package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	input := bufio.NewReader(os.Stdin)
	var s string

	_, err := fmt.Fscan(input, &s)
	if err != nil {
	}

	n := len(s)
	result := (n - 1) / 2
	k := s[1:]
	if (n-1)%2 != 0 {
		fmt.Println(result + 1)
		return
	}
	if t, _ := strconv.Atoi(k); t == 0 {
		fmt.Println(result)
		return
	}
	fmt.Println(result + 1)
}


package main

import (
	"fmt"
	"strconv"
)

func main() {
	var given string
	fmt.Scanf("%s", &given)
	lens := len(given)
	answer := (lens - 1) / 2
	oneplus := given[1:]
	if (lens-1)%2 != 0 {
		answer++
		fmt.Println(answer)
		return
	}
	rets := 0
	rets, _ = strconv.Atoi(oneplus)
	if rets == 0 {
		fmt.Println(answer)
		return
	}
	answer++
	fmt.Println(answer)

}


package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)
	N := len(s)
	res := (N - 1) / 2
	deg := s[0] == '1' && (N-1)%2 == 0
	for i := 1; i < N; i++ {
		if s[i] == '1' {
			deg = false
			break
		}
	}
	if !deg && s != "0" {
		res++
	}
	fmt.Print(res)
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var s string
	ch := make(chan string)
	go func() {
		scanner := bufio.NewScanner(os.Stdin)
		for scanner.Scan() {
			ch <- scanner.Text()
		}
	}()
	s = <-ch
	ss := strings.Split(s, " ")
	d, _ := strconv.Atoi(ss[0])
	if ss[len(ss)-1] == "month" {
		if d <= 29 {
			fmt.Println("12")
			return
		}
		if d <= 30 {
			fmt.Println("11")
			return
		}
		if d <= 31 {
			fmt.Println("7")
			return
		}
	}
	cw := 366 / 7
	if d == 5 || d == 6 {
		cw++
	}
	fmt.Printf("%v", cw)
	return
}


// cf611a project main.go
package main

import (
	"fmt"
)

func main() {
	var x int
	var s string
	fmt.Scanf("%d of %s", &x, &s)
	m := []int{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	d := []int{52, 52, 52, 52, 53, 53, 52}
	if s == "week" {
		fmt.Println(d[x-1])
	} else {
		var c int
		for _, v := range m {
			if v >= x {
				c++
			}
		}
		fmt.Println(c)
	}
}


package main

import "fmt"

//import "strings"

var s string
var n, ans int

func main() {
        fmt.Scanf("%d of %s", &n, &s)
        switch s {
        case "week":
                ans = cal_week(n)
        case "month":
                ans = cal_month(n)
        }
        fmt.Println(ans)
}

func cal_week(n int) int {
        if n == 5 || n == 6 {
                return 53
        } else {
                return 52
        }

}

func cal_month(n int) int {
        if n < 30 {
                return 12
        } else if n == 30 {
                return 11
        } else {
                return 7
        }
}


package main

import "fmt"

func main() {
    var n int
    var h,a [35]int
    fmt.Scan(&n)
    for i := 0; i < n; i++ { fmt.Scan(&h[i],&a[i]) }
    ans := 0
    for i := 0; i < n; i++ {
        for j := 0; j < n; j++ {
            if (i != j) && (h[i] == a[j]) {
                ans++
            }
        }
    }
    fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var noOfTeams, currNumber, result int
	reader := bufio.NewReader(os.Stdin)
	fmt.Fscan(reader, &noOfTeams)
	homeAway := make([][2]int, noOfTeams)
	for index := 0; index < noOfTeams; index++ {
		fmt.Fscan(reader, &currNumber)
		homeAway[index][0] = currNumber
		fmt.Fscan(reader, &currNumber)
		homeAway[index][1] = currNumber
	}
	for index := 0; index < noOfTeams; index++ {
		awayWear := homeAway[index][1]
		for innerIndex := 0; innerIndex < noOfTeams; innerIndex++ {
			if index == innerIndex {
				continue
			}
			if awayWear == homeAway[innerIndex][0] {
				result++
			}

		}
	}
	fmt.Println(result)
}


package main

import (
	"fmt"
)

func main() {
	var n, ans int
	fmt.Scan(&n)
	uni := make([][2]int, n)
	for i := range uni {
		fmt.Scan(&uni[i][0], &uni[i][1])
	}
	for home := range uni {
		for guest := range uni {
			if uni[home][0] == uni[guest][1] {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


/*
URL:
https://codeforces.com/problemset/problem/1114/C
*/

package main

import (
	"bufio"
	"errors"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
)

/********** FAU standard libraries **********/

//fmt.Sprintf("%b\n", 255) 	// binary expression

/********** I/O usage **********/

//str := ReadString()
//i := ReadInt()
//X := ReadIntSlice(n)
//S := ReadRuneSlice()
//a := ReadFloat64()
//A := ReadFloat64Slice(n)

//str := ZeroPaddingRuneSlice(num, 32)
//str := PrintIntsLine(X...)

/*******************************************************************/

const (
	// General purpose
	MOD          = 1000000000 + 7
	ALPHABET_NUM = 26
	INF_INT64    = math.MaxInt64
	INF_BIT60    = 1 << 60
	INF_INT32    = math.MaxInt32
	INF_BIT30    = 1 << 30
	NIL          = -1

	// for dijkstra, prim, and so on
	WHITE = 0
	GRAY  = 1
	BLACK = 2
)

func init() {
	// bufio.ScanWords <---> bufio.ScanLines
	ReadString = newReadString(os.Stdin, bufio.ScanWords)
	stdout = bufio.NewWriter(os.Stdout)
}

var (
	n, b int64
)

func main() {
	n, b = ReadInt64_2()

	if n == 1 {
		fmt.Println(0)
		return
	}

	memo := TrialDivision(b)

	counts := make(map[int64]int64)
	for a := range memo {
		cnt := int64(0)
		cur := a
		for n/cur > 0 {
			cnt += n / cur
			// PrintfDebug("cur: %d, diff: %d\n", cur, n/cur)

			if IsProductOverflow(cur, a, INF_INT64) {
				break
			}

			cur *= a
		}

		counts[a] = cnt
	}
	// PrintfDebug("素因数分解: %v\n", memo)
	// PrintfDebug("カウント: %v\n", counts)

	ans := int64(INF_INT64)
	for a, cnt := range counts {
		e := memo[a]
		ChMin(&ans, cnt/e)
	}
	fmt.Println(ans)
}

func IsProductOverflow(i, j, m int64) bool {
	return float64(i)*float64(j) > float64(m)
}

func IsAddOverflow(i, j, m int64) bool {
	return float64(i)+float64(j) > float64(m)
}

// ChMin accepts a pointer of integer and a target value.
// If target value is SMALLER than the first argument,
//	then the first argument will be updated by the second argument.
func ChMin(updatedValue *int64, target int64) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

// TrialDivision returns the result of prime factorization of integer N.
func TrialDivision(n int64) map[int64]int64 {
	var i, exp int64
	p := map[int64]int64{}

	if n <= 1 {
		panic(errors.New("[argument error]: TrialDivision only accepts a NATURAL number"))
	}

	for i = 2; i*i <= n; i++ {
		exp = 0
		for n%i == 0 {
			exp++
			n /= i
		}

		if exp == 0 {
			continue
		}
		p[i] = exp
	}
	if n > 1 {
		p[n] = 1
	}

	return p
}

/*******************************************************************/

/*********** I/O ***********/

var (
	// ReadString returns a WORD string.
	ReadString func() string
	stdout     *bufio.Writer
)

func newReadString(ior io.Reader, sf bufio.SplitFunc) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	r.Split(sf)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

// ReadInt returns an integer.
func ReadInt() int {
	return int(readInt64())
}
func ReadInt2() (int, int) {
	return int(readInt64()), int(readInt64())
}
func ReadInt3() (int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64())
}
func ReadInt4() (int, int, int, int) {
	return int(readInt64()), int(readInt64()), int(readInt64()), int(readInt64())
}

// ReadInt64 returns as integer as int64.
func ReadInt64() int64 {
	return readInt64()
}
func ReadInt64_2() (int64, int64) {
	return readInt64(), readInt64()
}
func ReadInt64_3() (int64, int64, int64) {
	return readInt64(), readInt64(), readInt64()
}
func ReadInt64_4() (int64, int64, int64, int64) {
	return readInt64(), readInt64(), readInt64(), readInt64()
}

func readInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// ReadIntSlice returns an integer slice that has n integers.
func ReadIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt()
	}
	return b
}

// ReadInt64Slice returns as int64 slice that has n integers.
func ReadInt64Slice(n int) []int64 {
	b := make([]int64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadInt64()
	}
	return b
}

// ReadFloat64 returns an float64.
func ReadFloat64() float64 {
	return float64(readFloat64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(ReadString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// ReadFloatSlice returns an float64 slice that has n float64.
func ReadFloat64Slice(n int) []float64 {
	b := make([]float64, n)
	for i := 0; i < n; i++ {
		b[i] = ReadFloat64()
	}
	return b
}

// ReadRuneSlice returns a rune slice.
func ReadRuneSlice() []rune {
	return []rune(ReadString())
}

/*********** Debugging ***********/

// ZeroPaddingRuneSlice returns binary expressions of integer n with zero padding.
// For debugging use.
func ZeroPaddingRuneSlice(n, digitsNum int) []rune {
	sn := fmt.Sprintf("%b", n)

	residualLength := digitsNum - len(sn)
	if residualLength <= 0 {
		return []rune(sn)
	}

	zeros := make([]rune, residualLength)
	for i := 0; i < len(zeros); i++ {
		zeros[i] = '0'
	}

	res := []rune{}
	res = append(res, zeros...)
	res = append(res, []rune(sn)...)

	return res
}

// Strtoi is a wrapper of strconv.Atoi().
// If strconv.Atoi() returns an error, Strtoi calls panic.
func Strtoi(s string) int {
	if i, err := strconv.Atoi(s); err != nil {
		panic(errors.New("[argument error]: Strtoi only accepts integer string"))
	} else {
		return i
	}
}

// PrintIntsLine returns integers string delimited by a space.
func PrintIntsLine(A ...int) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.Itoa(A[i])
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintIntsLine returns integers string delimited by a space.
func PrintInts64Line(A ...int64) string {
	res := []rune{}

	for i := 0; i < len(A); i++ {
		str := strconv.FormatInt(A[i], 10) // 64bit int version
		res = append(res, []rune(str)...)

		if i != len(A)-1 {
			res = append(res, ' ')
		}
	}

	return string(res)
}

// PrintfDebug is wrapper of fmt.Fprintf(os.Stderr, format, a...)
func PrintfDebug(format string, a ...interface{}) {
	fmt.Fprintf(os.Stderr, format, a...)
}

// PrintfBufStdout is function for output strings to buffered os.Stdout.
// You may have to call stdout.Flush() finally.
func PrintfBufStdout(format string, a ...interface{}) {
	fmt.Fprintf(stdout, format, a...)
}


package main

import (
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func CF1114C(in io.Reader, out io.Writer) {
	var n, x int64
	Fscan(in, &n, &x)
	ans := int64(1e18)
	f := func(p, e int64) {
		c := int64(0)
		for pp := p; ; pp *= p {
			c += n / pp
			if pp > n/p {
				break
			}
		}
		if c/e < ans {
			ans = c / e
		}
	}
	for i := int64(2); i*i <= x; i++ {
		e := int64(0)
		for ; x%i == 0; x /= i {
			e++
		}
		if e > 0 {
			f(i, e)
		}
	}
	if x > 1 {
		f(x, 1)
	}
	Fprint(out, ans)
}

func main() { CF1114C(os.Stdin, os.Stdout) }


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

// -----------------------------------------------------------------------------

// IO helper functions

// Returns next token from input.  It must be initialized by SetInput()
// before the first call.
var nextToken func() ([]byte, error)
var nextLine func() ([]byte, error)

// Holds a buffer for output.  It must be initialized by SetOutput().
// All IO fucntions (read*() and [e]print*()) should write to OutputWriter
// instead of this.
var OutputBuffer *bufio.Writer

// Holds an io.Writer.  It must be initialized by SetOutput()
var OutputWriter io.Writer

// Set IO functions for interactive input/output.
func SetInteractive(w io.Writer, r io.Reader) {
	SetUnbefferedInput(r)
	OutputBuffer = nil
	OutputWriter = w
}

// Setup OutputBuffer and OutputWriter.
func SetOutput(w io.Writer) {
	OutputBuffer = bufio.NewWriter(w)
	OutputWriter = OutputBuffer
}

// Flushes OutputBuffer
func Flush() {
	if OutputBuffer != nil {
		OutputBuffer.Flush()
	}
}

// Returns true if c is a white space
func IsSpace(c byte) bool {
	switch c {
	case '\t', '\n', '\v', '\f', '\r', ' ':
		return true
	}
	return false
}

func IsNewLine(c byte) bool {
	switch c {
	case '\n', '\r':
		return true
	}
	return false
}

// Setup nextToken with input buffer.
func SetInput(r io.Reader) {
	buf := new(bytes.Buffer)
	var b []byte

	var i int
	rest := func() ([]byte, error) {
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		return b[j:i], nil
	}
	initial := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextToken = rest
		return rest()
	}
	nextToken = initial

	restLn := func() ([]byte, error) {
		for i < len(b) && IsNewLine(b[i]) {
			i++
		}
		if i == len(b) {
			return nil, io.ErrUnexpectedEOF
		}
		j := i
		for i < len(b) && !IsNewLine(b[i]) {
			i++
		}
		return b[j:i], nil
	}

	initialLn := func() ([]byte, error) {
		io.Copy(buf, r)
		b = buf.Bytes()
		nextLine = restLn
		return restLn()
	}
	nextLine = initialLn
}

// Setup nextToken without input buffer.
func SetUnbefferedInput(r io.Reader) {
	buf := bufio.NewReader(r)
	var b []byte

	var i int
	nextToken = func() ([]byte, error) {
		var err error
		if i == len(b) {
			b, err = buf.ReadBytes('\n')
			if err != nil {
				return nil, err
			}
			i = 0
			j := len(b) - 1
			for 0 <= j && IsSpace(b[j]) {
				j--
			}
			b = b[0 : j+1]
		}
		for i < len(b) && IsSpace(b[i]) {
			i++
		}
		j := i
		for i < len(b) && !IsSpace(b[i]) {
			i++
		}
		if i == j {
			return nil, io.ErrUnexpectedEOF
		}
		return b[j:i], nil
	}
}

// -----------------------------------------------------------------------------

// IO functions

// Reads next token and return it as []byte
func readb() []byte {
	b, err := nextToken()
	if err != nil {
		panic(err)
	}
	return b
}

// Reads next token and return it as string
func reads() string {
	return string(readb())
}

// Read next line as []byte
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b
}

// Read next line as string
func readsln() string {
	return string(readbln())
}

// Reads next token and return it as int64
func readll() int64 {
	i, err := strconv.ParseInt(reads(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

// Reads next token and return it as int
func readi() int {
	return int(readll())
}

// Reads next token and return it as float64
func readf() float64 {
	f, err := strconv.ParseFloat(reads(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

// Write args to OutputWriter with the format f
func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(OutputWriter, f, args...)
}

// Write args to OutputWriter without format
func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(OutputWriter, args...)
}

// Write args to stderr with the format f
func eprintf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(os.Stderr, f, args...)
}

// Write args to stderr without format
func eprintln(args ...interface{}) (int, error) {
	return fmt.Fprintln(os.Stderr, args...)
}

// -----------------------------------------------------------------------------

// Simple math functions

const (
	// big prime
	INF  = 1000000007
	INF2 = 1000000009
	INF3 = 998244353
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func minll(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func maxll(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absll(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

// egcd(a, b) returns d, x, y:
//   d is gcd(a,b)
//   x, y are  integers that satisfy ax + by = d
func egcd(a, b int) (int, int, int) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcd(b, a%b)
	return d, y, x - a/b*y
}

func egcdll(a, b int64) (int64, int64, int64) {
	if b == 0 {
		return a, 1, 0
	}
	d, x, y := egcdll(b, a%b)
	return d, y, x - a/b*y
}

func gcd(a, b int) int {
	d, _, _ := egcd(a, b)
	return d
}

func gcdll(a, b int64) int64 {
	d, _, _ := egcdll(a, b)
	return d
}

// set up IO functions
func init() {
	// for non-interactive
	SetInput(os.Stdin)
	SetOutput(os.Stdout)

	// Enable below when interactive.  Its ok to leave above intact.
	// SetInteractive(os.Stdout, os.Stdin)
}

func main() {
	defer Flush()

	n := readi()
	println(n/2 + 1)
}


package main
import "fmt"

func main(){
    var n int
    fmt.Scan(&n)
    fmt.Println(n/2+1)
}


// Codeforces helper functions
// 20 Jan 18
// samadhi

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
	"strings"
	"unicode"
)

const debug = true

func main() {
	reader := bufio.NewReader(os.Stdin)

	n := gsli(reader)[0]

	if n == 1 {
		fmt.Println("1")
		return
	}

	fmt.Println(n/2 + 1)

}

// Input helpers

// If you don't pass in a reference to the reader, and just instantiate a new
// one every time, it will work locally, with IO typed at human-speed, but not
// on Codeforces.

// Get Space-separated Line as Strings
//
// Example input:
// 1 test 382.0
// Example output:
// ["1", "test", "382.0"]

func gsls(reader *bufio.Reader) (arr []string) {
	// Get a full line
	input, _ := reader.ReadString('\n')

	//Strip newline and return chars, if any
	input = strings.TrimSuffix(input, "\n")
	input = strings.TrimSuffix(input, "\r")

	// Split at the spaces into an array
	arr = strings.Split(input, " ")

	return
}

// Get Space-separated Line as Integers
// Any non-valid integers will be 0
//
// Example input:
// test 1 12.3 -117
// Example output:
// [0, 1, 0, -117]

func gsli(reader *bufio.Reader) (arr []int) {
	stringArr := gsls(reader)

	for _, e := range stringArr {
		cur, _ := strconv.Atoi(e)
		arr = append(arr, cur)
	}

	return
}

// Get Space-separated Line as 64-bit Floats
// Any non-valid floats will be 0
//
// Example input:
// test 128.328 12 -11.0
// Example output:
// [0, 128.328, 12, -11]

func gslf(reader *bufio.Reader) (arr []float64) {
	stringArr := gsls(reader)

	for _, e := range stringArr {
		cur, _ := strconv.ParseFloat(e, 64)
		arr = append(arr, cur)
	}

	return
}

// String helpers

// Is Lowercase
// Given some string[i], return whether it is lower case or not.

func isl(b byte) bool {
	var r rune
	r = rune(b)
	return unicode.IsLower(r)
}

// Math helpers

// Positve Modulo
// Returns x mod y, but always positive

func posMod(x, y int) int {
	return (x%y + y) % y
}

// Max Int
// Returns the max of two ints

func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}

// Distance formule
// Calculates the distance to the origin

func dist(x, y float64) float64 {
	return math.Sqrt(math.Pow(x, 2) + math.Pow(y, 2))
}

// Output helpers

func yes() {
	fmt.Println("Yes")
}

func no() {
	fmt.Println("No")
}

// Debug helpers

// From https://groups.google.com/forum/#!topic/golang-nuts/Qlxs3V77nss

func dbg(s string, a ...interface{}) {
	if debug {
		fmt.Printf(s, a...)
	}
}


package main

import (
	"fmt"
	"math"
)

func main() {
	i:=0.0
	fmt.Scanln(&i)
	c:=math.Log2(i)
	d:=float64(int(c))
	if c-d<0.000001 {
		fmt.Println("YES")
	}else {
		fmt.Println("NO")
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt64()
	m := readInt64()
	a := readInt64()
	b := readInt64()
	rest := n % m
	if rest == 0 {
		fmt.Println(0)
		return
	}
	ans := min(a*(m-rest), b*rest)
	fmt.Println(ans)
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}


package main

import "fmt"

var n, m, a, b int64

func min(a, b int64) int64 {
    if a < b {
        return a
    } else {
        return b
    }
}

func main() {
    fmt.Scan(&n, &m, &a, &b)
    if n % m == 0 {
        fmt.Println("0")
    } else {
        c := n / m
        ans := min((c * m + m - n) * a, (n - c * m) * b)
        fmt.Println(ans)
    }
}


package main

import (
	"fmt"
)

func main() {
	var n, m, a, b int64

	fmt.Scanf("%d %d %d %d", &n, &m, &a, &b)

	if n%m == 0 {
		fmt.Println("0")
	} else {
		division := n / m
		build := (division+1)*m - n
		demolish := division*m - n

		build *= a
		demolish *= -b

		if build > demolish {
			fmt.Println(demolish)
		} else {
			fmt.Println(build)
		}
	}
}


package main

import (
	"bytes"
	"fmt"
	"io/ioutil"
	"os"
)

const MAX = 300

var vis [MAX][MAX][32][10][6]bool
var mark [MAX][MAX]bool
var dx [8]int = [8]int{1, 1, 1, 0, -1, -1, -1, 0}
var dy [8]int = [8]int{-1, 0, 1, 1, 1, 0, -1, -1}

var n int
var t []int

func dfs(x, y, c, dir, step int) {

	if c == n || vis[x][y][c][dir][step] {
		return
	}

	//fmt.Printf("%d %d %d %d %d\n", x, y, c, dir, step)

	mark[x][y] = true
	vis[x][y][c][dir][step] = true
	if step > 0 {
		dfs(x+dx[dir], y+dy[dir], c, dir, step-1)
	} else {
		dfs(x+dx[(dir+1)%8], y+dy[(dir+1)%8], c+1, (dir+1)%8, t[c+1]-1)
		dfs(x+dx[(dir+7)%8], y+dy[(dir+7)%8], c+1, (dir+7)%8, t[c+1]-1)
	}
}

func main() {
	b, _ := ioutil.ReadAll(os.Stdin)
	r := bytes.NewReader(b)
	fmt.Fscanf(r, "%d\n", &n)

	t = make([]int, n+1)
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(r, "%d ", &t[i])
	}
	fmt.Fscanf(r, "%d\n", &t[n-1])

	for i := 0; i < MAX; i++ {
		for j := 0; j < MAX; j++ {
			for k := 0; k < 32; k++ {
				for l := 0; l < 10; l++ {
					for m := 0; m < 6; m++ {
						vis[i][j][k][l][m] = false
					}
				}
			}
		}
	}

	dfs(150, 150, 0, 1, t[0]-1)

	cnt := 0

	for i := 0; i < MAX; i++ {
		for j := 0; j < MAX; j++ {
			if mark[i][j] {
				cnt++
			}
		}
	}

	fmt.Printf("%d\n", cnt)

}


package main

import (
	"bufio"
	"fmt"
	"os"
)

type move struct {
	x  int
	y  int
	dx int
	dy int
	w  int
}

const W = 5000 * 1000
const H = 5*30*2 + 10
const Z = H / 2

var used [H][H]bool
var wave [H][H][3][3][2]bool
var t [31]int
var n int
var maxw int

var q [W]move
var hd, tl int

func push(m move) {
	q[tl] = m
	if tl == W-1 {
		tl = 0
	} else {
		tl += 1
	}
}

func pop() move {
	ret := q[hd]
	if hd == W-1 {
		hd = 0
	} else {
		hd += 1
	}
	return ret
}

func empty() bool {
	return hd == tl
}

var ndx [3][3]int
var ndy [3][3]int
var ndxx [3][3]int
var ndyy [3][3]int

func do() {
	m := pop()

	tt := t[m.w]
	lx := m.x + (tt-1)*m.dx
	ly := m.y + (tt-1)*m.dy

	//fmt.Printf("%d lines from (%d, %d) with dir (%d, %d)\n", tt, m.x-Z, m.y-Z, m.dx, m.dy)

	for i := 0; i < tt; i++ {
		used[m.x+i*m.dx][m.y+i*m.dy] = true
	}

	if m.w+1 < n {
		ndx1 := ndx[1+m.dx][1+m.dy]
		ndy1 := ndy[1+m.dx][1+m.dy]
		x1 := lx + ndx1
		y1 := ly + ndy1

		nw := (m.w + 1) % 2
		if m.w+1 > maxw {
			maxw = m.w + 1
			clear()
		}

		if !wave[x1][y1][1+ndx1][1+ndy1][nw] {
			wave[x1][y1][1+ndx1][1+ndy1][nw] = true
			push(move{x1, y1, ndx1, ndy1, m.w + 1})
		}

		ndx2 := ndxx[1+m.dx][1+m.dy]
		ndy2 := ndyy[1+m.dx][1+m.dy]
		x2 := lx + ndx2
		y2 := ly + ndy2
		if !wave[x2][y2][1+ndx2][1+ndy2][nw] {
			wave[x2][y2][1+ndx2][1+ndy2][nw] = true
			push(move{x2, y2, ndx2, ndy2, m.w + 1})
		}
	}
}

func clear() {
	k := maxw % 2
	for x := 0; x < H; x++ {
		for y := 0; y < H; y++ {
			for i := 0; i < 3; i++ {
				for j := 0; j < 3; j++ {
					wave[x][y][i][j][k] = false
				}
			}
		}
	}
}

func main() {

	ndy = [3][3]int{
		{0, 1, 1},
		{-1, 0, 1},
		{-1, -1, 0},
	}

	ndx = [3][3]int{
		{-1, -1, 0},
		{-1, 0, 1},
		{0, 1, 1},
	}

	ndyy = [3][3]int{
		{-1, -1, 0},
		{-1, 0, 1},
		{0, 1, 1},
	}

	ndxx = [3][3]int{
		{0, -1, -1},
		{1, 0, -1},
		{1, 1, 0},
	}

	in := bufio.NewReader(os.Stdin)

	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &t[i])
	}

	for x := 0; x < H; x++ {
		for y := 0; y < H; y++ {
			for i := 0; i < 3; i++ {
				for j := 0; j < 3; j++ {
					for z := 0; z < 2; z++ {
						wave[x][y][i][j][z] = false
					}
				}
			}
			used[x][y] = false
		}
	}

	wave[Z][Z][0][1][0] = true
	push(move{Z, Z, 0, 1, 0})
	maxw = 0

	for !empty() {
		do()
	}

	ret := 0
	for x := 0; x < H; x++ {
		for y := 0; y < H; y++ {
			if used[x][y] {
				ret += 1
			}
		}
	}
	fmt.Println(ret)
}


package main

import (
        "bufio"
        "fmt"
        "os"
        "strconv"
)
type Pos struct {
    i, j, lvl, di, dj int
}

func solve() {
    const mx = 300
    n := readInt()
    a := readIntArray(n)

    was := [mx+2][mx+2][31][3][3]bool{}
    ans := [mx+2][mx+2]bool{}
    setWas := func(p Pos) {
        was[p.i][p.j][p.lvl][p.di+1][p.dj+1] = true
    }
    checkWas := func(p Pos) bool {
        return was[p.i][p.j][p.lvl][p.di+1][p.dj+1]
    }
    q := []Pos{Pos{mx/2, mx/2, 0, 1, 0}}
    setWas(q[0])
    for i := 0; i < len(q); i++ {
        cur := q[i]
        for t := 0; t < a[cur.lvl]; t++ {
            cur.i += cur.di
            cur.j += cur.dj
            ans[cur.i][cur.j] = true
        }
        if nextLvl := cur.lvl+1; nextLvl < n {
            for rot := -1; rot < 2; rot += 2 {
                next := Pos{cur.i, cur.j, nextLvl, 0, 0}
                if abs(cur.di*cur.dj) == 1 {
                    if rot == 1 {
                        next.di = cur.di
                    } else {
                        next.dj = cur.dj
                    }
                } else {
                    if cur.di == 0 {
                        next.di = rot
                        next.dj = cur.dj
                    } else {
                        next.di = cur.di
                        next.dj = rot
                    }
 				}
                if !checkWas(next) {
                    setWas(next)
                    q = append(q, next)
                }
            }
        }
    }
    res := 0
    for i := range ans {
        for _, b := range ans[i] {
            if b {
                res++
            }
        }
    }
    fmt.Println(res)
}

// Helpers

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)

func main() {
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// Math

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}

// Sort

type Ints64 []int64

func (a Ints64) Len() int           { return len(a) }
func (a Ints64) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a Ints64) Less(i, j int) bool { return a[i] < a[j] }

/* Sort tempalte
func (a ) Len() int           { return len(a) }
func (a ) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a ) Less(i, j int) bool { return  }
*/


// https://codeforces.com/problemset/problem/1097/B

package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader *bufio.Reader = bufio.NewReader(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{}) { fmt.Fscanf(reader, f, a...) }

func main() {
	defer writer.Flush()

	var n int64
	scanf("%d\n", &n)
	arr := make([]int64, n)

	for i:=int64(0);i<n;i++ {
		var temp int64
		scanf("%d\n", &temp)
		arr[i] = temp
	}

	for i:=int64(0);i<(int64(1) << n);i++ {
		sum := int64(0)
		for j:=int64(0);j<n;j++ {
			if i & (int64(1) << j) != 0 {
				sum += arr[j]
			} else {
				sum -= arr[j]
			}
		}

		if sum % 360 == 0 {
			printf("%s\n", "YES")
			return
		}
	}

	printf("%s\n", "NO")
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d\n", &a[i])
	}
	b := make([]int, n)
	find := false
	for i := 0; i < 1<<uint(n); i++ {
		cur := 0
		q := i
		for j := 0; j < n; j++ {
			b[j] = q % 2
			q /= 2
			if b[j] == 0 {
				cur += a[j]
			} else {
				cur -= a[j]
			}
		}
		if cur%360 == 0 {
			find = true
		}
	}
	if find {
		fmt.Fprintf(out, "YES\n")
	} else {
		fmt.Fprintf(out, "NO\n")
	}
	return
}


package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanInt := func() int {
		scanner.Scan()
		num, err := strconv.Atoi(scanner.Text())
		if err != nil {
			log.Fatal(err)
		}
		return num
	}

	n := scanInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = scanInt()
	}

	solutionCount := uint(math.Pow(2.0, float64(n)))
	for i := uint(0); i < solutionCount; i++ {
		sum := 0
		for j := 0; j < n; j++ {
			if (i>>uint(j))&1 == 1 {
				sum += a[j]
			} else {
				sum -= a[j]
			}
		}
		if sum%360 == 0 {
			fmt.Println("YES")
			os.Exit(0)
		}
	}

	fmt.Println("NO")
}


package main

import (
	"fmt"
	"math"
)

func fac(num int64) int64 {
	if num == 1 {
		return num
	}
	return fac(num-1) * num
}

func main() {
	var a int64
	var b int64
	fmt.Scanf("%d %d", &a, &b)
	var minnum = int64(math.Min(float64(a), float64(b)))
	fmt.Printf("%v\n", fac(minnum))
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var n, m int

	fmt.Scan(&n, &m)
	var c int = 1
	for i := 1; i <= int(math.Min(float64(n), float64(m))); i++ {
		c = c * i
	}
	fmt.Println(c)
}


package main

import "fmt"

var (
        a, b int64
)

func main() {
        fmt.Scanln(&a,&b)
        if a>b {
                a = b
        }
        b := int64(1)
        for i := int64(1) ; i<=a ; i++ {
                b *=i
        }
        fmt.Println(b)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

const NMAX = 100
const EMPTY = 255
const INFINITY = uint32(999999)

func toInt(buf []byte) uint32 {
	n := uint32(0)
	for _, v := range buf {
		n = n*10 + uint32(v-'0')
	}

	return n
}

func solve(n uint32, p [NMAX]uint32) uint32 {
  type State struct  {
    odds int
    evens int
    last uint32
    index uint32
  }

  start := State{}

  for i := uint32(1); i <= n; i++ {
    f := false
    for j := uint32(0); j < n; j++ {
      f = f || i == p[j]
    }

    if !f {
      if i % 2 == 0 {
        start.evens++
      } else {
        start.odds++
      }
    }
  }

  memo := map[State]uint32{}
  var solve func(s State) uint32
  solve = func(s State) uint32 {
    if r, f := memo[s]; f {
      return r
    }

    i, r := s.index, uint32(0)
    for ; i < n && p[i] != 0; i++ {
      if i > 0 {
        prev := p[i - 1]
        if prev == 0 {
          prev = s.last
        }
        if prev % 2 != p[i] % 2 {
          r++
        }
      }
    }

    prev := uint32(0)
    if i > 0 {
      prev = p[i - 1]
      if prev == 0 {
        prev = s.last
      }
    }

    if i < n && p[i] == 0 {
      r1, r2 := INFINITY, INFINITY
      if s.odds > 0 {
        next := State{index: i + 1, odds: s.odds - 1, evens: s.evens, last: 1}
        r1 = solve(next)
        if i > 0 && (prev % 2 == 0) {
          r1++
        }
      }

      if s.evens > 0 {
        next := State{index: i + 1, odds: s.odds, evens: s.evens - 1}
        r2 = solve(next)
        if i > 0 && (prev % 2 > 0) {
          r2++
        }
      }

      if r1 > r2 {
        r1 = r2
      }

      r += r1
    }

    memo[s] = r

    return r
  }

  return solve(start)
}

func main() {
	var n uint32

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	n = toInt(scanner.Bytes())

  p := [NMAX]uint32{}
  for i := uint32(0); i < n; i++ {
    scanner.Scan()
    p[i] = toInt(scanner.Bytes())
  }

  res := solve(n, p)
  fmt.Println(res)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

const N  = 102
const Mask  = 2
const INF  = 1e9 + 1

var n int
var dp[N][N][Mask] int
var cnt[N] int
var a[N] int

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

func main()  {
	defer writer.Flush()
	fmt.Fscanf(reader, "%d\n", &n)

	var odd = 0
	for i := 1; i <= n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
		cnt[i] = cnt[i - 1]
		if a[i]%2 != 0 {
			cnt[i]++
			odd++
		}
	}

	var mo = n / 2
	if n % 2 != 0 {
		mo++
	}
	mo -= odd

	for i := 0; i <= n; i++ {
		for j := 0; j <= n; j++ {
			dp[i][j][0] = INF
			dp[i][j][1] = INF
		}
	}

	dp[0][0][0] = 0
	dp[0][0][1] = 0

	for i := 0; i < n; i++ {
		for j := 0; j <= mo; j++ {
			for k := 0; k < 2; k++ {
				if a[i+1] > 0 {
					// already
					var nk= a[i+1] % 2
					var add= 0
					if nk != k {
						add++
					}
					dp[i+1][j][nk] = min(dp[i+1][j][nk], dp[i][j][k]+add)
				} else {
					// even
					{
						var add= 0
						if k != 0 {
							add++
						}
						dp[i+1][j][0] = min(dp[i+1][j][0], dp[i][j][k]+add)
					}
					// odd
					{
						var add= 0
						if k != 1 {
							add++
						}
						if j+1 <= mo {
							dp[i+1][j+1][1] = min(dp[i+1][j+1][1], dp[i][j][k]+add)
						}
					}
				}
			}
		}
	}

	var ret = min(dp[n][mo][0], dp[n][mo][1])
	fmt.Fprintf(writer, "%d\n", ret)
}


package main

import (
	"fmt"
	"sort"
)

func work(capacity int, arrOne []int, arrTwo []int) int {
	sort.Ints(arrOne)
	sort.Ints(arrTwo)
	used, cnt, ans := 0, 0, 0
	for i, j := -1, -1; i <= len(arrOne); i++ {
		for ; j + 1 < len(arrTwo) && used + arrTwo[j + 1] <= capacity; j++ {
			used += arrTwo[j + 1]
			cnt += 2
		}
		for ; j >= 0 && used > capacity; j-- {
			used -= arrTwo[j]
			cnt -= 2
		}
		if used <= capacity && cnt > ans {
			ans = cnt
		}
		if i + 1 < len(arrOne) {
			used += arrOne[i + 1]
			cnt++
		}
	}
	// fmt.Println("-=", ans)
	return ans
}

func main() {
	var n, x int
	fmt.Scan(&n)
	if n == 1 {
		fmt.Println(0)
		return
	}
	cntOdd, cntEven := (n + 1) / 2, n / 2
	var odd, odd2, even, even2 []int
	last, emptyLen, ans := -1, 0, 0
	for i := 0; i < n; i++ {
		fmt.Scan(&x)
		if x == 0 {
			emptyLen++
			continue
		}
		x %= 2
		if x == 1 {
			cntOdd--
		} else {
			cntEven--
		}
		if last != -1 && x != last {
			ans++
		}
		if emptyLen > 0 {
			if last == -1 || last == x {
				if last == -1 {
					ans++
					if x == 0 {
						even = append(even, emptyLen)
					} else {
						odd = append(odd, emptyLen)
					}
				} else {
					ans += 2
					if x == 0 {
						even2 = append(even2, emptyLen)
					} else {
						odd2 = append(odd2, emptyLen)
					}
				}
			}
			emptyLen = 0
		}
		last = x
	}

	if last == -1 {
		fmt.Println(1)
		return
	}
	if emptyLen > 0 {
		ans++
		if last == 0 {
			even = append(even, emptyLen)
		} else {
			odd = append(odd, emptyLen)
		}
	}
	// fmt.Println("ans", ans)
	ans -= work(cntEven, even, even2)
	ans -= work(cntOdd, odd, odd2)
	fmt.Println(ans)
}


package main

import "fmt"

func main() {
	var n, t, k, d int
	fmt.Scan(&n, &t, &k, &d)
	no := (n + k - 1) / k * t
	if no <= d+t {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


package main

import "fmt"

func main() {
	var n, k, t, d int
	fmt.Scan(&n, &t, &k, &d)
	x := t
	for d >= 0 {
		if x == t {
			n -= k
		}
		if n <= 0 {
			fmt.Println("NO")
			return
		}
		d--
		x--
		if x == 0 {
			x = t
		}
	}
	fmt.Println("YES")
	return
}


package main

import (
	"fmt"
)

func main()  {
	var noOfNeededCakes int
	fmt.Scan(&noOfNeededCakes)
	var timeNeedForCakes int
	fmt.Scan(&timeNeedForCakes)
	var noOfCakesAtSameTime int
	fmt.Scan(&noOfCakesAtSameTime)
	var timeToBuildOven int
	fmt.Scan(&timeToBuildOven)
	g := (noOfNeededCakes + noOfCakesAtSameTime - 1 ) / noOfCakesAtSameTime
	normalCycle := 0
	twoCycle := timeToBuildOven
	for i := 1; i <= g; i++ {
		if normalCycle <= twoCycle {
			normalCycle += timeNeedForCakes
		} else {
			twoCycle += timeNeedForCakes
		}
	}
	max := 0
	if normalCycle > twoCycle {
		max = normalCycle
	} else {
		max = twoCycle
	}
	if max < g * timeNeedForCakes {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}


package main

import "fmt"

func main() {
	var N, K int64
	fmt.Scanf("%d %d", &N, &K)
	odds := N / 2 + N % 2

	if K <= odds {
		fmt.Println(1 + (K - 1) * 2)
	} else {
		fmt.Println(2 + (K - odds - 1) * 2)
	}
}


package main

import (
	"fmt"
	"bufio"
	"os"
)

var in *bufio.Reader = bufio.NewReader(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	var n,k int64
 	var even int64
	fmt.Fscan(in,&n)
	fmt.Fscan(in,&k)

	if n % 2 == 0 {
		even = n / 2
	}else {
		even = n / 2 + 1
	}

	if k > even {
		fmt.Println((k-even) * 2)
	}else{
		fmt.Println((k * 2) - 1)
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

var n, k int64

func main() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader := bufio.NewReaderSize(stdin, 1<<20)
	fmt.Fscanf(reader, "%d%d\n", &n, &k)

	if k <= (n+1)/2 {
		fmt.Println(2*k - 1)
	} else {
		fmt.Println(2 * (k - (n+1)/2))
	}
}


package main

import "fmt"

func main() {
    var n, i int

    fmt.Scan(&n)

    for cnt:=1; cnt<=n; i++{
        cnt *= 2;
    }

    fmt.Println(i)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main()  {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	cnt := 0
	double := 1
	for n > 0 {
		cnt++
		n -= double
		double *= 2
	}

	fmt.Fprintln(out, cnt)

}


package main

import "fmt"
import "math"
func main() {
	 var n float64
	fmt.Scanf("%f",&n)
	x:=int(math.Log2(n))
	fmt.Println(x+1);
}


package main

import (
	"fmt"
)

func main() {
	var (
		n int
	)
	fmt.Scan(&n)
	a, b := Calculate854A(n)
	fmt.Print(a, b)
}

func Calculate854A(n int) (int, int) {
	for a := n / 2; a > 0; a-- {
		var b = n - a
		if Gcd(a, b) == 1 {
			return a, b
		}
	}
	return 0, 0
}

func Gcd(a int, b int) (int) {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}


package main

import (
        "fmt"
)

func gcd(a int, b int) int {
        if b == 0 {
                return a
        }
        if a < b {
                return gcd(b, a)
        } else {
                return gcd(b, a%b)
        }
}

var num int

func main() {
        fmt.Scan(&num)
        div := num / 2
        for i := div; div >= 1; i-- {
                if gcd(i, num-i) == 1 {
                        fmt.Println(i, num-i)
                        break
                }
        }
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	ansA := 0
	ansB := 0
	for i := 1; i <= n; i++ {
		a := i
		b := n - i
		if a < b {
			ok := true
			for j := 2; j <= a; j++ {
				if a%j == 0 && b%j == 0 {
					ok = false
					break
				}
			}
			if ok {
				ansA = a
				ansB = b
			}
		}
	}
	fmt.Printf("%d %d\n", ansA, ansB)
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a int, b int) int {
	if a < b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}


package main

import (
	"fmt"
)

func main() {
	var n uint64
	fmt.Scanf("%d", &n)

	switch n {
	case 0:
		fmt.Println("1")
	case 1:
		fmt.Println("5")
	default:
		fmt.Println("25")
	}
}


package main

import "fmt"

func main() {
	fmt.Println(25)
}


package main

import "fmt"

func main(){
	fmt.Println(25)
}


package main

import "fmt"

func main() {
    var x,t,a,b,da,db int
    fmt.Scan(&x,&t,&a,&b,&da,&db)
    m := make(map[int]bool)
    m[0] = true
    for i := 0; i < t; i++ {
        m[a-(da*i)] = true
    }
    ans := false
    for i := 0; i <= t; i++ {
        if i == t {
            if m[x] {
                ans = true
                break
            }
        } else if m[x-(b-(db*i))] {
            ans = true
            break
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}


package main

import (
	"os"
	"bufio"
	"strconv"
)

func scanInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	x, _ := strconv.Atoi(scanner.Text())
	return x
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	x, t := scanInt(scanner), scanInt(scanner)
	a, b := scanInt(scanner), scanInt(scanner)
	da, db := scanInt(scanner), scanInt(scanner)
	if x == 0 {
		writer.WriteString("YES\n")
		return
	}
	for i := 0; i < t; i++ {
		for j := 0; j < t; j++ {
			f, g := a-i*da, b-j*db
			if x == f || x == g || x == f+g {
				writer.WriteString("YES\n")
				return
			}
		}
	}
	writer.WriteString("NO\n")
}


// 203A
package main

import (
	"fmt"
)

func main() {
	var (
		x, t, a, b, va, vb int
		ax, bx             [305]int
	)
	fmt.Scan(&x, &t, &a, &b, &va, &vb)
	ax[0], ax[t] = a, 0
	bx[0], bx[t] = b, 0
	for i := 1; i < t; i++ {
		bx[i] = bx[i-1] - vb
		ax[i] = ax[i-1] - va
	}
	for i := 0; i <= t; i++ {
		for j := 0; j <= t; j++ {
			if ax[i]+bx[j] == x {
				fmt.Print("YES")
				return
			}
		}
	}
	fmt.Print("NO")
	return
}


package main

import (
	"fmt"
)

func cell(n int) int {
    if n == 1 {
        return 1
    } else {
        return 4*(n-1) + cell(n-1)
    }
}

func main() {
	var n int
    fmt.Scan(&n)
    fmt.Println(cell(n))
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d" ,&n);
	fmt.Printf("%d", (n - 1)*(n - 1)*2 + 2*n - 1);

}


package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	var input io.Reader = bufio.NewReader(os.Stdin)

	var n int
	var a [105]int
	var d [105]int

	fmt.Fscan(input, &n)

	d[1] = 1
	a[1] = 0

	for i := 2; i <= n; i++ {
		a[i] = a[i-1] + 4
		d[i] = a[i] + d[i-1]
	}

	fmt.Println(d[n])

}


package main

import "fmt"

func check(d... int) bool {
    for _, v := range d {
        if v != d[0] { return false }
    }
    return true
}

func main() {
    var a [3][3]int
    total := 0
    for i := 0; i < 3; i++ {
        for j := 0; j < 3; j++ {
            fmt.Scan(&a[i][j])
            total += a[i][j]
        }
    }
    total /= 2
    for i := 0; i < 3; i++ {
        t := total
        for j := 0; j < 3; j++ { t -= a[i][j] }
        a[i][i] = t
    }
    for i := 0; i < 3; i++ {
        for j := 0; j < 3; j++ {
            fmt.Print(a[i][j])
            if j == 2 { fmt.Println() } else { fmt.Print(" ") }
        }
    }
}


package main

import (
    "fmt"
    )

func main() {
    var n, m int
    fmt.Scan(&n, &m)

    ans := 0
    for a := 0; a <= m; a++ {
        b := n - a*a
        if b >= 0 && a + b*b == m {
            ans++
        }
    }

    fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var n, m int64
	fmt.Fscanln(reader, &n, &m)
	var total, i, j, isquare, jsquare int64
	for i <= n {
		j = i
		jsquare = isquare
		for j <= m {
			if isquare+j == n && i+jsquare == m {
				total += 1
				if i != j && jsquare+i == n && j+isquare == m {
					total += 1
				}
			} else if jsquare+i == n && j+isquare == m {
				total += 1
			}
			j += 1
			jsquare += (2*j - 1)
		}
		i += 1
		isquare += (2*i - 1)
	}
	fmt.Fprintln(writer, total)
}


package main

import "fmt"

func main() {
    var n,m int
    fmt.Scan(&n,&m)
    ans := 0
    for a := 0; a <= m; a++ {
        for b := 0; b <= n; b++ {
            if ((a*a+b) == n) && ((a+b*b) == m) { ans++ }
        }
    }
    fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	var k, r int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &k, &r)
	sum := 0
	i := 0
	for ; ; i++ {
		sum += k
		if sum%10 == 0 || sum%10 == r {
			break
		}
	}
	fmt.Println(i + 1)
}


package main

import (
	"fmt"
)

func main() {
	var k, r int
	fmt.Scanf("%d %d", &k, &r)
	for i := 1; i <= 9; i++ {
		if k*i%10 == 0 || k*i%10 == r {
			fmt.Println(i)
			break
		}
	}
}


package main

import "fmt"

// https://codeforces.com/problemset/problem/732/A
// комментарии к решению
// Десятичных монет неограниченное количество, поэтому нас интересует
// строго десятичный остаток стоимости, что приводит к конечному кол-ву
// решений. Перебираем все на листочке и выписываем двумерный массив решений
func taskSolution(k int, r int) int {
	counts := [][]int{
		{1, 1, 1, 1, 1, 1, 1, 1, 1},  // k%10 = 0
		{1, 2, 3, 4, 5, 6, 7, 8, 9},  // k%10 = 1
		{5, 1, 5, 2, 5, 3, 5, 4, 5},  // k%10 = 2
		{7, 4, 1, 8, 5, 2, 9, 6, 3},  // k%10 = 3
		{5, 3, 5, 1, 5, 4, 5, 2, 5},  // k%10 = 4
		{2, 2, 2, 2, 1, 2, 2, 2, 2},  // k%10 = 5
		{10, 2, 5, 4, 5, 1, 5, 3, 5}, // k%10 = 6
		{3, 6, 9, 2, 5, 8, 1, 4, 7},  // k%10 = 7
		{5, 4, 5, 3, 5, 2, 5, 1, 5},  // k%10 = 8
		{9, 8, 7, 6, 5, 4, 3, 2, 1},  // k%10 = 9
	}

	return counts[k%10][r-1]
}

func main() {
	var k, r int
	if _, err := fmt.Scan(&k, &r); err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(k, r))
}


package main

import "fmt"

func min(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}

func main() {
	var y, b, r int
	fmt.Scanf("%v %v %v", &y, &b, &r)
	ans_r := min(y + 2, min(b + 1, r))
	fmt.Println((ans_r - 1) * 3)
}


package main

import (
	"fmt"
)

func min ( a int, b int ) int {
	if a > b {
		return b
	}
	return a
}

func main() {
	var y, b, r int
	fmt.Scanf ( "%d %d %d\n", &y, &b, &r )
	b--; r -= 2
	fmt.Println ( min ( min ( y, b ), r ) * 3 + 3 )
}


package main

import "fmt"

func main() {
	var y, b, r int
	fmt.Scan(&y, &b, &r)
	if b <= y {
		y = b - 1
	} else {
		b = y + 1
	}
	if r <= b {
		b = r - 1
		y = b - 1
	} else {
		r = b + 1
	}
	fmt.Println(y + b + r)
}


package main
import (
	"fmt"
)
func main() {
	var n,k,l,c,d,p,nl,np,a int
	fmt.Scan(&n,&k,&l,&c,&d,&p,&nl,&np)
	k*=l
	c*=d
	k/=nl
	p/=np
	if k>p {
		a=p
	} else {a=k}
	if a>c {
		a=c
	}
	fmt.Println(a/n)
}


package main

import (
	"fmt"
)

func min(x,y int64) int64 {
    if x>y {
        return y
    } else {
        return x
    }
}

func main() {
	var n,k,l,c,d,p,nl,np int64
	fmt.Scanf("%d %d %d %d %d %d %d %d",&n,&k,&l,&c,&d,&p,&nl,&np)
	fmt.Println(min(min(k*l/nl , c*d), p/np )/n)
}


package main

import "fmt"

func Min(x... int) (r int) {
    r = x[0]
    for i := 1; i < len(x); i++ {
        if r > x[i] { r = x[i] }
    }
    return
}

func main() {
    var n,k,l,c,d,p,nl,np int
    fmt.Scan(&n,&k,&l,&c,&d,&p,&nl,&np)
    fmt.Println(Min((k*l)/nl,(c*d),p/np)/n)
}


package main

import "fmt"

func abs(a int) int{
	if a < 0{
		return -a
	} else{
		return a
	}
}

func min(a, b int) int{
	if a < b{
		return a
	} else{
		return b
	}
}

func main() {
	var n int
	fmt.Scanln(&n)
	if n%2 >0  {
		fmt.Println("0")
	} else{
		var ans int64 = 1
		for i :=0;i<n/2 ;i++  {
			ans <<= 1
		}
		fmt.Println(ans)
	}
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	// var a string
	var n int
	// var x float64
	// var s string
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n)

	if n == 1 {
		fmt.Println("0")
	} else {
		if n%2 == 0 {
			fmt.Println(int(math.Pow(2, float64(n/2))))
		} else {
			fmt.Println("0")
		}
	}

	// a := make([]int, n)

	// for i := 0; i < n; i++ {
	// 	fmt.Fscanf(scr, "%d", &a[i])
	// }
}


package main
import "fmt" //引入fmt库

func main() {
	//fmt.Println("Hello World!")
	//fmt.Println("Hello Worl2d!")

	var n uint;
	fmt.Scan(&n);

	if (n&1)==1 {
		fmt.Println(0);
	}else{
		fmt.Println(1<<(n/2))
	}

}


package main

import (
	"fmt"
	//"bufio"
	//"os"
	//"strconv"
	//"unicode"
	//"strings"
	//"math"
)

func min(a,b int)int {
	if a<b {
		return a
	} else {
		return b
	}
}

func main() {
	var a,b,c,d,l,r,m int
	fmt.Scan(&a,&b,&c,&d,&l,&r)
	m=min(a,min(b,min(c,d)))
	if m>=l && r>=m {
		fmt.Println(m-l)
	} else if m>=l && r<m {
		fmt.Println(r-l+1)
	} else {
		fmt.Println("0")
	}
}


// 68A
package main

import (
	"fmt"
	"sort"
)

func main() {
	var a, b int
	p := make([]int, 4)
	fmt.Scan(&p[0], &p[1], &p[2], &p[3], &a, &b)
	sort.Sort(sort.IntSlice(p))
	if p[0]-a <= 0 {
		fmt.Println(0)
	} else if p[0] <= b+1 {
		fmt.Println(p[0] - a)
	} else {
		fmt.Println(b - a + 1)
	}
}


// 62A-mic
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, x, y, res int
	fmt.Scan(&a, &b, &c, &d, &x, &y)
	for i := x; i <= y; i++ {
		if ((((i % a) % b) % c) % d) == i {
			res++
		}
	}
	fmt.Println(res)
}


package main

import "fmt"

func invr(row int) int {
	return 2 - row
}

func invc(col int) int {
	return 2 - col
}

func main() {
	var grid [3][3]rune
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			fmt.Scanf("%c", &grid[i][j])
		}
		fmt.Scanf("\n")
	}

	var possible = true
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			possible = possible && (grid[i][j] == grid[invr(i)][invc(j)])
		}
	}
	if possible {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import "os"
import "bufio"

func main(){
	matrix := make([]string, 3)
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	for i:=0; i<3; i++ {
		r.Scan()
		matrix[i] = r.Text()
	}
	for i:=0; i<3; i++ {
		for j:=0; j<3; j++ {
			if string(matrix[i][j]) != string(matrix[2-i][2-j]) {
				w.WriteString("NO\n")
				w.Flush()
				return
			}
		}
	}
	w.WriteString("YES\n")
	w.Flush()
}


package main

import (
    "fmt"
)

func main() {
    var G [3]string
    for i:=0; i<3; i++ {
        fmt.Scanln(&G[i])
    }
    if symmetric(G) {
        fmt.Println("YES")
    }else {
        fmt.Println("NO")
    }
}

func symmetric(G [3]string) bool {
    for i:=0; i<2; i++ {
        for j:=0; j<3; j++ {
            if G[i][j] != G[2-i][2-j] {
                return false
            }
        }
    }
    return true
}


package main

import "fmt"

func main() {
	var n,a,b int
	fmt.Scan(&n,&a,&b)
	a+=b
	for a<n{
	    a+=n
	}
	for a>n{
	    a-=n
	}
	fmt.Print(a)
}


package main

import "fmt"

func main() {
	var n, a, b, ans int
	fmt.Scanf("%d%d%d", &n, &a, &b)
	ans = (a+b)%n
	if ans <= 0 {
		ans += n
	}
	fmt.Println(ans)
}


package main

import (
    "fmt"
    )

func main() {
    var n, a, b int
    fmt.Scan(&n, &a, &b)
    fmt.Println(((a + b - 1) % n + n) % n + 1)
}


package main

/*
	To get the maximum xor sum for n > 1 numbers, basically we just need to
	find a single number which is complement of n in its binary form.

	For example if we have 10 (1010), we need to find 101 which is 5 then we
	got the maximum xor sum which is 1111 (15).

	Notice that this complement number of binary n will always appear since we
	are given selection of candy from 1..n. So as long as n > 1, then the maximum
	xor sum must be always in form of n binary but with all 0 changed to 1.

	So for example if we have 10 = 1010, then the maximum xor sum is 1111 = 15. This
	property yield true for all numbers in input set.

	For n = 1, we just need to return n.
*/

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n, k int64
	stdio := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdio, "%d %d", &n, &k)

	if k == 1 {
		fmt.Println(n)
		return
	}
	binStr := strings.Replace(strconv.FormatInt(n, 2), "0", "1", -1)
	num, _ := strconv.ParseInt(binStr, 2, 64)
	fmt.Println(num)
}


package main

import "fmt"

func main() {
	var n, m int64
	fmt.Scan(&n, &m)

	if m > 1 {
		pow := int64(1)
		for n >= pow {
			pow <<= 1
		}
		fmt.Println(pow - 1)
	} else {
		fmt.Println(n)
	}
}


package main

import (
	"fmt"
)

func main() {
	var n, k int64
	fmt.Scan(&n, &k)
	if k == 1 {
		fmt.Println(n)
		return
	}
	var max int64 = 1
	for max <= n {
		max <<= 1
	}
	fmt.Println(max - 1)
}


package main

import (
	"fmt"
)

func gcd(a, b int) int {
	for a != 0 {
		a, b = b%a, a
	}
	return b
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	x := a * d
	y := b * c
	if x > y {
		x, y = y, x
	}
	x = y - x
	g := gcd(x, y)
	fmt.Printf("%d/%d", x/g, y/g)
}


package main

import "fmt"

func gcd(a,b int) int { if b == 0 { return a } else { return gcd(b,a%b) } }

func main() {
    var a,b,c,d,p,q int
    fmt.Scan(&a,&b,&c,&d)
    a *= d
    c *= b
    if a > c {
        p = a-c
        q = a
    } else {
        p = c-a
        q = c
    }
    _gcd := gcd(p,q)
    p /= _gcd
    q /= _gcd
    fmt.Printf("%d/%d\n",p,q)
}


package main

import (
	"fmt"
	"os"
	"bufio"
)

func gcd(x, y int) int {
	if x == 0 {
		return y
	}
	return gcd(y % x, x)
}

func main() {
	var a, b, c, d int
	//f, _  := os.Open("in.txt")
	reader := bufio.NewReader(os.Stdin)
	for true {
		if _, err := fmt.Fscanf(reader, "%d %d %d %d\n", &a, &b, &c, &d); err != nil {
			break
		}
		k := gcd(c * b, a * d)
		k1 := c * b / k
		k2 := a * d / k
		if k1 > k2 {
			fmt.Printf("%d/%d\n", k1 - k2, k1)
		} else {
			fmt.Printf("%d/%d\n", k2 - k1, k2)
		}
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func nextWords(scanner *bufio.Scanner) []string {
	scanner.Scan()
	return strings.Fields(scanner.Text())
}

func nextNumbers(scanner *bufio.Scanner) []int {
	var numbers = make([]int, 0)
	line := nextWords(scanner)
	for i := range line {
		n, _ := strconv.Atoi(line[i])
		numbers = append(numbers, n)
	}
	return numbers
}

func nextInt(scanner *bufio.Scanner) int {
	number, _ := strconv.Atoi(nextLine(scanner))
	return number
}

func sumInputs(numbers []int) int {
	var sum int
	for i := range numbers {
		sum += numbers[i]
	}
	return sum
}

func nextLine(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}

func splitToIntegers(str string) []int {
	ar := strings.Split(str, "")
	res := make([]int, 0)

	for c := range ar {
		it, _ := strconv.Atoi(ar[c])
		res = append(res, it)
	}

	return res
}

func main() {

	sc := bufio.NewScanner(os.Stdin)

	t := nextInt(sc)

	for i := 0; i < t; i++ {
		entry := splitToIntegers(nextLine(sc))

		l := len(entry)
		d := entry[0]

		result := (d - 1)*10 + l * (l + 1) / 2

		fmt.Println(result)
	}

}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"os"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) {
		var x string
		Fscan(in, &x)
		d := int(x[0]&15)
		ans := 10*(d-1)
		for i := range x {
			ans+=i+1
		}
		Fprintln(out, ans)
		return
	}

	var t int
	Fscan(in, &t)
	for Case := 1; Case <= t; Case++ {
		solve(Case)
	}
}

func main() { run(os.Stdin, os.Stdout) }


package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func solve() {
	a := make([]string, 0)
	for i := 1; i <= 10000; i++ {
		num := strconv.Itoa(i)
		ok := true
		for j := 1; j < len(num); j++ {
			if num[j] != num[j-1] {
				ok = false
				break
			}
		}
		if ok {
			a = append(a, num)
		}
	}
	sort.Strings(a)
	t := readInt()

	for i := 0; i < t; i++ {
		x := strconv.Itoa(readInt())
		ans := 0
		for j := 0; j < len(a); j++ {
			ans += len(a[j])
			if a[j] == x {
				fmt.Println(ans)
				break
			}
		}
	}
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func min(a int64, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}


package main

import (
	"fmt"
)

func main() {
	for i := 0; i < 8; i++ {

		var line string
		fmt.Scanln(&line)

		if !(line == "WBWBWBWB" || line == "BWBWBWBW"){
			fmt.Println("NO")
			return
		}
	}

	fmt.Println("YES")
}


package main

import (
	"fmt"
)

func main() {
	for i := 0; i < 8; i++ {

		var line string
		fmt.Scanln(&line)

		first := line[0]
		second := line[1]
		for j := 0; j < 8; j++ {
			if (line[j] == first && j%2 == 1) ||
				(line[j] == second && j%2 == 0) {
				fmt.Println("NO")
				return
			}
		}
	}

	fmt.Println("YES")
}


package main

import (
	"fmt"
)

func main() {
	var s string
	n:=0
	for i:=0;i<8;i++ {
		fmt.Scan(&s)
		for j:=1;j<len(s);j++ {
			if s[j]==s[j-1] {
				n=1
			}
		}
	}
	if n==0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func I(i interface{}, delim string) error {
	_, err := fmt.Fscanf(r, "%v"+delim, i)
	return err
}

func O(o interface{}, delim string) {
	fmt.Fprintf(w, "%v"+delim, o)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.txt"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var c1 int
	for I(&c1, " ") == nil {
		solve(c1)
	}
}

func solve(c1 int) {
	var c2, c3, c4, c5 int
	I(&c2, " ")
	I(&c3, " ")
	I(&c4, " ")
	I(&c5, "\n")
	c := c1 + c2 + c3 + c4 + c5
	if c%5 == 0 && c != 0 {
		O(c/5, "\n")
	} else {
		O("-1", "\n")
	}
}


package main

import (
    "bufio"
    "os"
    "strconv"
)

var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
var writer *bufio.Writer = bufio.NewWriter(os.Stdout)

func ReadInt32() int {
    scanner.Scan()
    ans, _ := strconv.Atoi(scanner.Text())
    return ans
}

func ReadString() string {
    scanner.Scan()
    return scanner.Text()
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    c1 := ReadInt32()
    c2 := ReadInt32()
    c3 := ReadInt32()
    c4 := ReadInt32()
    c5 := ReadInt32()

    a := c1 + c2 + c3 + c4 + c5
    if a > 0 && a%5 == 0 {
        writer.WriteString(strconv.Itoa(a/5) + "\n")
    } else {
        writer.WriteString("-1\n")
    }
}


package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, e, s int
	fmt.Scanf("%d %d %d %d %d\n", &a, &b, &c, &d, &e)
	s = a + b + c + d + e
	if s == 0 || s%5 != 0 {
		fmt.Print(-1)
		return
	}
	fmt.Print(s / 5)
}


// 80A-mic
package main

import (
    "fmt"
)

func main() {
    var l, cou, n, m int
    a := make([]int, 60)
    for i := 2; i < 55; i++ {
        for k := 1; k <= i; k++ {
            if i%k == 0 {
                cou++
            }

        }
        if cou == 2 {
            a[l] = i
            l++
            cou = 0
        }
        cou = 0

    }
    fmt.Scan(&n, &m)
    for i := 0; i < 55; i++ {
        if a[i] == n && a[i+1] == m {
            fmt.Println("YES")
            return
        }
    }
    fmt.Println("NO")
}


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strings"
	"unicode"
)

func main() {
	n, m := read2i()
	if isNextPrime(n, m) {
		fmt.Fprintln(writer, "YES")
	} else {
		fmt.Fprintln(writer, "NO")
	}
	writer.Flush()
}

func isNextPrime(n, m int) bool {
	for i := n + 1; i < m; i++ {
		if isPrime(i) {
			return false
		}
	}
	return isPrime(m)
}

func isPrime(n int) bool {
	for x := 2; x*x <= n; x++ {
		if n%x == 0 {
			return false
		}
	}
	return n > 1
}

func withSameCase(word string) string {
	lowerCount := 0
	for _, letter := range word {
		if unicode.IsLower(letter) {
			lowerCount++
		}
	}
	if lowerCount*2 >= len(word) {
		return strings.ToLower(word)
	}
	return strings.ToUpper(word)
}

func solve(matrix [][]int) []string {
	n := 3
	state := make([][]byte, n)
	for i := range state {
		state[i] = make([]byte, n)
		for j := range matrix[i] {
			state[i][j] = byte(matrix[i][j])
			if i > 0 {
				state[i][j] += byte(matrix[i-1][j])
			}
			if i+1 < n {
				state[i][j] += byte(matrix[i+1][j])
			}
			if j > 0 {
				state[i][j] += byte(matrix[i][j-1])
			}
			if j+1 < n {
				state[i][j] += byte(matrix[i][j+1])
			}
			state[i][j] &= 1
			state[i][j] ^= 1
			state[i][j] += '0'
		}
	}
	res := make([]string, n)
	for i := range res {
		res[i] = string(state[i])
	}
	return res
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func max64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

var (
	reader = bufio.NewReaderSize(os.Stdin, 1<<13)
	writer = bufio.NewWriterSize(os.Stdout, 1<<13)
)

func readi() int {
	return int(readi64())
}

func read2i() (int, int) {
	return readi(), readi()
}

func read3i() (int, int, int) {
	return readi(), readi(), readi()
}

func read4i() (int, int, int, int) {
	return readi(), readi(), readi(), readi()
}

func readis(n int) []int {
	res := make([]int, n)
	for i := range res {
		res[i] = readi()
	}
	return res
}

func readi64() int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign, res := int64(1), int64(0)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func readi64s(n int) []int64 {
	res := make([]int64, n)
	for i := range res {
		res[i] = readi64()
	}
	return res
}

func readline() string {
	res := new(bytes.Buffer)
	for {
		line, isPrefix, err := reader.ReadLine()
		if err != nil {
			panic(err)
		}
		res.Write(line)
		if !isPrefix {
			break
		}
	}
	return res.String()
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}


package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	is_prime := make([]int, 51, 51)
	for i := 0; i < 51; i++ {
		is_prime[i] = 1
	}
	is_prime[1] = 0
	for i := 2; i <= 8; i++ {
		if is_prime[i] == 1 {
			for x := i + i; x < 51; x += i {
				is_prime[x] = 0
			}
		}
	}

	ans := false
	for i := n + 1; i < 51; i++ {
		if is_prime[i] == 1 {
			if i == m {
				ans = true
			}
			break
		}
	}

	if ans == true {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
	"fmt"
	"strconv"
)

func main() {
	var m, s int
	fmt.Scan(&m, &s)
	if 9*m < s || (s < 1 && m > 1) {
		fmt.Print("-1 -1")
		return
	}
	min := getMin(s, m)
	max := getMax(s, m)
	fmt.Print(min, " ", max)
}

func getMax(s, m int) string {
	var max string
	for s > 9 {
		max = max + "9"
		s -= 9
		m--
	}
	max = max + strconv.Itoa(s)
	m--
	for i := 0; i < m; i++ {
		max = max + "0"
	}
	return max
}

func getMin(s, m int) string {
	var min string
	for s > 9 {
		min = "9" + min
		s -= 9
		m--
	}
	if m == 1 {
		min = strconv.Itoa(s) + min
	} else {
		if s > 1 {
			min = strconv.Itoa(s-1) + min
			m--
		}
		for i := 0; i < m-1; i++ {
			min = "0" + min
		}
		min = "1" + min
	}
	return min
}


package main

import "fmt"

// https://codeforces.com/problemset/problem/489/C
// комментарии к решению
// Максимальное число всегда будет выглядеть как:
// 99..99Х00..00 , где Х - цифра
// а минимальное число будет выглядеть как:
// 100...0Х99..99 или Х99..99 , где Х - цифра
func taskSolution(m int, s int) string {
	if s > 9*m {
		return "-1 -1"
	} else if s == 0 && m != 1 {
		return "-1 -1"
	}

	ans := make([]byte, 2*m+1)
	last := 0
	for i := 0; i < m; i += 1 {
		switch {
		case s == 0:
			ans[m+i+1] = '0'
			ans[m-i-1] = '0'
		case s > 9:
			ans[m+i+1] = '9'
			ans[m-i-1] = '9'
			s -= 9
		default:
			last = m - i - 1
			ans[m+i+1] = byte(s) + '0'
			ans[m-i-1] = byte(s) + '0'
			s = 0
		}
	}
	if last > 0 {
		ans[0] = '1'
		ans[last] -= byte(1)
	}
	// put space between two numbers
	ans[m] = ' '
	return string(ans)
}

func main() {
	var m, s int
	if _, err := fmt.Scan(&m, &s); err != nil {
		panic(err)
	}

	fmt.Println(taskSolution(m, s))
}


// http://codeforces.com/contest/489/problem/C
package main

import (
	"fmt"
	"bufio"
	"os"
)

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

const (
	MOD = 1e9 + 7
)

type (

)

func min(a, b int) int {
	if a < b {
		return a
	}

	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}

	return b
}

func main () {
	var (
		n, s int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)

	fmt.Fscanln(input, &n, &s)

	if n * 9 < s {
		fmt.Println(-1, -1)
		return
	}

	if s == 0 {
		if n == 1 {
			fmt.Println(0, 0)
			return
		}
		fmt.Println(-1, -1)
		return
	}

	ans := make([]int, n + 1)

	sum := s
	for i := 1; i <= n; i++ {
		for j := 0; j < 10; j++ {
			if i == 1 && j == 0 {
				continue
			}
			if sum - j >= 0 && i < n {
				if sum - j <= (n - i)*9 {
					ans[i] = j
					sum -= j
					break
				}
			} else {
				ans[i] = sum
			}

		}
	}

	for i := 1; i <= n; i++ {
		fmt.Print(ans[i])
	}

	fmt.Print(" ")

	sum = s
	for i := 1; i <= n; i++ {
		for j := 9; j >= 0; j-- {
			if i == 1 && j == 0 {
				continue
			}
			if i < n {
				if sum - j >= 0 && sum - j <= (n - i)*9 {
					ans[i] = j
					sum -= j
					break
				}
			} else {
				ans[i] = sum
			}

		}
	}

	for i := 1; i <= n; i++ {
		fmt.Print(ans[i])
	}
}


package main

import (
  "fmt"
)

func main() {
  var s string
  jumpval :=0
  current := 1
  vowels := "AEIOUY"
  fmt.Scanf("%s", &s)
  for i:=0; i < len(s); i++ {
    for j:=0; j < len(vowels); j++ {
      if vowels[j] == s[i]{
        if jumpval < current {
          jumpval = current
        }
        current = 0
        break
      }
    }
    current++
  }
  if current > jumpval {
    jumpval = current
  }
  fmt.Println(jumpval)
}


package main

import (
	"strconv"
	"bufio"
	"os"
	"fmt"
)

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	old := -1
	mx := 0
	for i, v := range S {
		switch v {
		case 'A', 'E', 'I', 'O', 'U', 'Y':{
			mx = max(mx, i - old)
			old = i
		}
		}
	}
	mx = max(mx, len(S) - old)

	fmt.Println(mx)
}

func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r:rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf) + 1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

import "fmt"

func main() {
    var s string
    fmt.Scan(&s)
    min, cur := 0, 0
    for _, c := range s {
        if c == 'A' || c == 'E' || c == 'I' || c == 'O' || c == 'U' || c == 'Y' {
            if min < cur+1 {
                min = cur+1
            }
            cur = 0
        } else {
            cur++
        }
    }
    if min < cur+1 {
        min = cur+1
    }
    fmt.Print(min)
}


package main

import (
	"fmt"
	"math/big"
)

func main() {
	n := 0
	fmt.Scanf("%d\n", &n)
	crush := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &crush[i])
		crush[i]--
	}

	sizes := make([]int, 0)
	visited := make([]bool, n)
	for first := 0; first < n; first++ {
		if !visited[first] {
			visited[first] = true
			size := 1
			x := crush[first]
			for !visited[x] {
				visited[x] = true
				size++
				x = crush[x]
			}
			if x != first {
				fmt.Println(-1)
				return
			}
			sizes = append(sizes, size)
		}
	}

	ans := big.NewInt(1)
	for _, size := range sizes {
		var k *big.Int
		if size%2 == 0 {
			k = big.NewInt(int64(size / 2))
		} else {
			k = big.NewInt(int64(size))
		}
		g := new(big.Int).GCD(nil, nil, ans, k)
		ans.Div(ans, g)
		ans.Mul(ans, k)
	}
	fmt.Println(ans)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1<<13)
	writer := bufio.NewWriterSize(os.Stdout, 1<<13)
	n := ReadInt(reader)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ReadInt(reader) - 1
	}
	fmt.Fprintln(writer, solve(a))
	writer.Flush()
}

func solve(a []int) int64 {
	n := len(a)
	res := int64(0)
	reached := make([]bool, n)
	for i := 0; i < n; i++ {
		if !reached[i] {
			k := i
			count := int64(0)
			for !reached[k] {
				reached[k] = true
				k = a[k]
				count++
			}
			if k != i {
				return -1
			}
			if count == 0 {
				continue
			}
			if count%2 == 0 {
				count /= 2
			}
			if res == 0 {
				res = count
			} else {
				res = lcm(res, count)
			}
		}
	}
	return res
}

func gcd(a, b int64) int64 {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int64) int64 {
	g := gcd(a, b)
	return (a / g) * b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func ReadInt(reader *bufio.Reader) int {
	return int(ReadInt64(reader))
}

func ReadInt64(reader *bufio.Reader) int64 {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	sign := int64(1)
	if b == '-' {
		sign *= -1
		b, err = reader.ReadByte()
	}
	res := int64(0)
	for isValid(b, err) {
		res = res*10 + int64(b-'0')
		b, err = reader.ReadByte()
	}
	return res * sign
}

func isValid(b byte, err error) bool {
	return err == nil && (('0' <= b && b <= '9') || b == '-')
}


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"runtime"
	"strings"
)

func main() {
	b, _ := ioutil.ReadAll(os.Stdin)
	if len(b) == 0 {
		test()
	} else {
		solve(bytes.NewReader(b), os.Stdout)
	}
}

func solve(r io.Reader, w io.Writer) {
	var n int
	fmt.Fscanln(r, &n)

	cs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &cs[i])
	}

	fmt.Fprintln(w, f(cs))
}

func f(cs []int) int {
	gs := graphs(cs)

	if len(gs) == 0 {
		return -1
	}

	for i, g := range gs {
		if g%2 == 0 {
			gs[i] = g / 2
		}
	}

	if len(gs) == 1 {
		return gs[0]
	}

	return lcmm(gs...)
}

func graphs(cs []int) []int {
	seen := make(map[int]bool, len(cs))

	var ls []int

	for j, c := range cs {
		i := j + 1

		if seen[i] {
			continue
		}

		if cs[i-1] == i {
			seen[i] = true
			seen[cs[i-1]] = true
			ls = append(ls, 1)
			continue
		}

		l := 2

		for ; ; l++ {
			seen[c] = true
			next := cs[c-1]
			if next == i {
				break
			}
			if seen[next] {
				return nil
			}
			c = next
		}
		seen[i] = true
		ls = append(ls, l)
	}
	return ls
}

func gcd(a, b int) int {
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}

func lcmm(xs ...int) int {
	r := 1
	for _, x := range xs {
		r = lcm(r, x)
	}
	return r
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: `
4
2 3 1 4
`,
			want: `3`,
		},
		{
			in: `
4
4 4 4 4
`,
			want: `-1`,
		},
		{
			in: `
4
2 1 4 3
`,
			want: `1`,
		},
		{
			in: `
5
2 3 1 5 4
`,
			want: `3`,
		},
		{
			in: `
7
2 3 1 5 6 7 4
`,
			want: `6`,
		},
		{
			in: `
5
2 4 3 1 2
`,
			want: `-1`,
		},
		{
			in: `
10
8 10 4 3 2 1 9 6 5 7
`,
			want: `15`,
		},
	}
	for i, tt := range tests {
		fmt.Printf("=== TEST %d\n", i)
		buf := new(bytes.Buffer)
		solve(strings.NewReader(chomp(tt.in)), buf)
		if got, want := chomp(buf.String()), chomp(tt.want); got != want {
			fmt.Printf("%d: got %v, want %v\n", i, got, want)
		}
	}
}

func chomp(s string) string {
	return strings.Trim(s, "\n")
}

func assert(b bool) {
	if !b {
		_, file, line, ok := runtime.Caller(1)
		if ok {
			f, _ := os.Open(file)
			defer f.Close()
			s := bufio.NewScanner(f)
			lnum := 0
			for s.Scan() {
				lnum++
				if lnum == line {
					wd, _ := os.Getwd()
					fname, _ := filepath.Rel(wd, file)
					fmt.Printf("assertion fails: %s:%d: %v\n", fname, line, s.Text())
					break
				}
			}
		}
	}
}

func pow(a, b int) int {
	r := 1
	for i := 0; i < b; i++ {
		r *= a
	}
	return r
}


package main

import (
	"fmt"
	"math"
)

func scanInput() (int64, int64, int64) {
	var x, y, m int64
	fmt.Scanf("%d %d %d\n", &x, &y, &m)
	return x, y, m
}

func fibo(x, y, m int64) int64 {
	var n int64
	if x >= m || y >= m {
		return int64(0)
	}
	if n = 0; x < m && y < m && (x+y) <= y && (x+y) <= x {
		n = -1
		return n
	} else if math.Signbit(float64(x)) != math.Signbit(float64(y)) {
		if x > y {
			x, y = y, x
		}
		n = (-x) / y
		x = -((-x) % y)
	}

	for x < m && y < m {
		t := x + y
		if x < y {
			x = t
		} else {
			y = t
		}
		n++
	}
	return n
}

func main() {
	x, y, m := scanInput()
	n := fibo(x, y, m)
	fmt.Printf("%d\n", n)
}


// 317A
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d, e int64
	e = 0
	fmt.Scan(&a, &b, &d)
	if a < b {
		c = a
		a = b
		b = c
	}
	if a >= d {
		fmt.Print("0")
		return
	}
	if a <= 0 {
		fmt.Print("-1")
		return
	}
	if b < 0 {
		e = 1 - b/a
		b += a * e
	}
	for a < d {
		c = a
		a += b
		b = c
		e++
	}
	fmt.Println(e)
}


// 317A-mic_rizal
package main

import (
    "fmt"
)

func main() {
    var x, y, m, RESULT, tmp int64
    fmt.Scan(&x, &y, &m)
    if x >= m || y >= m {
        fmt.Println("0")
    } else {
        if x <= 0 && y <= 0 {
            fmt.Println("-1")
        } else {
            if x < y {
                tmp = x
                x = y
                y = tmp
            }

            if y < 0 {
                n := (-y)/x + 1
                RESULT += n
                y += x * n
            }
            for x < m {
                y += x
                tmp = x
                x = y
                y = tmp
                RESULT += 1
            }
            fmt.Println(RESULT)
        }
    }
}


package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) (_b bool) {
		var n, m, k int
		Fscan(in, &n, &m, &k)
		 mx :=  0
		if m&1 == 0 {
			mx = n * m / 2
			base := 0
			if n&1 == 0 {

			} else {
				base = m / 2
			}

			if k < base {
				return false
			}
			if (k-base)&1 > 0 {
				return false
			}
			return true
		} else { // m&1==1 && n&1==0
			mx = n*m/2 - n/2
			if k > mx {
				return false
			}
			if k&1 > 0 {
				return false
			}

			return true
		}
	}
	var T int
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		if solve(Case) {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }


package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	writer  = bufio.NewWriter(os.Stdout)
	scanner = bufio.NewScanner(os.Stdin)
)

func init() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 4096), 1e9)
}

func printf(f string, a ...interface{}) {
	fmt.Fprintf(writer, f, a...)
}

func _int() int {
	s := _string()
	i := 0
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int(r - '0')
	}
	return i
}

func _int64() int64 {
	s := _string()
	i := int64(0)
	if s[0] == '-' {
		for _, r := range s[1:] {
			i *= 10
			i -= int64(r - '0')
		}
		return i
	}
	for _, r := range s {
		i *= 10
		i += int64(r - '0')
	}
	return i
}

func _string() string {
	if !scanner.Scan() {
		panic(scanner.Err())
	}
	return scanner.Text()
}

func main() {
	defer writer.Flush()
	for t := _int(); t > 0; t-- {
		n := _int()
		m := _int()
		k := _int()
		ans := sol(n, m, k)
		if ans {
			printf("YES\n")
		} else {
			printf("NO\n")
		}
	}
}

func sol(n, m, k int) bool {
	if m&1 == 0 && n&1 == 0 {
		return k&1 == 0
	}
	if m&1 == 1 && n&1 == 0 {
		if k*2 > (m-1)*n { // cannot fit horizontally
			return false
		}
		return k&1 == 0
	}
	if n&1 == 1 && m&1 == 0 {
		if k*2 >= m {
			return sol(n-1, m, k-m/2)
		}
		return false
	}
	// shouldn't reach here
	return false
}


package main
import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	solve := func(Case int) (_b bool) {
		var n, m, k int
		Fscan(in, &n, &m, &k)
		 mx :=  0
		if m&1 == 0 {
			mx = n * m / 2
			base := 0
			if n&1 == 0 {

			} else {
				base = m / 2
			}

			if k < base {
				return false
			}
			if (k-base)&1 > 0 {
				return false
			}
			return true
		} else { // m&1==1 && n&1==0
			mx = n*m/2 - n/2
			if k > mx {
				return false
			}
			if k&1 > 0 {
				return false
			}

			return true
		}
	}
	var T int
	Fscan(in, &T)
	for Case := 1; Case <= T; Case++ {
		if solve(Case) {
			Fprintln(out, "YES")
		} else {
			Fprintln(out, "NO")
		}
	}
	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("有未读入的数据：\n" + _s)
	}
}

func main() { run(os.Stdin, os.Stdout) }


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func solve() {
	n := readInt()
	m := readInt()
	k := readInt64()
	x := readInt()
	y := readInt()

	v := make([][]int64, n)
	for i := 0; i < n; i++ {
		v[i] = make([]int64, m)
	}
	if n == 1 {
		size := m
		mul := k / int64(size)
		k = k % int64(size)
		if mul > 0 {
			for j := 0; j < m; j++ {
				v[0][j] = mul
			}
		}
	} else {
		size := (n + n - 2) * m
		mul := k / int64(size)
		k = k % int64(size)
		if mul > 0 {
			for i := 1; i < n-1; i++ {
				for j := 0; j < m; j++ {
					v[i][j] = 2 * mul
				}
			}
			for j := 0; j < m; j++ {
				v[0][j] = mul
			}
			for j := 0; j < m; j++ {
				v[n-1][j] = mul
			}
		}
	}
	for i := 0; i < n && k > 0; i++ {
		for j := 0; j < m && k > 0; j++ {
			v[i][j]++
			k--
		}
	}
	for i := n - 2; i >= 0 && k > 0; i-- {
		for j := 0; j < m && k > 0; j++ {
			v[i][j]++
			k--
		}
	}
	// for i := 0; i < n; i++ {
	// 	fmt.Printf("v[i] = %+v\n", v[i])
	// }
	minValue := int64(math.MaxInt64)
	maxValue := int64(math.MinInt64)
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			value := v[i][j]
			if value < minValue {
				minValue = value
			}
			if value > maxValue {
				maxValue = value
			}
		}
	}
	fmt.Printf("%d %d %d", maxValue, minValue, v[x-1][y-1])
}

var scanner *bufio.Scanner

func main() {
	scanner = bufio.NewScanner(os.Stdin)
	const MaxTokenLength = 1024 * 1024
	scanner.Buffer(make([]byte, 0, MaxTokenLength), MaxTokenLength)
	scanner.Split(bufio.ScanWords)
	solve()
}

// IO

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	val, _ := strconv.Atoi(readString())
	return val
}

func readInt64() int64 {
	v, _ := strconv.ParseInt(readString(), 10, 64)
	return v
}

func readIntArray(sz int) []int {
	a := make([]int, sz)
	for i := 0; i < sz; i++ {
		a[i] = readInt()
	}
	return a
}

func readInt64Array(n int) []int64 {
	res := make([]int64, n)
	for i := 0; i < n; i++ {
		res[i] = readInt64()
	}
	return res
}


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
)

func main() {
	io := FastIO{reader: bufio.NewReader(os.Stdin), writer: bufio.NewWriter(os.Stdout)}

	N := io.NextLong()
	M := io.NextLong()
	K := io.NextLong()
	X := io.NextLong()
	Y := io.NextLong()

	max := Max(GetAt(N, M, 1, 1, K), GetAt(N, M, 2, 1, K), GetAt(N, M, N - 1, 1, K))
	min := GetAt(N, M, N, M, K)
	sergey := GetAt(N, M, X, Y, K)

	io.Printf("%d %d %d\n", max, min, sergey)

	io.FlushOutput()
}

func GetAt(N, M, R, C, K int64) int64 {
	R--
	C--

	if R < 0 || R >= N || C < 0 || C >= M {
		return 0
	}

	var cnt int64
	if N == 1 {
		cnt = K / M
		if C < K % M {
			cnt++
		}
	} else {
		T := M * (N + N - 2)
		P := K / T
		if R == 0 || R == N - 1 {
			cnt = P
		} else {
			cnt = P * 2
		}
		rem := K % T
		// fmt.Printf("(%d, %d), T = %d, P = %d, cnt = %d, rem = %d\n", R, C, T, P, cnt, rem)
		// fmt.Printf("  idx1 = %d, idx2 = %d\n", (M * R) + C, M * ((2 * N) - R - 2) + C)
		if R < N - 1 && (M * R) + C < rem {
			cnt++
		}
		if M * ((2 * N) - R - 2) + C < rem {
			cnt++
		}
	}
	// fmt.Printf("  cnt = %d\n", cnt)
	return cnt
}

func Min(args ...int64) int64 {
	min := args[0]
	for i := 1; i < len(args); i++ {
		if (args[i] < min) {
			min = args[i]
		}
	}
	return min
}

func Max(args ...int64) int64 {
	max := args[0]
	for i := 1; i < len(args); i++ {
		if (args[i] > max) {
			max = args[i]
		}
	}
	return max
}

type FastIO struct {
	reader *bufio.Reader
	writer *bufio.Writer
}

func (io *FastIO) NextChar() byte {
	c, _ := io.reader.ReadByte()
	return c
}

func (io *FastIO) NextInt() int {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := 1
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := 0
	for !IsSpaceChar(c) {
		res = (res * 10) + int(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextLong() int64 {
	c := io.NextChar()
	for IsSpaceChar(c) {
		c = io.NextChar()
	}
	sgn := int64(1)
	if c == '-' {
		sgn = -1
		c = io.NextChar()
	}
	res := int64(0)
	for !IsSpaceChar(c) {
		res = (res * 10) + int64(c - '0')
		c = io.NextChar()
	}
	return sgn * res
}

func (io *FastIO) NextIntArray(size int) []int {
	return io.NextIntArrayOffset(size, 0)
}

func (io *FastIO) NextIntArrayOffset(size, offset int) []int {
	arr := make([]int, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextInt()
	}
	return arr
}

func (io *FastIO) NextLongArray(size int) []int64 {
	return io.NextLongArrayOffset(size, 0)
}

func (io *FastIO) NextLongArrayOffset(size, offset int) []int64 {
	arr := make([]int64, size + offset)
	for i := 0; i < size; i++ {
		arr[i + offset] = io.NextLong()
	}
	return arr
}

func (io *FastIO) NextString() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsSpaceChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) NextLine() string {
	c := io.NextChar()
	for (IsSpaceChar(c)) {
		c = io.NextChar()
	}
	var sb bytes.Buffer
	for !IsLineBreakChar(c) {
		sb.WriteByte(c)
		c = io.NextChar()
	}
	return sb.String()
}

func (io *FastIO) Printf(format string, args ...interface{}) {
	io.writer.WriteString(fmt.Sprintf(format, args...))
}

func (io *FastIO) FlushOutput() {
	io.writer.Flush()
}

func IsSpaceChar(c byte) bool {
	switch c {
	case 0, '\t', '\n', '\r', ' ':
		return true
	default:
		return false
	}
}

func IsLineBreakChar(c byte) bool {
	switch c {
		case 0, '\n', '\r':
			return true
		default:
			return false
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	do()
}

func do() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	s.Scan()
	m, _ := strconv.Atoi(s.Text())
	s.Scan()
	k, _ := strconv.ParseInt(s.Text(), 10, 64)
	s.Scan()
	x, _ := strconv.Atoi(s.Text())
	s.Scan()
	y, _ := strconv.Atoi(s.Text())

	min := minAsk(n, m, k)
	max := maxAsk(n, m, k)
	cnt := count(n, m, x, y, k)
	fmt.Printf("%v %v %v\n", max, min, cnt)
}

func minAsk(n, m int, k int64) int64 {
	if n <= 2 {
		return k / int64(n*m)
	}

	t := int64(2*n*m - 2*m)
	th := int64(n * m)
	d := k / t
	r := k % t

	if r < th {
		return d
	}
	return d + 1
}

func maxAsk(n, m int, k int64) int64 {
	if n <= 2 {
		d := k / int64(n*m)
		r := k % int64(n*m)
		if r > 0 {
			return d + 1
		}
		return d
	}

	t := int64(2*n*m - 2*m)
	th := int64(n * m)
	d := k / t
	r := k % t

	if d > 0 && r <= int64(m) {
		return d * 2
	} else if r <= th {
		return d*2 + 1
	}

	return d*2 + 2
}

func count(n, m, x, y int, k int64) int64 {
	if n <= 2 {
		d := k / int64(n*m)
		r := k % int64(n*m)
		if r >= int64((x-1)*m+y) {
			return d + 1
		}
		return d
	}

	t := int64(2*n*m - 2*m)
	th := int64(n * m)
	d := k / t
	r := k % t

	if x == 1 {
		if r >= int64(y) {
			return d + 1
		}
		return d
	} else if x == n {
		if r-int64((n-1)*m) >= int64(y) {
			return d + 1
		}
		return d
	} else {
		if r < int64((x-1)*m+y) {
			return d * 2
		} else if r >= int64((x-1)*m+y) && r < th+int64((n-x-1)*m+y) {
			return d*2 + 1
		}
	}

	return d*2 + 2
}


package main

import (
	"bufio"
	"errors"
	"fmt"
	"os"
	"strconv"
	"strings"
)

const N = 11

type Deck struct {
	cards []int
}

func (d *Deck) addCard(c int) {
	d.cards = append(d.cards, c)
}

func (d *Deck) isLosing() bool {
	return len(d.cards) == 0
}

func (d *Deck) hash() int64 {
	var h int64
	for _, c := range d.cards {
		h = N*h + int64(c+1)
	}
	return h
}

func oneRound(d1, d2 *Deck) {
	var c1, c2 int
	c1, d1.cards = d1.cards[0], d1.cards[1:]
	c2, d2.cards = d2.cards[0], d2.cards[1:]
	d := d1
	if c1 < c2 {
		c1, c2 = c2, c1
		d = d2
	}
	d.addCard(c2)
	d.addCard(c1)
}

func makeKey(d1, d2 Deck) string {
	return strconv.FormatInt(d1.hash(), N) + "#" + strconv.FormatInt(d2.hash(), N)
}

func main() {
	nextInt()
	var d1, d2 Deck
	k1 := nextInt()
	for i := 0; i < k1; i++ {
		d1.addCard(nextInt() - 1)
	}
	k2 := nextInt()
	for i := 0; i < k2; i++ {
		d2.addCard(nextInt() - 1)
	}
	was := make(map[string]struct{})
	for rounds := 0; ; rounds++ {
		if d1.isLosing() {
			fmt.Println(rounds, 2)
			return
		}
		if d2.isLosing() {
			fmt.Println(rounds, 1)
			return
		}
		key := makeKey(d1, d2)
		if _, ok := was[key]; ok {
			break
		}
		was[key] = struct{}{}
		oneRound(&d1, &d2)
	}
	fmt.Println(-1)
}

func init() {
	// maybe defer writer.Flush() in main

	lineScanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)

	/*
		inputFile, err := os.Open("a.in")
		if err != nil {
			panic(err)
		}
		outputFile, err := os.Create("a.out")
		if err != nil {
			panic(err)
		}
		lineScanner = bufio.NewScanner(inputFile)
		writer = bufio.NewWriter(outputFile)
	*/

	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}

var lineScanner *bufio.Scanner
var wordScanner *bufio.Scanner

var writer *bufio.Writer

func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

func nextWord() string {
	for !wordScanner.Scan() {
		if err := wordScanner.Err(); err != nil {
			panic(err)
		}
		line, err := nextLine()
		if err != nil {
			return ""
		}
		wordScanner = bufio.NewScanner(strings.NewReader(line))
		wordScanner.Split(bufio.ScanWords)
	}
	return wordScanner.Text()
}

func nextInt() int {
	res, err := strconv.Atoi(nextWord())
	if err != nil {
		panic(err)
	}
	return res
}

func nextInt64() int64 {
	res, err := strconv.ParseInt(nextWord(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func nextFloat64() float64 {
	res, err := strconv.ParseFloat(nextWord(), 64)
	if err != nil {
		panic(err)
	}
	return res
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func I(i ...interface{}) error {
	_, err := fmt.Fscan(r, i...)
	return err
}

func O(o ...interface{}) {
	fmt.Fprint(w, o...)
}

var (
	r *bufio.Reader
	w *bufio.Writer
)

func init() {
	if f, err := os.Open("in.goC"); err == nil {
		r = bufio.NewReader(f)
	} else {
		r = bufio.NewReader(os.Stdin)
	}
	w = bufio.NewWriter(os.Stdout)
}

func main() {
	defer w.Flush()
	var n int
	for I(&n) == nil {
		solve(n)
	}
}

type node struct {
	child *node
	value int
}

func solve(n int) {
	var k int
	I(&k)
	a := make([]int, k)
	for i := range a {
		I(&a[i])
	}
	I(&k)
	b := make([]int, k)
	for i := range b {
		I(&b[i])
	}
	var i int
	for i = 0; i < 1000 && len(a) > 0 && len(b) > 0; i++ {
		if a[0] > b[0] {
			a = append(a, b[0])
			a = append(a, a[0])
		} else {
			b = append(b, a[0])
			b = append(b, b[0])
		}
		a = a[1:]
		b = b[1:]
	}
	if len(b) == 0 {
		O(i, " 1\n")
	} else if len(a) == 0 {
		O(i, " 2\n")
	} else {
		O("-1\n")
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	var n int
	if _, err := fmt.Scanf("%d\n", &n); err != nil {
		return
	}

	c := make([][]int, 2)
	c[0] = make([]int, n)
	c[1] = make([]int, n)
	k := make([]int, 2)
	pos := make([]int, 2)

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	steps := 0
	winner := -1
	loop := false

	situations := make(map[string]int)

	for j := 0; j < 2; j++ {
		scanner.Scan()
		var ek error
		k[j], ek = strconv.Atoi(scanner.Text())
		if ek != nil {
			return
		}
		for i := 0; i < k[j] && scanner.Scan(); i++ {
			a, err := strconv.Atoi(scanner.Text())
			if err != nil {
				return
			}
			c[j][i] = a
		}
	}

	situations[situation_to_code(c, k, pos, n)] = 1

	for true {
		f := make([]int, 2)
		f[0] = c[0][pos[0]]
		f[1] = c[1][pos[1]]

		for i := 0; i < 2; i++ {
			c[i][pos[i]] = 0
			pos[i]++
			if pos[i] >= n {
				pos[i] = pos[i] % n
			}
		}

		ic := -1
		if f[0] > f[1] {
			ic = 0
		} else { // not equal guaranteed
			ic = 1
		}

		ip := pos[ic] + k[ic] - 1
		if ip >= n {
			ip = ip % n
		}
		c[ic][ip] = f[(ic+1)%2]
		ip++
		if ip >= n {
			ip = ip % n
		}
		c[ic][ip] = f[ic]

		k[ic]++
		k[(ic+1)%2]--

		steps++

		curr_sit := situation_to_code(c, k, pos, n)
		if situations[curr_sit] > 0 {
			loop = true
			break
		} else {
			situations[curr_sit]++
		}
		if k[(ic+1)%2] == 0 {
			winner = ic + 1
			break
		}
	}

	if loop {
		fmt.Println(-1)
	} else {
		fmt.Println(steps, winner)
	}
}

func situation_to_code(c [][]int, k, p []int, n int) string {
	res := make([]string, n+2)
	res[0], res[1] = strconv.Itoa(k[0]), strconv.Itoa(k[1])
	rp := 2
	for i := 0; i < 2; i++ {
		for j := 0; j < k[i]; j++ {
			pos := (p[0] + j) % n
			res[rp] = strconv.Itoa(c[i][pos])
			rp++
		}
	}
	return strings.Join(res, ",")
}


package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int

func main() {
	fmt.Fscan(reader, &n)
	m := int(math.Log2(float64((n + 4) / 5)))
	n -= int(math.Exp2(float64(m))-1) * 5
	m = int(math.Exp2(float64(m)))
	switch (n + m - 1) / m {
	case 0:
		fmt.Println("Howard")
	case 1:
		fmt.Println("Sheldon")
	case 2:
		fmt.Println("Leonard")
	case 3:
		fmt.Println("Penny")
	case 4:
		fmt.Println("Rajesh")
	case 5:
		fmt.Println("Howard")
	}
}


package main

import (
	"fmt"
	"math"
)

func main() {
	people := []string{"Sheldon", "Leonard", "Penny", "Rajesh", "Howard"}
	var k int
	fmt.Scan(&k)

	if k <= len(people) {
		fmt.Print(people[k-1])
		return
	}

	round := int(math.Ceil(math.Log2(float64(k)/float64(len(people)) + 1)))
	left := k - 5*(int(math.Pow(2, float64(round-1)))-1)
	pos := (left - 1) / int(math.Pow(2, float64(round-1)))

	fmt.Print(people[pos])
}


package main

import "fmt"

func main() {
    var n int
    ans := [...]string{"Sheldon","Leonard","Penny","Rajesh","Howard"}
    fmt.Scan(&n)
    a := 1
    for n > (5*a) {
        n -= (5*a)
        a *= 2
    }
    fmt.Println(ans[(n-1)/a])
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

var reader = bufio.NewReader(os.Stdin)
var writer = bufio.NewWriter(os.Stdout)

func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func getLine2Ints(n int) []int {
	ans := make([]int, n)
	for i := 0; i < n; i++ {
		scanf("%d ", &ans[i])
	}
	scanf("%d\n", &ans[n-1])
	return ans
}

var debug = false

func see(a interface{}) {
	if debug {
		printf("DEBUG:%v\n", a)
	}
}

func d(p, a, b byte) (bool, byte) {
	return p >= a && p <= b, p - a
}

func main() {
	defer writer.Flush()

	n := getLine2Int()
	if n <= 0 {
		return
	}
	s := getLine()
	var c [26]bool
	for i := 0; i < len(s); i++ {
		if ok, t := d(s[i], 'a', 'z'); ok {
			c[t] = ok
		}
		if ok, t := d(s[i], 'A', 'Z'); ok {
			c[t] = ok
		}
	}
	ok := true
	for i := 0; ok && i < len(c); i++ {
		if !c[i] {
			ok = false
		}
	}

	if ok {
		printf("YES\n")
	} else {
		printf("NO\n")
	}
}


package main

import "fmt"
import "strings"

func main() {
	var n int
	var s string
	m := make(map[rune]bool)
	fmt.Scanf("%d\n", &n)
	fmt.Scanf("%s\n", &s)
	for _, v := range strings.ToLower(s) {
		m[v] = true
	}
	if len(m) == 26 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	var n int
	fmt.Scanf("%d \n", &n)
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')

	if n < 26 {
		fmt.Print("NO")
		return
	}

	for i := 0; i < 26; i++ {
		if !strings.ContainsRune(text, int32(65+i)) && !strings.ContainsRune(text, int32(97+i)) {
			fmt.Print("NO")
			return
		}
	}
	fmt.Print("YES")
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func solve(mat []int, t1, t2, n, b, k int) int {
	for b < n {
		if mat[b] == 1 {
			t1--
		} else {
			t2--
		}
		b += k
	}
	ans := t1 - t2
	if ans < 0 {
		ans = 0 - ans
	}
	return ans
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, k int
	fmt.Fscanf(buf, "%d %d\n", &n, &k)
	mat := make([]int, n+1)
	var t1 int = 0
	var t2 int = 0
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
		if mat[i] == 1 {
			t1++
		} else {
			t2++
		}
	}
	max := -1
	for b := 0; b < k; b++ {
		tmp := solve(mat, t1, t2, n, b, k)
		if max == -1 || max < tmp {
			max = tmp
		}
	}
	fmt.Printf("%d\n", max)
}


package main

import (
	"fmt"
	"math"
)

var ns [200]int

func main() {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &ns[i])
	}
	var allE, allS int
	for idx := 0; idx < n; idx++ {
		if ns[idx] > 0 {
			allE++
		} else {
			allS++
		}
	}
	maxDist := float64(-1)
	for b := 0; b < n; b++ {
		currE := float64(allE)
		currS := float64(allS)
		for i := -100; i < 100; i++ {
			c := b + i*k
			if c >= 0 && c < n {
				if ns[c] > 0 {
					currE--
				} else {
					currS--
				}
			}
		}
		maxDist = math.Max(maxDist, math.Abs(currE-currS))
	}
	fmt.Printf("%0.f\n", maxDist)
}


package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

type CaseInput struct {
	K int64
	Tabs []int64
}

func readCaseInput(scanner *bufio.Scanner) CaseInput {
	size := readInt64(scanner)
	k := readInt64(scanner)
	tabs := make([]int64, size)
	for i := range tabs {
		tabs[i] = readInt64(scanner)
	}
	return CaseInput{k, tabs}
}

type CaseOutput struct {
	MaxDiff int64
}

func writeCaseOutput(writer *bufio.Writer, out CaseOutput) {
	writef(writer, "%d\n", abs64(out.MaxDiff))
}

func solveCase(in CaseInput) CaseOutput {
	diffs := make([]int64, in.K)
	diffsTotal := int64(0)
	for i, t := range in.Tabs {
		diffs[int64(i) % in.K] += t
		diffsTotal += t
	}

	maxDiff := abs64(diffsTotal - diffs[0])
	for b := int64(1); b < in.K; b++ {
		maxDiff = max64(abs64(diffsTotal - diffs[b]), maxDiff)
	}
	return CaseOutput{maxDiff}
}

func solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {
	writeCaseOutput(writer, solveCase(readCaseInput(scanner)))
}

func main() {
	var scanner *bufio.Scanner
	if len(os.Args) > 1 {
		reader, err := os.Open(os.Args[1])
		if err != nil {
			panic(err)
		}
		defer reader.Close()
		scanner = bufio.NewScanner(reader)
	} else {
		scanner = bufio.NewScanner(os.Stdin)
	}
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 0, 1024*1024), 1024*1024)

	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	solveSequential(scanner, writer)
}

func readInt64(sc *bufio.Scanner) int64 {
	if !sc.Scan() {
		panic("failed to scan next token")
	}

	res, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func writef(writer *bufio.Writer, formatStr string, values ...interface{}) {
	out := fmt.Sprintf(formatStr, values...)
	_, err := writer.WriteString(out)
	if err != nil {
		panic(err)
	}
}

func max64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}


package main

import "bufio"
import "os"
import "fmt"
import "math"

func Read(s *bufio.Reader) string {
    line, _ := s.ReadString('\n')
    return line
}

func Write(s *bufio.Writer, a ...interface{}) {
    fmt.Fprintln(s, a...)
    s.Flush()
}

func is_simple(n int64) bool {
    var result bool = true

    if math.Mod(float64(n), 2) == 0 {
        return false
    }

    end := int64(math.Pow(float64(n), 0.5)) + 1
    var i int64
    for i = 3; i <= end; i += 2 {
        if math.Mod(float64(n), float64(i)) == 0 {
            result = false
            break
        }
    }

    return result
}

func main() {
    reader := bufio.NewReader(os.Stdin)

    var n int64
    fmt.Sscanln(Read(reader), &n)

    var result int64 = n

    if !is_simple(n) {
        result = 1

        if math.Mod(float64(n), 2) == 0 {
            result *= 2

            for math.Mod(float64(n), 2) == 0 {
                n = n / 2
            }
        }

        var i int64
        var end int64 = int64(math.Pow(float64(n), 0.5)) + 1
        for i = 3; i <= end; i += 2 {
            if math.Mod(float64(n), float64(i)) == 0 {
                result *= i
                for math.Mod(float64(n), float64(i)) == 0 {
                    n = n / i
                }
                end = int64(math.Pow(float64(n), 0.5)) + 1
            }
        }

        result *= n
    }

    writer := bufio.NewWriter(os.Stdout)
    Write(writer, result)
}


package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int64

	fmt.Fscanln(reader, &n)

	var cnt, i int64 = 1, 2

	for i*i <= n {
		if n%i == 0 {
			cnt *= i
		}
		for n%i == 0 {
			n /= i
		}
		i++
	}

	fmt.Println(cnt * n)
}