package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	koutsu := make(map[string]int)
	shuntsu := make(map[string][]int)
	scanner.Scan()
	text := scanner.Text()
	tiles := strings.Split(text, " ")
	for _, s := range tiles {
		if _, ok := koutsu[s]; !ok {
			koutsu[s] = 1
		} else {
			koutsu[s]++
		}
		char := strings.Split(s, "")
		suit := char[1]
		digit, _ := strconv.Atoi(char[0])
		digit = digit - 1
		if _, ok := shuntsu[suit]; !ok {
			arr := make([]int, 9)
			arr[digit] = 1
			shuntsu[suit] = arr
		} else {
			shuntsu[suit][digit] = 1
		}
	}

	minKou := 2
	for _, v := range koutsu {
		if 3 - v < minKou {
			minKou = 3 - v
		}
		if minKou == 0 {
			fmt.Println(minKou)
			return
		}
	}
	minShun := 2
	for _, arr := range shuntsu {
		count := 0
		for _, v := range arr {
			if v == 1 {
				count++
			} else if v == 0 {
				if 3 - count < minShun {
					minShun = 3 - count
				}
				count = 0
			}
		}
		if 3 - count < minShun {
			minShun = 3 - count
		}
		if minShun == 0 {
			fmt.Println(minShun)
			return
		}
	}
	if minKou < minShun {
		fmt.Println(minKou)
	} else {
		fmt.Println(minShun)
	}
}


package main

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

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 max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func consec(arr []int) int {

	ans := 0

	for i := 0; i < len(arr); i++ {
		cur := 1
		last := arr[i]
		for j := i + 1; j < len(arr); j++ {
			if arr[j] == last+1 {
				last = last + 1
				cur++
			} else {
				ans = max(ans, cur)
				break
			}
		}
		ans = max(ans, cur)
	}
	return ans
}

func same(arr []int) int {

	ans := 0

	for i := 0; i < len(arr); i++ {
		cur := 1
		last := arr[i]
		for j := i + 1; j < len(arr); j++ {
			if arr[j] == last {
				cur++
			} else {
				ans = max(ans, cur)
				break
			}
		}
		ans = max(ans, cur)
	}
	return ans
}

func main() {
	defer writer.Flush()
	var a, b, c string

	s := []int{}
	m := []int{}
	p := []int{}

	scanf("%s %s %s\n", &a, &b, &c)

	if a[1] == byte('s') {
		cur := int(a[0] - byte('0'))
		s = append(s, cur)
	}
	if a[1] == byte('m') {
		cur := int(a[0] - byte('0'))
		m = append(m, cur)
	}
	if a[1] == byte('p') {
		cur := int(a[0] - byte('0'))
		p = append(p, cur)
	}

	if b[1] == byte('s') {
		cur := int(b[0] - byte('0'))
		s = append(s, cur)
	}
	if b[1] == byte('m') {
		cur := int(b[0] - byte('0'))
		m = append(m, cur)
	}
	if b[1] == byte('p') {
		cur := int(b[0] - byte('0'))
		p = append(p, cur)
	}

	if c[1] == byte('s') {
		cur := int(c[0] - byte('0'))
		s = append(s, cur)
	}
	if c[1] == byte('m') {
		cur := int(c[0] - byte('0'))
		m = append(m, cur)
	}
	if c[1] == byte('p') {
		cur := int(c[0] - byte('0'))
		p = append(p, cur)
	}

	sort.Ints(s)
	sort.Ints(p)
	sort.Ints(m)

	// fmt.Println(s, p, m)

	// fmt.Println(consec(p))

	if same(s) == 3 || consec(s) == 3 || same(p) == 3 || consec(p) == 3 || same(m) == 3 || consec(m) == 3 {
		printf("0")
		return
	}

	if same(s) == 2 || consec(s) == 2 || same(p) == 2 || consec(p) == 2 || same(m) == 2 || consec(m) == 2 {
		printf("1")
		return
	}

	if len(s) == 2 {
		s = []int{s[0], s[0] + 1, s[1]}
	} else if len(s) == 3 {
		s = []int{s[0], s[0] + 1, s[1], s[1] + 1, s[2]}
	}
	if len(m) == 2 {
		m = []int{m[0], m[0] + 1, m[1]}
	} else if len(m) == 3 {
		m = []int{m[0], m[0] + 1, m[1], m[1] + 1, m[2]}
	}
	if len(p) == 2 {
		p = []int{p[0], p[0] + 1, p[1]}
	} else if len(p) == 3 {
		p = []int{p[0], p[0] + 1, p[1], p[1] + 1, p[2]}
	}

	if same(s) >= 2 || consec(s) >= 2 || same(p) >= 2 || consec(p) >= 2 || same(m) >= 2 || consec(m) >= 2 {
		printf("1")
		return
	}

	printf("2")

}


package main

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

func main() {
	sc := NewScanner()
	A := make([]string, 3)
	for i := 0; i < 3; i++ {
		S := sc.Next()
		A[i] = string(S[1]) + string(S[0])
	}
	sort.Strings(A)
	//fmt.Printf("%+v\n", A)
	if A[0] == A[1] && A[1] == A[2] {
		fmt.Println(0)
		return
	}
	if A[0] == A[1] || A[1] == A[2] {
		fmt.Println(1)
		return
	}

	if A[0][0] == A[1][0] && A[1][0] == A[2][0] {
		if A[0][1]+1 == A[1][1] && A[1][1]+1 == A[2][1] {
			fmt.Println(0)
			return
		}

		if A[0][1]+1 == A[1][1] || A[1][1]+1 == A[2][1] {
			fmt.Println(1)
			return
		}

	}
	if A[0][0] == A[1][0] {
		if A[0][1]+1 == A[1][1] {
			fmt.Println(1)
			return
		}
	}
	if A[1][0] == A[2][0] {
		if A[1][1]+1 == A[2][1] {
			fmt.Println(1)
			return
		}
	}

	fmt.Println(2)

}

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) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 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"
	"math"
)

func countDivisor(a, b int) int {
	q := a - b
	ret := 0
	sqrtQ := int(math.Sqrt(float64(q)))
	for i := 1; i < sqrtQ; i++ {
		if q%i != 0 || q/i < b {
			continue
		}
		ret++
		if i <= b {
			continue
		}
		ret++
	}
	if sqrtQ > b && sqrtQ*sqrtQ == q {
		ret++
	}
	return ret
}

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)

	if a < b || (a != b && a-b <= b) {
		fmt.Println(0)
	} else if a == b {
		fmt.Println("infinity")
	} else {
		fmt.Println(countDivisor(a, b))
	}
}


package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var a, b, c int
	if Scan(&a, &b); a == b {
		Print("infinity")
		return
	}
	a -= b
	for d := 1; d*d <= a; d++ {
		if a%d == 0 {
			if d >= b {
				c++
			}
			if d*d < a && a/d >= b {
				c++
			}
		}
	}
	Print(c)
}


package main

import "fmt"

func main() {
	var a, b, f, k int64
	fmt.Scan(&a, &b, &f, &k)
	start := true
	fue := b
	stops := 0
	for i := 0; i < int(k); i++ {
		dist := f
		if !start {
			dist = a - f
		}
		if fue < dist {
			fmt.Println(-1)
			return
		}
		if fue < a || fue < a+(a-dist) && i+1 != int(k) {
			fue = b - (a - dist)
			stops++
		} else {
			fue -= a
		}
		if fue < 0 {
			fmt.Println(-1)
		}
		start = !start
	}
	fmt.Println(stops)
}


package main

import "fmt"

func main() {
	var a, b, f, k int
	fmt.Scanf("%d", &a)
	fmt.Scanf("%d", &b)
	fmt.Scanf("%d", &f)
	fmt.Scanf("%d", &k)

	//fmt.Printf("%v %v %v %v\n", a, b, f, k)

	if (f > b) {
		fmt.Printf("-1")
		return
	}

	if ((k > 1) && (2*(a-f) > b)) {
		fmt.Printf("-1")
		return
	}

	if ((k > 2) && (2*f > b)) {
		fmt.Printf("-1")
		return
	}

	totalCount := 0
	b_current := b
	k0 := 0
	for {
		//forward
		b_current -= f
		if (k0 != k-1) {
			if (((b_current - 2*(a-f)) < 0) || (b_current == 0)) {
				b_current = b
				totalCount++
			}
		} else {
			if (((b_current - (a-f)) < 0) || (b_current == 0)) {
				b_current = b
				totalCount++
			}
		}
		k0++
		if (k0 == k) {
			fmt.Printf("%v", totalCount)
			return
		}
		b_current -= (a-f)
		//backward
		b_current -= (a-f)
		if (k0 != k-1) {
			if ((b_current == 0) || ((b_current - 2*f) < 0)) {
				b_current = b
				totalCount++
			}
		} else {
			if ((b_current == 0) || ((b_current - f) < 0)) {
				b_current = b
				totalCount++
			}
		}
		k0++
		if (k0 == k) {
			fmt.Printf("%v", totalCount)
			return
		}
		b_current -= f
	}
}


package main

import "fmt"

func main() {
	var a, b, f, k int
	fmt.Scan(&a, &b, &f, &k)
	curFuel := b
	refuelsNeeded := 0
	isInA := false
	for i := k; i > 0; i-- {
		var fuelNeeded int
		if isInA {
			curFuel -= a - f
			if i == 1 {
				fuelNeeded = f
			} else {
				fuelNeeded = 2 * f
			}
			if curFuel < fuelNeeded {
				curFuel = b
				refuelsNeeded++
			}
			if curFuel < fuelNeeded {
				fmt.Println("-1")
				return
			}
			curFuel -= f
			if curFuel < 0 {
				fmt.Println("-1")
				return
			}
		} else {
			curFuel -= f
			if i == 1 {
				fuelNeeded = a - f
			} else {
				fuelNeeded = 2 * (a - f)
			}
			if curFuel < fuelNeeded {
				curFuel = b
				refuelsNeeded++
			}
			if curFuel < fuelNeeded {
				fmt.Println("-1")
				return
			}
			curFuel -= a - f
			if curFuel < 0 {
				fmt.Println("-1")
				return
			}
		}
		isInA = !isInA
	}
	fmt.Printf("%d\n", refuelsNeeded)
}


package main

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

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

	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())

	scanner.Scan()
	m, _ := strconv.Atoi(scanner.Text())

	a := make([]int, n)
	l := make([]int, m)

	i := 0
	for scanner.Scan() {
		l[i], _ = strconv.Atoi(scanner.Text())
		l[i]--
		i++
	}

	mm := map[int]int{}
	for i := 0; i < m-1; i++ {
		a[l[i]] = (l[i+1] - l[i]) % n
		if a[l[i]] <= 0 {
			a[l[i]] += n
		}
		if j, ok := mm[a[l[i]]]; ok && j != l[i] {
			fmt.Println(-1)
			return
		}
		mm[a[l[i]]] = l[i]
	}

	// fill in zeroes
	for i := 0; i < n; i++ {
		if a[i] != 0 {
			continue
		}
		for j := 1; j <= n; j++ {
			if _, ok := mm[j]; !ok {
				mm[j] = i
				a[i] = j
				break
			}
		}
	}

	for i := 0; i < n; i++ {
		fmt.Printf("%d ", a[i])
	}
	fmt.Println()
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1034B(in io.Reader, out io.Writer) {
	var n, m int64
	Fscan(in, &n, &m)
	ans := n * m
	n %= 6
	m %= 6
	if n == 0 || m == 0 {
		Fprint(out, ans)
		return
	}
	mat := [][]int64{
		{0, 0, 0, 2, 4},
		{0, 0, 4, 8, 10},
		{0, 4, 8, 12, 14},
		{2, 8, 12, 16, 20},
		{4, 10, 14, 20, 24},
	}
	Fprint(out, ans-n*m+mat[n-1][m-1])
}

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


package main

import (
    "fmt"
)

func main() {
    var a, b, c;
    fmt.Scan(&a, &b, &c);
    base := a;
    if (base > b - 1) {
        base = b - 1;
    }
    if (base > c - 2) {
        base = c - 2;
    }
    fmt.Println(3 * base + 3);
}


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%5 != 0 {
		fmt.Print(-1)
		return
	}
	fmt.Print(s / 5)
}


package main

import (
	"fmt"
)

func main() {
	sum := 0
	for i := 0; i < 5; i++ {
		var b int
		fmt.Scan(&b)
		sum += b
	}
	if sum%5 == 0 {
		fmt.Println(sum / 5)
	} else {
		fmt.Println(-1)
	}
}


package main

import (
	"fmt"
)

func main() {
	var x int
	for i := 0; i < 5; i++ {
		var y int
		fmt.Scan(&y)
		x += y
	}
	if x%5 > 0 {
		fmt.Println(-1)
	} else {
		fmt.Println(x / 5)
	}
}


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 a, b, c, d, e int64
    scanf("%d %d %d %d %d\n", &a, &b, &c, &d, &e)
    total := a + b + c + d + e
    if total % 5 == 0 {
        printf("%d", total / 5)
    } else {
        printf("%d", -1)
    }
}


package main

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

func scanner() string {
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		return scanner.Text()
	}
	return ""
}

func main() {
	var input []string
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		input = append(input, scanner.Text())
	}
	// input = append(input, scanner())
	// input = append(input, scanner())
	// input = append(input, scanner())
	// input = append(input, scanner())
	// input = append(input, scanner())

	a1, _ := strconv.Atoi(input[0])
	a2, _ := strconv.Atoi(input[1])
	k1, _ := strconv.Atoi(input[2])
	k2, _ := strconv.Atoi(input[3])
	n, _ := strconv.Atoi(input[4])

	if a1*k1 > a2*k2 {
		k1, k2, a1, a2 = k2, k1, a2, a1
	}
	var min, max int

	if a1*k1 >= n {
		max = n / k1
	} else {
		max = a1
		max += (n - a1*k1) / k2
	}

	var minCard int

	if k1 > 1 {
		minCard = a1 * (k1 - 1)
	}
	if k2 > 1 {
		minCard += a2 * (k2 - 1)
	}

	if minCard >= n {
		min = 0
	} else {
		min = n - minCard
	}

	fmt.Printf("%v %v", min, max)
}


package main

import (
	"fmt"
)

func main() {
	var a1, a2, k1, k2, n int

	// scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Scanln(&a1)
	fmt.Scanln(&a2)
	fmt.Scanln(&k1)
	fmt.Scanln(&k2)
	fmt.Scanln(&n)

	min := n - (((k1 - 1) * a1) + ((k2 - 1) * a2))

	if min <= 0 {
		min = 0
	} else if min >= a1+a2 {
		min = a1 + a2
	}

	max := 0
	if k1 < k2 {
		max = n / k1

		if max > a1 {
			max = a1
		} else if max < 1 {
			max = 0
		}
		n -= k1 * max

		x := n / k2
		if x > a2 {
			x = a2
		} else if x < 1 {
			x = 0
		}
		max += x

	} else {
		max = n / k2

		if max > a2 {
			max = a2
		} else if max < 1 {
			max = 0
		}
		n -= k2 * max

		x := n / k1
		if x > a1 {
			max = a1
		} else if x < 1 {
			max = 0
		}
		max += x
	}

	fmt.Println(min, max)

}


package main

import "fmt"

func vowel_l(r rune) bool {
    if r == 'a' || r == 'e' || r == 'i' || r == 'u' {
        return true
    }
    return false
}

func odd(r rune) bool {
    if r == '1' || r == '3' || r == '5' || r == '7' || r == '9' {
        return true
    }
    return false
}

func main() {
    var s string
    fmt.Scan(&s)
    var cnt int
    for _, r := range s {
        if vowel_l(r) || odd(r) {
            cnt++
        }
    }
    fmt.Print(cnt)
}


package main

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

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	count := 0
	for _, v := range S {
		switch v {
		case 'a', 'i', 'u', 'e', 'o', '0', '2', '4', '6', '8':
			count++

		}
	}
	fmt.Println(count)

}

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"
	"strings"
)

func main() {
	var s string
	fmt.Scanln(&s)
	var ans int
	for i := 0; i < len(s); i++ {
		if s[i] >= '0' && s[i] <= '9' {
			if (s[i]-'0')%2 == 0 {
				ans++
			}
		} else {
			if strings.IndexByte("aeiou", s[i]) != -1 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


// Codeforces 676 B
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
	"strconv"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
    var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
    for i:=0; i<len(ss); i++ {
        a[i], err = strconv.Atoi(ss[i])
        if err != nil {
            fmt.Println("n atoi failure", err)
            panic(err)
        }
    }
    return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
    a := make([]int, n)
    s, err := in.ReadString('\n')
    if err != nil {
        fmt.Println("read failure", err)
        panic(err)
    }
    ss := strings.Split(strings.Trim(s, " \n\r"), " ")
    for j:=0; j<n; j++ {
        aa,err := strconv.Atoi(ss[j])
        if err != nil {
            fmt.Println("aa conv failed", err)
            panic(err)
        }
        a[j] = aa
    }
    return a
}

var n int
var t int
var res int

func readData() {
 	in = bufio.NewReader(os.Stdin)
	// reading n
    n,t,_,_,_ = readFive()
    //fmt.Printf("n,t = %d %d\n", n,t)
}

func solve() {
    aa := make([]float64, n+1)
    an := make([]float64, n+1)
    aa[0] = float64(t)
    countFull := 0
    for i:=0; i<n+1; i++ {
        // clear an
        for j:=0; j<n; j++ {
            an[j] = 0.0;
        }
        for j:=0; j<n; j++ {
            if aa[j] >= 0.999999999999 {
                countFull ++
                v := (aa[j] - 1.0)/2.0
                //fmt.Printf("a,v= %f %f\n",aa[j], v)
                an[j] += v
                an[j+1] += v
            }
        }
        // copy an -> a
        //fmt.Println(i)
        for j:=0; j<n; j++ {
            //fmt.Printf("%f ", an[j])
            aa[j] = an[j]
        }
    }
    res = countFull
}

func main() {
 	readData()

    solve()

    // print aqnswer
    fmt.Println(res)
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var first, second string
	fmt.Scan(&first)
	fmt.Scan(&second)

	bytes1 := []byte(strings.ToLower(first))
	bytes2 := []byte(strings.ToLower(second))

	var result int
	for i := 0; i < len(bytes1); i++ {
		if bytes1[i] > bytes2[i] {
			result = 1
		} else if bytes1[i] < bytes2[i] {
			result = -1
		}
	}
	fmt.Println(result)
}

// https://codeforces.com/problemset/problem/112/A


package main

import (
	"fmt"
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
)

func run(s1, s2 string) int {
	s1 = strings.ToLower(s1)
	s2 = strings.ToLower(s2)
	if s1 < s2 {
		return -1
	} else if s1 > s2 {
		return 1
	}
	return 0
}

func Test(t *testing.T) {
	assert.Equal(t, run("aaaa", "aaaA"), 0)
	assert.Equal(t, run("abs", "Abz"), -1)
	assert.Equal(t, run("abcdefg", "AbCdEfF"), 1)
}

func main() {
	var s1, s2 string
	fmt.Scan(&s1, &s2)
	fmt.Println(run(s1, s2))
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, min int

	fmt.Scanln(&n, &m)
	a := make([]int, m)

	for i := 0; i < m; i++ {
		fmt.Scanf("%d", &a[i])
	}
	sort.Sort(sort.IntSlice(a))
	for i := 0; i < m-n; i++ {
		if i == 0 {
			min = a[i+n-1] - a[i]
		} else {
			if min > a[i+n-1]-a[i] {
				min = a[i+n-1] - a[i]
			}
		}
	}
	fmt.Println(min)

}


package main

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	_ = nextInt()
	s := next()
	var outsideWords []string

	for i := strings.Index(s, "("); i >= 0; i = strings.Index(s, "(") {
		j := strings.Index(s, ")")
		outsideWords = append(outsideWords, splitWords(s[i+1:j], '_')...)
		s = s[:i] + s[j+1:]
	}

	println(maxLength(splitWords(s, '_')), len(outsideWords))

}

func splitWords(s string, c rune) []string {
	return strings.FieldsFunc(s, func(c rune) bool { return c == '_' })
}

func maxLength(s []string) int {
	l := 0

	for i := range s {
		if len(s[i]) > l {
			l = len(s[i])
		}
	}

	return l
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }


package main;

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

func groups(line string) ([]string, []string) {
    outside, inside := make([]string, 0, 10), make([]string, 0, 10)
    parts := strings.FieldsFunc(line, func(c rune) bool {
        return c=='(' || c==')'
    })
    out := line[0]!='('
    for _, p := range parts {
        if out {
            outside = append(outside, strings.Split(p, "_") ...)
        } else {
            inside = append(inside, strings.Split(p, "_") ...)
        }
        out = !out
    }

    return outside, inside

}

func main() {
    inp := bufio.NewReader(os.Stdin)
    scanner := bufio.NewScanner(inp)

    scanner.Scan() // number
    scanner.Scan()
    outside, inside := groups(scanner.Text())

    fmt.Fprintf(os.Stderr, "%v - %v \n", outside, inside)

    longestOutside := 0
    for _, w := range outside {
        if len(w) > longestOutside {
            longestOutside = len(w)
        }
    }

    inParenthesis := 0
    for _, w := range inside {
        if len(w) > 0 {
            inParenthesis++
        }
    }

    fmt.Println(longestOutside, inParenthesis)
}


package main

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

func main() {
	fsc := NewFastScanner()
	n := fsc.NextInt()
	text := fsc.Next()
	var flag, maxLength, inLength, outLength, count int
	for i := 0; i < n; i++ {
		if text[i] == '(' {
			if maxLength < outLength {
				maxLength = outLength
			}
			outLength = 0
			flag = 1
		} else if text[i] == ')' {
			if inLength != 0 {
				count++
			}
			inLength = 0
			flag = 0
		} else if text[i] == '_' {
			if inLength != 0 {
				count++
			}
			inLength = 0
			if outLength != 0 {
				if maxLength < outLength {
					maxLength = outLength
				}
			}
			outLength = 0
		} else if flag == 0 {
			outLength++
		} else if flag == 1 {
			inLength++
		}
	}

	fmt.Println(maxLength, count)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 2028)
	return &FastScanner{r: rdr}
}

func (s *FastScanner) 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 *FastScanner) NextInt() int {
	val, err := strconv.Atoi(s.Next())
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) NextInt64() int64 {
	val, err := strconv.ParseInt(s.Next(), 10, 64)
	if err != nil {
		panic(err)
	}
	return val
}
func (s *FastScanner) Pre() {
	if s.p >= len(s.buf) {
		s.ReadLine()
		s.p = 0
	}
}

func (s *FastScanner) ReadLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, err := s.r.ReadLine()
		if err != nil {
			panic(err.Error())
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

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

type TupleInt struct {
	first  int
	second int
	third  int
}

func main() {
	in := NewScanner()
	_ = in.NextInt()
	S := in.NextLine()
	inside := false
	last := 0
	mx := 0
	count := 0
	comma := false

	for i, s := range S {
		if s == '(' {
			inside = true
			comma = true
		} else if s == ')' {
			inside = false
			comma = true
			last = i + 1

		} else if s == '_' {
			comma = true
		} else {
			if comma {
				if inside {
					count++
				}
				comma = false
			}
		}
		if comma {
			if !inside {
				mx = max(mx, i - last)
			}
			last = i + 1
		}

	}
	fmt.Println(mx, count)
}
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); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

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

	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 (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt64()
	var ret int64 = 1

	for i := int64(2); n > 1; i++ {
		if n%i == 0 {
			ret *= i

			for n%i == 0 {
				n /= i
			}
		}
	}

	println(ret)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, 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 main() {
    reader := bufio.NewReader(os.Stdin)

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

    a := make([]int, 0)

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

    for i := 3; i <= n; i++ {
        for int(math.Mod(float64(n), float64(i))) == 0 {
            n = n / i
            a = append(a, i)
        }
    }

    var result int = a[0]
    for i := 1; i < len(a); i++ {
        if a[i] != a[i - 1] {
            result *= a[i]
        }
    }

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


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 main() {
    reader := bufio.NewReader(os.Stdin)

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

    a := make([]int, 0)

    if n == 1 {
        a = append(a, 1)
    }

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

    for i := 3; i <= n; i++ {
        for int(math.Mod(float64(n), float64(i))) == 0 {
            n = n / i
            a = append(a, i)
        }
    }

    var result int = a[0]
    for i := 1; i < len(a); i++ {
        if a[i] != a[i - 1] {
            result *= a[i]
        }
    }

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


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 main() {
    reader := bufio.NewReader(os.Stdin)

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

    a := make([]int, 0)

    if n < 2 {
        a = append(a, n)
    }

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

    for i := 3; i <= n; i++ {
        for int(math.Mod(float64(n), float64(i))) == 0 {
            n = n / i
            a = append(a, i)
        }
    }

    var result int = a[0]
    for i := 1; i < len(a); i++ {
        if a[i] != a[i - 1] {
            result *= a[i]
        }
    }

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


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 main() {
    reader := bufio.NewReader(os.Stdin)

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

    a := make([]int64, 0)

    if n < 2 {
        a = append(a, n)
    }

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

    var i int64
    for i = 3; i <= n; i++ {
        for int64(math.Mod(float64(n), float64(i))) == 0 {
            n = n / i
            a = append(a, i)
        }
    }

    var result int64 = a[0]
    for i = 1; i < int64(len(a)); i++ {
        if a[i] != a[i - 1] {
            result *= a[i]
        }
    }

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


package main

import (
	"bufio"
	"container/list"
	"fmt"
	"os"
	//	"strconv"
)

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

func ReadInt32() int64 {
	scanner.Scan()
	return toInt(scanner.Bytes())
}

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

func main() {
	//:	fmt.Print64(strconv.IntSize)
	scanner.Split(bufio.ScanWords)
	l := list.New()

	//var n int64
	m := ReadInt32()
	var r int64 = 1
	var i int64

	for i = 2; i <= m && m > 1; i++ {
		isPrime := true
		for e := l.Front(); e != nil; e = e.Next() {
			var n int64

			n = e.Value.(int64)
			if i%n == 0 {
				isPrime = false
				break
			}
			if n*n > i {
				break
			}

		}
		if isPrime {
			l.PushBack(i)
			if m%i == 0 {
				r = r * i
			}
			for ; m%i == 0; m = m / i {
			}

		}
	}
	fmt.Print(r)

}


package main

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

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

    fmt.Fscanln(reader, &n)

    var cnt, i int64 = 1, 2

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

    fmt.Println(cnt * n)
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := n + 1; i < 9001; i++ {
		if isBeautiful(i) {
			fmt.Print(i)
			return
		}
	}
}

func isBeautiful(n int) bool {
	var a [10]int
	for n > 0 {
		i := n % 10
		a[i]++
		n = n / 10
	}
	for i := 0; i < 10; i++ {
		if a[i] >= 2 {
			return false
		}
	}
	return true
}


package main

import (
	"fmt"
)

func difnomb(k int) bool {
	var a, b, c, d int
	f := true
	a = int(k / 1000)
	b = int(k/100) % 10
	c = int(k/10) % 10
	d = k % 10
	if a == b || a == c || b == c || b == d || c == d {
		f = false
	}
	return f
}

func main() {
	var n int
	fmt.Scan(&n)
	for true {
		n++
		if difnomb(n) {
			break
		}
	}
	fmt.Println(n)
}


package main

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

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

	var w, m int
	Fscan(in, &w, &m)
	if w <= 3 {
		Fprint(out, "YES")
		return
	}
	coef := []int{}
	for ; m > 0; m /= w {
		c := m % w
		if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
		}
		coef = append(coef, c)
	}
	n := len(coef)
	for i := 0; i < n; i++ {
		c := coef[i]
		if c == -1 {
			for j := i + 1; j < n; j++ {
				coef[j]++
				if coef[j] != 0 {
					break
				}
			}
		} else if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
			i--
		}
	}
	Fprint(out, "YES")
}

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


package main

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

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

	var w, m int
	Fscan(in, &w, &m)
	if w <= 3 {
		Fprint(out, "YES")
		return
	}
	coef := []int{}
	for ; m > 0; m /= w {
		c := m % w
		if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
		}
		coef = append(coef, c)
	}
	n := len(coef)
	for i := 0; i < n; {
		c := coef[i]
		if c == -1 {
			for j := i + 1; j < n; j++ {
				coef[j]++
				if coef[j] != 0 {
					break
				}
			}
			i++
		} else if c > 1 {
			if c < w-1 {
				Fprint(out, "NO")
				return
			}
			c = -1
		}
	}
	Fprint(out, "YES")
}

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


package main

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

type Cell int

const (
	EmptyCell Cell = iota
	PigCell
	WolfCell
)

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	n := nextInt(s)
	m := nextInt(s)
	gs := make([][]Cell, n)
	wolves := make([]Wolf, 0, n)
	for i := 0; i < len(gs); i++ {
		gs[i] = make([]Cell, m)
		s.Scan()
		row := s.Text()
		for j := 0; j < m; j++ {
			switch row[j] {
			case 'P':
				gs[i][j] = PigCell
			case 'W':
				gs[i][j] = WolfCell
				wolves = append(wolves, Wolf{i, j})
			default:
				gs[i][j] = EmptyCell
			}
		}
	}

	fmt.Println(solve(gs, wolves, len(wolves)-1))
}

func solve(gs [][]Cell, wolves []Wolf, k int) int {
	if k < 0 {
		return 0
	}

	i := wolves[k].i
	j := wolves[k].j

	a, b, c, d, e := 0, 0, 0, 0, 0
	if ix(gs, i-1, j) == PigCell {
		hs := copyGrid(gs)
		hs[i-1][j] = EmptyCell
		hs[i][j] = EmptyCell
		a = 1 + solve(hs, wolves, k-1)
	}
	if ix(gs, i+1, j) == PigCell {
		hs := copyGrid(gs)
		hs[i+1][j] = EmptyCell
		hs[i][j] = EmptyCell
		b = 1 + solve(hs, wolves, k-1)
	}
	if ix(gs, i, j+1) == PigCell {
		hs := copyGrid(gs)
		hs[i][j+1] = EmptyCell
		hs[i][j] = EmptyCell
		c = 1 + solve(hs, wolves, k-1)
	}
	if ix(gs, i, j-1) == PigCell {
		hs := copyGrid(gs)
		hs[i][j-1] = EmptyCell
		hs[i][j] = EmptyCell
		d = 1 + solve(hs, wolves, k-1)
	}
	e = solve(gs, wolves, k-1)

	return maximum(a, b, c, d, e)

	//max := 0
	//for i := 0; i < len(gs); i++ {
	//	for j := 0; j < len(gs[i]); j++ {
	//		if gs[i][j] == WolfCell {
	//			a, b, c, d := 0, 0, 0, 0
	//			if ix(gs, i-1, j) == PigCell {
	//				hs := copyGrid(gs)
	//				hs[i-1][j] = EmptyCell
	//				hs[i][j] = EmptyCell
	//				a = 1 + solve(hs)
	//			}
	//			if ix(gs, i+1, j) == PigCell {
	//				hs := copyGrid(gs)
	//				hs[i+1][j] = EmptyCell
	//				hs[i][j] = EmptyCell
	//				b = 1 + solve(hs)
	//			}
	//			if ix(gs, i, j+1) == PigCell {
	//				hs := copyGrid(gs)
	//				hs[i][j+1] = EmptyCell
	//				hs[i][j] = EmptyCell
	//				c = 1 + solve(hs)
	//			}
	//			if ix(gs, i, j-1) == PigCell {
	//				hs := copyGrid(gs)
	//				hs[i][j-1] = EmptyCell
	//				hs[i][j] = EmptyCell
	//				d = 1 + solve(hs)
	//			}
	//			if m := maximum(a, b, c, d); m > max {
	//				max = m
	//			}
	//		}
	//	}
	//}
	//return max
}

type Wolf struct {
	i, j int
}

type Pair struct {
	x, y int
}

func maximum(xs ...int) int {
	max := 0
	for i := 0; i < len(xs); i++ {
		if xs[i] > max {
			max = xs[i]
		}
	}
	return max
}

func ix(gs [][]Cell, i, j int) Cell {
	if i < 0 || j < 0 || i > len(gs)-1 || j > len(gs[i])-1 {
		return EmptyCell
	}

	return gs[i][j]
}

func copyGrid(gs [][]Cell) [][]Cell {
	cs := make([][]Cell, len(gs))
	for i := 0; i < len(gs); i++ {
		cs[i] = make([]Cell, len(gs[i]))
		copy(cs[i], gs[i])
	}
	return cs
}

func copyAppend(ys []int, xs ...int) []int {
	ns := make([]int, len(ys), len(ys)+len(xs))
	copy(ns, ys)
	return append(ns, xs...)
}

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

func toLower(x byte) byte {
	return x + ('a' - 'A')
}

func isUpper(x byte) bool {
	return x >= 'A' && x <= 'Z'
}

func initArray(n, x int) []int {
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		xs[i] = x
	}
	return xs
}

func nextInt(s *bufio.Scanner) (n int) {
	s.Scan()
	n, _ = strconv.Atoi(s.Text())
	return
}


                                        b = max[i][j-1] + 1
                                }
                                if i < n - 1 && board[i+1][j] == 'P' {
                                        c = max[i+1][j] + 1
                                }
                                if j < m - 1 && board[i][j+1] == 'P' {
                                        d = max[i][j+1] + 1
                                }
                                var s = []int {a, b, c, d}
                                sort.Sort(sort.Reverse(sort.IntSlice(s)))
                                max[i][j] = s[0]
                        }
                }
        }
        r := 0;
        for i := 0; i < n; i++ {
                for j := 0; j < m; j++ {
                        r += max[i][j]
                }
        }
        return r
}

func main() {
        fmt.Scan(&n, &m)
        board = make([][]byte, n)
        max = make([][]int, n)
        for i := 0; i < n; i++ {
                board[i] = make([]byte, m)
                max[i] = make([]int, m)
                var s string
                fmt.Scan(&s)
                for j := 0; j < m; j++ {
                        board[i][j] = s[j]
                }
        }
        fmt.Println(findMax())
}


import "fmt"

func main() {

	var n, k int
	_, _ = fmt.Scan(&n, &k)

	for i := 0; i < k; i++ {
		if n%10 == 0 {
			n /= 10
		} else {
			n--
		}
	}

	fmt.Println(n)

}


import "fmt"

func main(){
    fmt.Println("hi")

}


package main

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

func wrongSubstraction() int {
	input := os.Args[1:]

	number, _ := strconv.Atoi(input[0])
	iter, _ := strconv.Atoi(input[1])

	for i := 0; i < iter; i++ {
		if number%10 == 0 {
			number /= 10
		} else {
			number--
		}
	}
	return number
}

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


package main

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

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

const MOD int64 = 1000000007

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n := nextInt64()
	var ret, a int64 = 1, 1

	for ; n > 0; n-- {
		ret = (ret * 27) % MOD
		a = (a * 7) % MOD
	}
	println(ret, a)
	if ret < a {
		ret += MOD
	}
	println(ret - a)
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }


package main

import (
	"fmt"
)

const (
	mod = 1000000007
)

func pow(n int, k int) int {
	if k == 0 {
		return 1
	}
	res := pow(n, k>>1)
	res = int((int64(res) * int64(res)) % mod)
	if k&1 != 0 {
		res = int((int64(res) * int64(n)) % mod)
	}
	return res
}

func solve(n int) int {
	a := pow(3, 3*n)
	a -= pow(7, n)
	a %= mod
	if a < 0 {
		return a - mod
	}
	return a
}

func main() {
	var n int
	fmt.Scanf("%d", &n)
	fmt.Println(solve(n))
}


package main

import (
    "fmt"
    )

func factorize(x int64) (length int, result [50]int64) {
    ri:=0
    reminder:=x
    lastdivider:=int64(2)
    for 1<reminder {
        reminderisprime:=true
        for i:=lastdivider; i*i<=reminder; i++ {
            if reminder%i==0 {
                result[ri]=i
                ri++
                reminder/=i
                lastdivider=i
                reminderisprime=false
                break
            }
        }
        if reminderisprime {
            result[ri]=reminder
            break
        }
    }
    return ri,result
}

func convolute(lng int, x [50]int64) (length int,primes,powers,quotients [15]int64) {
    for i:=0; i<=lng; i++ {
        if x[i]==0 {return}
        if i==0||primes[length-1]!=x[i] {
            primes[length]=x[i]
            quotients[length]=x[i]
            length++
        } else {
            quotients[length-1]*=x[i]
        }
        powers[length-1]++
    }
    return
}

func main() {
    var a,b int64
    fmt.Scanf("%d %d",&a,&b)

    la,da,pa,qa:=convolute(factorize(a))
    lb,db,pb,qb:=convolute(factorize(b))
    lab,dab,pab,qab:=convolute(factorize(a+b))

    var veca,vecb, vec [15]int64

    la--
    lb--
    lab--
    xa:=int64(1)
    xb:=int64(1)
    xab:=int64(1)

    min_p:=2*(a+b+1)
MainLoop:
    for {
        for i:=lab; i>=0; i-- {
            vec[i]++
            if pab[i]<vec[i] {
                if i==0 {break MainLoop}
                vec[i]=0
                xab/=qab[i]
            } else {
                xab*=dab[i]
                break
            }
        }
        yab:=(a+b)/xab
        p:=2*(xab+yab)
        if min_p<=p {continue}

        for i:=la; i>=0; i-- {
            veca[i]=0
        }

MainLoopA:
        for {
            for i:=la; i>=0; i-- {
                veca[i]++
                if pa[i]<veca[i] {
                    if i==0 {break MainLoopA}
                    veca[i]=0
                    xa/=qa[i]
                } else {
                    xa*=da[i]
                    break
                }
            }
            ya:=a/xa
            if xa<=xab&&ya<=yab||ya<=xab&&xa<=yab {
                min_p=p
                break
            }
        }

        if min_p==p {continue}

        for i:=lb; i>=0; i-- {
            vecb[i]=0
        }

 MainLoopB:
        for {
            for i:=lb; i>=0; i-- {
                vecb[i]++
                if pb[i]<vecb[i] {
                    if i==0 {break MainLoopB}
                    vecb[i]=0
                    xb/=qb[i]
                } else {
                    xb*=db[i]
                    break
                }
            }
            yb:=b/xb
            if xb<=xab&&yb<=yab||yb<=xab&&xb<=yab {
                min_p=p
                break
            }
        }

    }
    fmt.Println(min_p)
}


package main

import (
	"fmt"
	"sort"
)

var a, b int64
var aDiv, bDiv, sumDiv []int64

func checkDivisor(d []int64, n, div int64) []int64 {
	if n % div == 0 {
		d = append(d, div)
		q := n / div
		if q * q != n {
			d = append(d, q)
		}
	}
	return d
}

func checkBest(divs []int64, n int64, smaller, bigger int64, best *int64) {
	ld := len(divs)
	l := sort.Search(ld, func(ind int) bool {
		return smaller < divs[ind]
	})
	if l == ld {
		return
	}
	y := n / divs[l - 1]
	if y <= bigger {
		tmp := 2 * (smaller + bigger)
		if tmp < *best {
			*best = tmp
		}
	}
}

func main() {
	fmt.Scanf("%d %d", &a, &b)
	s := a + b
	aDiv, bDiv, sumDiv = make([]int64, 0), make([]int64, 0), make([]int64, 0)

	for i := int64(1); i*i <= s; i++ {
		aDiv = checkDivisor(aDiv, a, i)
		bDiv = checkDivisor(bDiv, b, i)
		sumDiv = checkDivisor(sumDiv, s, i)
	}

	makeLess := func(s []int64) func(x, y int) bool {
		return func(x, y int) bool {
			return s[x] < s[y]
		}
	}

	sort.Slice(aDiv, makeLess(aDiv))
	sort.Slice(bDiv, makeLess(bDiv))
	sort.Slice(sumDiv, makeLess(sumDiv))

	best := (s + 1) * 2

	for i := 0; i < len(sumDiv); i++ {
		smaller := sumDiv[i]
		if smaller * smaller > s {
			break
		}
		bigger := s / smaller
		checkBest(aDiv, a, smaller, bigger, &best)
		checkBest(bDiv, b, smaller, bigger, &best)
	}

	fmt.Println(best)
}


package main

import (
	"fmt"
)

func countRotations(inStr string) int{
	var cur = 'a'
	var ans = 0
	var dis = 0
	for _, c := range inStr{
		fmt.Println(cur,c,int(cur),int(c))
		dis=int(cur)-int(c)
		if dis<0{
			dis=-dis
		}
		if (26-dis)<dis{
			dis=26-dis
		}
		ans+=dis
		cur=c
	}
	return ans
}

func main(){
	var inStr string
	fmt.Scanln(&inStr)
	fmt.Println(countRotations(inStr))
}


// Турба го в Го, зачем тебе питон?
// Вот видеоурок Го для веба https://youtu.be/k27Oga3Wmxs
package main

import "fmt"

var sig = []int{6, 2, 5, 5, 4, 5, 6, 3, 7, 6, 49}

func getsumm(n int) int {
	res := 0
	for n > 0 {
		res += sig[n%10]
		n /= 10
	}
	return res
}

func main() {

	var k, n int
	var res int64 = 0
	nice := []int{0, 1, 11, 111, 1111, 11111, 111111}
	nice2 := []int{1, 10, 100, 1000, 10000, 100000, 1000000}
	a := 1
	b := 100
	fmt.Scan(&a, &b)
	for n = 0; b > a+9; n++ {
		k = getsumm(b/10)*nice2[n] + sig[10]*nice[n]
		for ; b%10 != 9; b-- {
			res += int64(k + sig[b%10])
		}
		k = getsumm(a/10)*nice2[n] + sig[10]*nice[n]
		for ; a%10 != 0; a++ {
			res += int64(k + sig[a%10])
		}
		a /= 10
		b /= 10
	}
	for ; b+1 > a; a++ {
		res += int64(getsumm(a)*nice2[n] + sig[10]*nice[n])
	}

	fmt.Println(res)
}


package main

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

//N _
const (
	N = 1e6 + 5
)

var values []byte

func inputter(inputReader *bufio.Reader,strs chan *string){
	for {
		input , _ := inputReader.ReadString('\n')
		input = strings.TrimSpace(input)
		if len(input) > 0 {
			inputs := strings.Split(input, " ")
			for i := range inputs{
				strs <- &inputs[i]
			}
		}
	}
}

func digits(x int32, ch chan byte){
	a := byte(0)
	for x > 0 {
		a += values[x%10]
		x/=10
	}
	ch <- a
}

func main(){
	rs := bufio.NewReader(os.Stdin)
	ws := bufio.NewWriter(os.Stdout)

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	a , _ := strconv.ParseInt(*<-strs, 10, 64)
	b , _ := strconv.ParseInt(*<-strs, 10, 64)

	values = []byte{6, 2, 5, 5, 4, 5, 6, 3, 7, 6}

	ch := make(chan byte)

	for i := a; i <= b; i++ {
		go digits(int32(i), ch)
	}

	total := int64(0)
	for i := int64(0); i < b - a + 1; i++ {
		total += int64(<-ch)
	}

	ws.WriteString(fmt.Sprint(total))
	ws.Flush()
}


package main

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

var dig = map[int]int{
	0: 6,
	1: 2,
	2: 5,
	3: 5,
	4: 4,
	5: 5,
	6: 6,
	7: 3,
	8: 7,
	9: 6,
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Scan()
	start := strings.Split(scanner.Text(), " ")
	x1, _ := strconv.Atoi(start[0])
	x2, _ := strconv.Atoi(start[1])

	sum := 0
	for i := x1; i <= x2; i++ {
		sum += dig[i]
	}
	fmt.Print(sum)
}


package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  total, found, min, max := getI(), getI(), getI(), getI()
  foundMin, foundMax := false, false
  for i := 0; i < found; i++ {
    x := getI()
    if x == min {
      foundMin = true
    } else if x == max {
      foundMax = true
    }
  }
  result := "Correct"
  if !foundMin && !foundMax && total-found == 1 {
    result = "Incorrect"
  }
  writer.WriteString(fmt.Sprintf("%s\n", result))
}


/*
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

			cur *= a
		}

		counts[a] = cnt
	}

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

// 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 (
	"bufio"
	. "fmt"
	"io"
	"os"
)

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

	var n, x int64
	Fscan(in, &n, &x)
	ans := int64(1e18)
	f := func(p, e int64) {
		c := int64(0)
		for pp := p; pp <= n; pp *= p {
			c += n / pp
		}
		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 (
	"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)
	for i := 0; i < t; i++ {
		for j := 0; j < t; j++ {
			if a-i*da + b-j*db == x {
				writer.WriteString("YES\n")
				return
			}
		}
	}
	writer.WriteString("NO\n")
}


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)
    for i := 0; i < t; i++ {
        m[a-(da*i)] = true
    }
    ans := false
    for i := 0; i < t; i++ {
        if m[x-(b-(db*i))] {
            ans = true
            break
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}


// 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")
			}
		}
	}
	fmt.Print("NO")
}


// 203A-mic_rizal
package main

import (
	"fmt"
)

func main() {
	var x, t, a, b, y, k int

	fmt.Scan(&x, &t, &a, &b, &y, &k)

	ret := false

	if x == 0 {
		ret = true
	}
	for i := 0; i < t; i++ {
		if x == a-i*y {
			ret = true
		}
	}
	for i := 0; i < t; i++ {
		if x == b-i*k {
			ret = true
		}
	}
	for i := 0; i < t; i++ {
		for r := 0; r < t; r++ {
			if x == a-i*y+b-r*k {
				ret = true
			}
		}
	}
	if ret {
		fmt.Println("YES")
	} else {4
		fmt.Println("NO")
	}
}


// 304A
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b, n int
	s := 0
	fmt.Scan(&n)
	for a = 1; a <= n; a++ {
		for b = a; b <= n; b++ {
			c := math.Sqrt(float64(a ^ 2 + b ^ 2))
			if int(c) <= n && int(c*c) == a^2+b^2 {
				s++
			}
		}
	}
	fmt.Print(s)
}


package main

import "fmt"

var x, k, A, B, res int64

func main()  {
	fmt.Scanf("%d\n%d\n%d\n%d", &x, &k, &A, &B)
	for x > 1 {
		if (k == 1) || (x % k != 0) {
			x--
			res += A
		} else {
			d := x / k;
			if B > (x - d) * A {
				x--
				res += A
			} else {
				x /= k
				res += B
			}
		}
	}
	fmt.Println(res)
}


package main

import "fmt"

var x, k, A, B, res int64

func main()  {
	fmt.Scanf("%d\n%d\n%d\n%d", &x, &k, &A, &B)
	x--;
	if k == 1 {
		res = x * A
		x = 0
	}
	for x > 0 {
		if x % k != 0 {
			d := x % k;
			x -= d
			res += A * d
		} else {
			d := x / k;
			if B > (x - d) * A {
				x -= d
				res += A * d
			} else {
				x /= k
				res += B
			}
		}
	}
	fmt.Println(res)
}


package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int64

	fmt.Fscanf(buf, "%d\n", &t)
	var ans int64 = 1+t

	for i := int64(2);i*i <= t;i++{
		if t%i == 0{
			if ans > i+t/i{
				ans = i+t/i
			}
		}
	}
	fmt.Printf("%d\n",ans)
}


package main

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

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

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

func main() {
	defer writer.Flush()
    scanner.Split(bufio.ScanWords)

	n := ReadInt()

	if n == 1 {
	    writer.WriteString("2")
	    return
	}

	if n == 2 {
	    writer.WriteString("3")
		return
	}

	if n%2 == 0 {
	    writer.WriteString(strconv.Itoa((n/2) + 2))
	} else {
	    writer.WriteString(strconv.Itoa(((1+n)/2) + 2))
	}

}


package main

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

const (
	BIG = 1024 * 1024 * 10
)

func readLine(r *bufio.Reader) string {
	bytes, _, err := r.ReadLine()
	if err != nil {
		log.Fatalln("Failed to read line")
	}

	return string(bytes)
}

func readInts(r *bufio.Reader) []int {
	elems := strings.Fields(readLine(r))

	ret := make([]int, len(elems))
	for i, el := range elems {
		tmp, err := strconv.ParseInt(el, 10, 64)
		if err != nil {
			log.Fatalf("Failed to parse number %v", el)
		}
		ret[i] = int(tmp)
	}

	return ret
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, BIG)

	tmp := readInts(r)
	w, h := tmp[0], tmp[1]
	tmp = readInts(r)
	u1, d1 := tmp[0], tmp[1]
	tmp = readInts(r)
	u2, d2 := tmp[0], tmp[1]

	for i := h; i > 0; i-- {
		w += i
		if i == d1 {
			if w > u1 {
				w -= u1
			} else {
				w = 0
			}
		} else if i == d2 {
			if w > u2 {
				w -= u2
			} else {
				w = 0
			}
		}
	}

	fmt.Println(w)
}


package main

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

func main() {

	inputreader := bufio.NewReader(os.Stdin)
	_, _ = inputreader.ReadString('\n')
	input, _ := inputreader.ReadString('\n')

	hours := 0
	first := false
	skips := 0

	for _, n := range strings.Split(input, " ") {
		k, _ := strconv.Atoi(n)
		if k == 1 {
			if !first {
				hours++
				first = true
			} else if skips == 1 {
				hours+=2
			} else {
				hours++
			}
			skips = 0
		} else {
			skips ++
		}
	}

	fmt.Print(hours)

}


package main

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

// Node -> node in Linked-List
type Node struct {
	D    int
	Next *Node
}

// Head -> head of Linked-List
type Head struct {
	Front *Node
	Back  *Node
	C     int
}

func (h *Head) createNode(i int) *Node {
	var n *Node = new(Node)
	n.D = i
	n.Next = nil
	h.C++
	return n
}

func (h *Head) solve() int {
	var c int
	h.Back = h.Front
	for i := 0; i < h.C-1; i++ {
		if (h.Back.Next.D - h.Back.D) == 1 {
			c++
		} else if (h.Back.Next.D - h.Back.D) == 2 {
			c += 2
		} else {
			c++
		}
		h.Back = h.Back.Next
	}
	c++

	return c
}

func (h *Head) free() {
	h.Back = h.Front
	for h.Back != nil {
		h.Front = h.Back.Next
		h.Back.D = 0
		h.Back.Next = nil
		h.Back = h.Front
	}
	h.C = 0
}

func main() {
	var head *Head = new(Head)
	var newNode *Node
	var scanner *bufio.Scanner
	var s string
	var count int = 0

	scanner = bufio.NewScanner(os.Stdin)
	head.Front = nil
	head.Back = nil
	head.C = 0
	// n
	scanner.Scan()

	// data
	scanner.Scan()
	s = regexp.MustCompile("\\s*").ReplaceAllString(scanner.Text(), "")
	for i := 0; i < len(s); i++ {
		if s[i] == '1' {
			newNode = head.createNode(i + 1)
			if head.Front == nil {
				head.Front = newNode
				head.Back = newNode
			} else {
				head.Back.Next = newNode
				head.Back = newNode
			}
		}
	}

	head.Back = head.Front
	// fmt.Println("number of node(s):", head.C)
	// for head.Back != nil {
	// 	fmt.Printf("%d ", head.Back.D)
	// 	head.Back = head.Back.Next
	// }
	// fmt.Println()

	count = head.solve()

	fmt.Println(count)

	head.free()

	// fmt.Println("number of node(s):", head.C)
	// for head.Back != nil {
	// 	fmt.Printf("%d ", head.Back.D)
	// 	head.Back = head.Back.Next
	// }

}


// 已知某广场的长宽（都为整数），现有瓷砖（数量大于0小于10的9次方），请问最少需要多少块能把广场铺满,瓷砖不能打碎，瓷砖长宽与广场长宽平行
package main

import (
	"fmt"
)

func needNumber(m, n, a int32) int32 {
	var w, h int32
	if m%a > 0 {
		w = m/a + 1
	} else {
		w = m / a
	}
	if n%a > 0 {
		h = n/a + 1
	} else {
		h = n / a
	}
	return w * h
}
func main() {
	var m, n, a int32
	fmt.Scanln(&m, &n, &a)
	num := needNumber(m, n, a)
	fmt.Println(num)

}

//学会使用if else语法
//学会使用标准输入输出语法


package main

import "fmt"
import "strings"

func main() {

	var a, b int;

	fmt.Scan(&a, &b);

	fmt.Println((a * b) / 2)
}


package main

import ("fmt"
        "math"
)

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

    h := int64(math.Floor(n*m/2)
    fmt.Println(h)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var m, n int
	fmt.Scan(&m, &n)
	fmt.Println(int(math.Floor(m * n / 2)))
}


package main

import "fmt"

func main() {
    var m, n int
    fmt.Scanf(&m, &n)
    fmt.Println(m * n / 2)
}


package main

import "fmt"

func calc(t int) string {
	var a int
	var b int
	fmt.Scanln(&a,&b)
	var prev int = a
	var sum1 int = a
	var sum2 int = b
	var flag bool = false

	if a!=b{
		return "rated"
	}
	for i:=1;i<t;i++{
		var c int
		var d int
		fmt.Scanln(&c,&d)
		if c!=d{
			return "rated"
		}
		sum1 += c
		sum2 += d
		if prev<c{
			flag = true
		}
		prev  = c
	}

	if sum1!=sum2{
		return "rated"
	}else{
		if flag==true{
			return "unrated"
		}
	}
	return "maybe"
}

func main(){
	var t int
	fmt.Scanln(&t)
	ans := calc(t)
	fmt.Print(ans)
}


// Try Codeforces
// author: Leonardone @ NEETSDKASU
package main

import "fmt"

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	c := 0
	for {
		c++
		a -= c
		if a <= 0 {
			fmt.Println("Valera")
			break
		}
		c++
		b -= c
		if b <= 0 {
			fmt.Println("Vladik")
			break
		}
	}
}


package main

import "fmt"

func main() {
	var a, b int
	var k int
	fmt.Scanf("%d %d\n", &a, &b)
	for {
		if a-k < 0 {
			fmt.Println("Valera")
			break
		} else {
			a = a - k
			k++
		}
		if b-k < 0 {
			fmt.Println("Vladik")
			break
		} else {
			b = b - k
			k++
		}
	}
}


package main

import "bufio"
import "strconv"
import "os"
import "container/heap"

const inf = int64(100000000000000000)

type Item struct {
	value    int
	priority int64
	index    int
}

type PriorityQueue []*Item

func (pq PriorityQueue) Len() int { return len(pq) }

func (pq PriorityQueue) Less(i, j int) bool {
	return pq[i].priority < pq[j].priority
}

func (pq PriorityQueue) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *PriorityQueue) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Item)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *PriorityQueue) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

var in *bufio.Scanner
var out *bufio.Writer

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

	in.Split(bufio.ScanWords)
	defer out.Flush()

	in.Scan()
	n, _ := strconv.Atoi(in.Text())

	in.Scan()
	x, _ := strconv.Atoi(in.Text())

	in.Scan()
	y, _ := strconv.Atoi(in.Text())

	best := make([]int64, n*2+1)
	fixed := make([]bool, n*2+1)
	for i := 0; i <= n*2; i++ {
		best[i] = inf
		fixed[i] = false
	}

	root := 0
	best[root] = 0

	var queue PriorityQueue
	queue = append(queue, &Item{value: root, priority: best[root], index: 0})
	heap.Init(&queue)

	for queue.Len() > 0 {
		item := heap.Pop(&queue).(*Item)
		u := item.value

		if !fixed[u] {
			fixed[u] = true
			delta := []int{u - 1, u + 1, u * 2}
			cost := []int{x, x, y}
			for idx, v := range delta {
				if (v > 0) && (v <= 2*n) && (!fixed[v]) {
					cost := int64(cost[idx])
					if best[v] > best[u]+cost {
						best[v] = best[u] + cost
						newItem := &Item{value: v, priority: best[v]}
						heap.Push(&queue, newItem)
					}
				}
			}
		}
	}

	out.WriteString(strconv.FormatInt(best[n], 10))
	out.WriteByte('\n')
}


package main

import "os"
import "bufio"
import "strconv"

var in *bufio.Scanner
var out *bufio.Writer

func dp(n int, x int64, y int64) int64 {
	f := make([]int64, n+1)

	f[0] = 0
	for i := 1; i <= n; i++ {
		if i%2 == 0 {
			f[i] = min(f[i-1]+x, f[i/2]+y)
		} else {
			f[i] = min(f[i-1]+x, f[(i+1)/2]+y+x)
		}
	}

	return f[n]
}

func main() {
	in = bufio.NewScanner(os.Stdin)
	out = bufio.NewWriter(os.Stdout)

	in.Split(bufio.ScanWords)
	defer out.Flush()

	in.Scan()
	n, _ := strconv.Atoi(in.Text())

	in.Scan()
	x, _ := strconv.Atoi(in.Text())

	in.Scan()
	y, _ := strconv.Atoi(in.Text())

	res := dp(n, int64(x), int64(y))

	out.WriteString(strconv.FormatInt(res, 10))
	out.WriteByte('\n')
}


package main

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, x, y := nextInt(), nextInt64(), nextInt64()
	a := make([]int64, n+1)

	dp(a, x, y)

	println(a[n])
}

func dp(a []int64, x, y int64) {
	for i := 1; i < len(a); i++ {
		if i%2 == 0 {
			a[i] = min(a[i-1]+x, a[i/2]+y)
		} else {
			a[i] = min(a[i-1]+x, a[i/2]+x+y)
		}
	}
}

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

	return b
}

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

func nextInt64() int64 {
	n, _ := strconv.ParseInt(next(), 0, 64)
	return n
}

func nextInt() int {
	n, _ := strconv.Atoi(next())
	return n
}

func nextFloat() float64 {
	n, _ := strconv.ParseFloat(next(), 64)
	return n
}

func println(a ...interface{})               { fmt.Fprintln(writer, a...) }
func print(a ...interface{})                 { fmt.Fprint(writer, a...) }
func printf(format string, a ...interface{}) { fmt.Fprintf(writer, format, a...) }


// http://codeforces.com/problemset/problem/710/E

package main

import (
	"fmt"
)

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

	return b
}

func main() {
	var n int
	var x, y int64

	fmt.Scanln(&n, &x, &y)
	times := make([]int64, n)

	times[0] = x
	for i := 1; i < n; i++ {
		if i % 2 == 0 {
			// odd
			times[i] = x + times[i - 1]
		} else {
			// even
			times[i] = min(x + times[i - 1], y + times[i / 2])
		}
	}

	fmt.Println(times[n - 1])
}


package main

import "fmt"

func main() {
    var s string
    fmt.Scanf("%s", &s)
    c := s[0] - 'a'
    d := s[1] - '1'
    answ := 8
    var b1, b2 bool
    if c == 0 || c == 7 {
        answ -= 3
        b1 = true
    }
    if d == 0 || d == 7 {
        answ -= 3
        b2 = true
    }
    if b1 && b2 {
        answ++
    }
    print(answ)
}


// Try Codeforces
// author: Leonrdone @ NEETSDKASU
package main

import (
	"fmt"
	"sort"
)

type Foo []int64

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

func main() {
	var n, k int
	var m int64
	fmt.Scan(&n, &k, &m)
	xs := make([]int64, k)
	for i := range xs {
		fmt.Scan(&xs[i])
	}
	sum := int64(0)
	for _, x := range xs {
		sum += x
	}
	sort.Sort(Foo(xs))
	ans := int64(0)
	for i := 0; i < n; i++ {
		altm := sum * int64(i)
		if altm > m {
			break
		}
		tmp := int64((k + 1) * i)
		p := int64(n - i)
		for _, x := range xs {
			w := p
			for altm+w*x > m {
				w--
			}
			altm += w * x
			tmp += w
		}
		if tmp > ans {
			ans = tmp
		}
	}
	fmt.Println(ans)
}


package main

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

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

func f(x, y, z int, c chan int) {
	c <- x + y + z
	c <- x + y * z
	c <- (x + y) * z
	c <- x * y + z
	c <- x * (y * z)
	c <- x * y * z
	close(c)
}

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

func main() {
	defer out.Flush()

	var a, b, c int
	fmt.Fscan(in, &a, &b, &c)

	ch := make(chan int)
	go f(a,b,c, ch)

	var res int
	for i := range ch {
		res = max(res, i)
	}
	fmt.Println(res)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var x1, y1 float64
	var x2, y2 float64
	fmt.Scanf("%f %f\n", &x1, &y1)
	fmt.Scanf("%f %f\n", &x2, &y2)

	xDiff := math.Abs(x1 - x2)
	yDiff := math.Abs(y1 - y2)

	fmt.Println(math.Max(xDiff, yDiff))
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var (
		t string
		a string
		b bool
	)
	fmt.Scan(&t)
	tslice := strings.Split(t, "")
	n := len(tslice)
	if n % 2 != 0 {
		a += tslice[n / 2]
		for i := n / 2; i < n - 1; i++ {
			tslice[i] = tslice[i + 1]
		}
		b = true
		n--
	}
	for i := n / 2 - 1; i >= 0; i-- {
		if b {
			a += tslice[i] + tslice[n - i - 1]
		} else {
			a += tslice[n - i - 1] + tslice[i]
		}
	}
	fmt.Println(a)
}


package main

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

var in *bufio.Scanner = bufio.NewScanner(os.Stdin)
var out *bufio.Writer = bufio.NewWriter(os.Stdout)

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)

	n, m := nextInt(), nextInt()
	a, b := make([]byte, m), make([]byte, m)
	for i := 0; i < m; i++ {
		a[i] = '#'
		b[i] = '.'
	}
	b[m - 1] = '#'
	for i := 0; i < n; i++ {
		if i % 2 == 0 {
			fmt.Println(string(a))
		} else {
			fmt.Println(string(b))
			rev(b)
		}
	}

}

func rev(a []byte) {
	for i, j := 0, len(a) - 1; i <= j; {
		a[i], a[j] = a[j], a[i]
		i++
		j--
	}
}

func nextInt() int {
	in.Scan()
	res, _ := strconv.Atoi(in.Text())
	return res
}


package main

//14:17

import (
    "fmt"
)

func main() {
    var n, m int
    fmt.Scanf("%d %d", &n,&m)
    var i,j int
    for true {
        for j=0;j<=i;j++ {
            if n == j + m*i{
                fmt.Printf("%d", i+j)
                return
            }else if n <= j+m*i {
                fmt.Printf("-1");
                return;
            }
        }
        i++
    }
}


package main

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

var (
	reader  = bufio.NewReader(os.Stdin)
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	var n, x int
	scan(&n, &x)
	if n/x > 0 {
		v2 := n / 2
		v1 := n % 2
		for v2 >= 0 {
			fmt.Println(v2, v1)
			if (v2+v1)%x == 0 {
				fmt.Println(v2 + v1)
				return
			}
			v2--
			v1 += 2
		}
	} else {
		fmt.Println("-1")
	}
}

func scan(a ...interface{}) {
	fmt.Fscan(reader, a...)
}


package main

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

func main() {
	var n, m int // n台阶级数，m移动次数是m倍

	reader := bufio.NewReader(os.Stdin)
	fmt.Fscanln(reader, &n, &m)

	if m > n { // 如果倍数比台阶还多，肯定不可能
		fmt.Println(-1)
	} else {
		var move int
		//如果台阶是偶数 直接先除2
		if n%2 == 0 {
			move = n / 2

		} else {
			move = (n + 1) / 2
		}
		if move%m == 0 {
			fmt.Println(move)
		} else {
			fmt.Println(move + 1)
		}
	}
}


package main

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

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

type Int64Slice []int64

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

var usr1 [20]int
var usr2 [20]int

var n, m int
var val [2][30]int

func guess(v int) int {
	ret := 0
	for i := 0; i < n; i++ {
		if v == val[0][i*2] || v==val[0][i*2+1] {
			for j := 0; j < m; j++ {
				if v == val[1][j*2] || v==val[1][j*2+1] {
          // fmt.Printf("v:%v   %v - %v\n",v,i,j)
					if val[0][i*2] == val[1][j*2] && val[0][i*2+1] == val[1][j*2+1] {
					} else {
						if (usr1[i] == 0 || usr1[i] == v) && (usr2[j] == 0 || usr2[j] == v) {
							usr1[i] = v
							usr2[j] = v
							ret = v
						} else {
							return -1
						}
					}

				}
			}
		}
	}
	return ret
}

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, m = ReadInt32(), ReadInt32()

	for i := 0; i < n; i++ {
		val[0][i*2] = ReadInt32()
		val[0][i*2+1] = ReadInt32()
	}
	for i := 0; i < m; i++ {
		val[1][i*2] = ReadInt32()
		val[1][i*2+1] = ReadInt32()
	}

	// 1 zu pei 1 -> res
	ans := -1
	for i := 1; i < 10; i++ {
		ret := guess(i)
		if ret == -1 {
			fmt.Printf("-1\n")
			return
		}
    if ret == 0 {
      continue
    }
		if ans == -1 {
			ans = ret
		} else {
			ans = 0
		}
	}
	fmt.Printf("%v\n", ans)

	// quan pei 1 -> 0

	// else -1

}

func Demo() {
	var n, m int64 = ReadInt64(), ReadInt64()
	PrintInt64s(n, m)
	writer.WriteByte('\n')
	slice := []int64{1, 2, 3, 4, 5}
	PrintInt64s(slice...)

	// sortDemo
	//slice := []int64{5, 3, 4, 2, 1}
	sort.Sort(Int64Slice(slice))

	//s := strconv.FormatBool(true)
	//s := strconv.FormatFloat(3.1415, 'E', -1, 64)
	//s := strconv.FormatInt(-42, 16)
	//s := strconv.FormatUint(42, 16)

}

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

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

func MinFloat64(a float64, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

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

func MaxFloat64(a float64, b float64) float64 {
	if a < b {
		return a
	}
	return b
}

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

func ReadInt64() int64 {
	scanner.Scan()
	ans, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return ans
}

func ReadFloat64() float64 {
	scanner.Scan()
	ans, _ := strconv.ParseFloat(scanner.Text(), 64)
	return ans
}

func PrintInt64s(ints ...int64) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(int(value)))
		writer.WriteByte(' ')
	}
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	s := ""
	fmt.Scan(&s)
	n := strings.Count(s, "-")
	b := strings.Count(s, "o")
	if n%b == 0 {
		fmt.Printf("YES\n")
	} else {
		fmt.Printf("NO\n")
	}
}


package main

import (
	"strings"
	"fmt"
)

var YES = "YES"
var NO = "NO"

var bead = "o"
var thread = "-"

func Resolve(input string) string {
	var beadCount = strings.Count(input, bead)
	var threadCount = strings.Count(input, thread)

	if threadCount%beadCount == 0 {
		return YES
	}

	return NO
}

func main() {
	var input string
	fmt.Scanln(&input)
	fmt.Println(Resolve(input))
}


package main

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

func main() {
	var line string
	var businki, nitki int64
	reader := bufio.NewReader(os.Stdin)
	line, _ = reader.ReadString('\n')
	for _, v := range line {
		if v == 'o' {
			businki++
		} else if v == '-' {
			nitki++
		}
	}
	if nitki == 0 || nitki%businki == 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import "fmt"

func main() {
	var line string
	fmt.Scan(&line)

	elems := []rune(line)

	countFibres, countBeads := 0, 0
	for i := 0; i < len(elems); i++ {
		if elems[i] == '-' {
			countFibres++
		} else {
			countBeads++
		}
	}

	if countFibres % countBeads == 0 {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}


package main

import (
	"fmt"
)

func main() {
	var a, b, ans int
	fmt.Scan(&a, &b)
	for {
		ans += a
		a = a/b + a%b
		if a < b {
			ans += a
			break
		}
	}
	fmt.Print(ans)
}


package main

import (
	"fmt"
)

func main() {
	var n, t int
	fmt.Scanln(&n, &t)

	cnt := n

	for n/t > 0 {
		cnt += n / t
		n = (n / t) + (n % 2)
	}

	fmt.Println(cnt)
}


package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)

	var hours int = 0
	var rest = 0
	for candles := a; candles > 0; {
		rest += candles % b
		hours += candles
		if rest/b > 0 {
			candles += 1
			rest %= b
		}
		candles /= b
	}

	fmt.Printf("%d\n", hours)
}


package main

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

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

//========== Implement Algorithm =======================
func solution(a int, b int) int {
	temp := a
	for a > 0 {
		temp += a / b
		a = a / b

	}
	return temp
}

func main() {

	scanner := bufio.NewScanner(os.Stdin)

	//================== Variables used ====================
	var a, b, ret int
	//======================================================

	//============== Get return value from File ============
	if len(os.Args) >= 2 {

		file, err := os.Open(os.Args[1])
		if err != nil {
			log.Fatalf("failed opening file: %s", err)
		}
		scanner = bufio.NewScanner(file)
		defer file.Close()

	}
	scanner.Split(bufio.ScanWords)
	//======================= I/O ==========================
	scanner.Scan()
	a = fastGetInt(scanner.Bytes())
	scanner.Scan()
	b = fastGetInt(scanner.Bytes())
	//======================================================
	ret = solution(a, b)
	//==================== OUTPUT ==========================
	fmt.Print(ret)
}


// http://acm.timus.ru/problem.aspx?space=1&num=1741
package main

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

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

const (
	MOD = 1e9 + 7
)

type (

)

var
	days = [...]string{"monday", "tuesday", "wednesday", "thursday", "friday", "saturday", "sunday"}

func main () {
	var (
		s1, s2 string
	)

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

	fmt.Fscanln(input, &s1)
	fmt.Fscanln(input, &s2)

	p1, p2 := 0, 0
	for i := 0; i < len(days); i++ {
		if days[i] == s1 {
			p1 = i
			break
		}
	}

	for i := 0; i < len(days); i++ {
		if days[i] == s2 {
			p2 = i + 7
			break
		}
	}

	// Solve
	diff := (p2 - p1)
	if 31 % 7 == diff || 28 % 7 == diff  || 30 % 7 == diff {
		fmt.Println("YES")
		return
	}

	fmt.Println("NO")
}


package main

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

type scanner struct {
	sc *bufio.Scanner
}

func (sc *scanner) next() string {
	sc.sc.Scan()
	return sc.sc.Text()
}

func (sc *scanner) nextInt() int {
	i, err := strconv.Atoi(sc.next())
	if err != nil {
		panic(err)
	}
	return i
}

func newScanner(r io.Reader, split bufio.SplitFunc) *scanner {
	sc := bufio.NewScanner(r)
	sc.Split(split)
	return &scanner{
		sc: sc,
	}
}

var wsc = newScanner(os.Stdin, bufio.ScanWords)
var lsc = newScanner(os.Stdin, bufio.ScanLines)

func next() string {
	return wsc.next()
}

func nextInt() int {
	return wsc.nextInt()
}

func nextLine() string {
	return lsc.next()
}

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
}
func joinInts(a []int, sep string) string {
	b := make([]string, len(a))
	for i, v := range a {
		b[i] = strconv.Itoa(v)
	}
	return strings.Join(b, sep)
}

var weekdays = map[string]int{
	"sunday":    1,
	"monday":    2,
	"tuesday":   3,
	"wednesday": 4,
	"thursday":  5,
	"friday":    6,
	"saturday":  7,
}

func main() {
	d1, d2 := weekdays[next()], weekdays[next()]
	if d1-d2 == 4 || d2-d1 == 3 || d1-d2 == 3 || d2-d1 == 2 || d1 == d2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
	"fmt"
	"log"
	"sort"
)

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func find_last_le_idx(a []int, target int )int {
	//if not exist rturn -1

	s := 0
	e := len(a)
	for ;s < e;{
		mid := s +(e- s)/2
		if a[mid ] <= target{
			s = mid + 1
		}else {
			e = mid
		}
	}
	return s - 1
}

func find_first_ge_idx(a []int, target int )int {
	//if not exist rturn -1

	s := 0
	e := len(a)
	for ;s < e;{
		mid := s +(e- s)/2
		if a[mid ] < target{
			s = mid + 1
		}else {
			e = mid
		}
	}

	return s
}

func maxSumSubmatrix(a [][]int, target int) int {
	row := len(a)
	if row == 0{
		return 0
	}
	col := len(a[0])

	pre_sum := make([][]int, row)
	for i := range pre_sum{
		pre_sum[i] = make([]int ,col)
	}

	for i := 0;i < row; i ++{
		for j :=0;j < col; j ++{
			if j == 0 {
				pre_sum[i][j] = a[i][j]
			}else {
				pre_sum[i][j] = pre_sum[i][j-1] + a[i][j]
			}
		}
	}

	near := -100000000
	for i := 0; i < col ; i ++{
		for j :=i ;j <col; j ++{
			tmp := []int {0}
			cur := 0
			for k := 0;k < row; k++{

				if i == j {
					cur += a[k][i]
				}else if i == 0{
					cur += pre_sum[k][j]
				}else {
					cur += pre_sum[k][j] - pre_sum[k][i-1]
				}
				idx := find_first_ge_idx(tmp, cur  - target)
				if idx != len(tmp){
					near = max(near, cur -tmp[idx] )
				}
				iid := find_first_ge_idx(tmp, cur )
				q := tmp[iid:]
				tmp = append(tmp[:iid], cur)
				tmp = append(tmp ,q...)

				//if k == 0{
				//	if cur ==target || (cur < target&& cur > near) {
				//		near = cur
				//	}
				//	tmp = append(tmp, cur)
				//}
			}

		}
	}
	return near
}

func q(matrix [][]int, k int) int {
	row := len(matrix)
	col := len(matrix[0])
	near := -1000000
	for left := 0; left < col ; left ++{
	// 以left为左边界，每行的总和
		_sum :=make([]int, row)
	//for right in range(left, col):
		for right :=left ;right <col; right ++ {

			for j := 0; j < row; j++ {
				_sum[j] += matrix[j][right]
			}
			// 在left，right为边界下的矩阵，求不超过K的最大数值和
			tmp := []int{0}
			cur := 0
			for _, tmpp := range _sum {
				cur += tmpp

				//# 二分法
				idx := find_first_ge_idx(tmp, cur-k)
				if idx != len(tmp) {
					near = max(near, cur-tmp[idx])
				}
				iid := find_first_ge_idx(tmp, cur)
				q := []int{}

				q= append(q, tmp[iid:]...)
				ee := []int{}
				ee = append(ee,tmp[:iid]...)
				ee = append(ee, cur)
				tmp = append(ee, q...)
			}
		}
		}

	return near
}

func qeqw(a int, aa int) int{

	caa := "asas"
	log.Println(caa)
	return 23
}

func m(a []int, b[]int){
	 //q := map[[2]int]bool{}

}
var ori [1000001]int
var record [1000001]int

var energy [1000001]int
var counter [1000001]int

//}
func p(){
	var n int
	var k int
	var target int
	//var n,k int
	fmt.Scan(&n)
	fmt.Scan(&k)
	for i := 0;i < n; i ++{
		fmt.Scan(&record[i])
	}
	idx := -1
	left := 0
	min_l := 1000000000
	m_l := 0
	m_r := 0
	for ;left < n &&idx < n;{
		if target == k {
			//if counter[record[left]] > 1 {
			if idx - left +1 < min_l{
				min_l = idx - left + 1
				m_l = left
				m_r = idx
			}
			counter[record[left]] --

			//}else {
			//
			//}
			if counter[record[left]] == 0 {
				target --
			}
			left ++
		}else{
				idx ++
			counter[record[idx]] ++
			if counter[record[idx]] == 1{
				target ++
			}
			//idx++
		}
	}
	fmt.Println(m_l + 1, m_r + 1)
}

func ini(){
	var n int
	//var k int
	fmt.Scan(&n)
	//fmt.Scan(&k)
	for i := 0;i < n; i ++{
		fmt.Scan(&ori[i])
		fmt.Scan(&energy[i])
	}
	R := -1
	L := 0
	for i :=0; i < n; i ++{
		//if record[L] == i - k{
		//	L ++
		//}
		for ;R >= L &&ori[i] >ori[record[R]];R--{
			counter[i]	+= energy[record[R]]
		}
		tmp := energy[i]
		for ;R >= L &&ori[i] ==ori[record[R]];R--{
			tmp += energy[i]
		}
		R ++
		record[R] = i
		if R != 0  {
			counter[record[R - 1]] += tmp
		}
	}
	m := -1
	for i :=0; i <n;i ++{
		if counter[i] > m{
			m = counter[i]
		}
	}
	fmt.Println(m)
}
type S struct {
	Idx int
	Time int

}
type intSlice []S

func (p intSlice) Len() int           { return len(p) }
func (p intSlice) Less(i, j int) bool { return p[i].Time > p[j].Time }
func (p intSlice) Swap(i, j int)      { p[i], p[j] = p[j], p[i] }

var roww [1000]int
var coll [1000]int
func inii(){
	var m,n,k,l,d int
	//var k int
	row := make(intSlice, 10000)
	col := make(intSlice, 10000)
	fmt.Scan(&m, &n, &k, &l,&d)
	//fmt.Scan(&k)
	for i := 0;i < d; i ++{
		var x1,y1,x2,y2 int
		fmt.Scan(&x1,&y1,&x2,&y2)
		if x1 == x2 {
			if y1 > y2 {
				y1,y2 = y2,y1
			}
			col[y1].Idx = y1
			col[y1].Time ++
		}else{
				if x1 > x2{
					x1,x2 = x2,x1
				}
				row[x1].Idx = x1
			row[x1].Time ++
		}
		//fmt.Scan(&energy[i])
	}
	//row = row[:m+1]
	//col = col[:n + 1]
	sort.Sort(row)
	sort.Sort(col)
	row = row[:k+1]
	col = col[:l + 1]
	sort.Sort(row)
	sort.Sort(col)
	for i := 0;i < k-1;i ++ {
		fmt.Print(row[i].Idx," ")
	}
	fmt.Print(row[k -1 ].Idx,"\n")
	for i := 0;i < l-1;i ++ {
		fmt.Print(col[i].Idx," ")
	}
	fmt.Print(col[l -1 ].Idx,"\n")

}

func next_per(){
	var n int
	var m int
	fmt.Scan(&n,&m)
	a :=make([]int, n)
	for i:=0;i <n;i++{
		fmt.Scan(&a[i])
	}
	for ;m > 0;m--{
		i := 0
		for i = n-2;i >=0;i --{
			if a[i] < a[i + 1]{
				break
			}

		}
		//t := a[i+1]
		j := 0
		for j = i + 1;j < n;j ++{
			if a[j] <= a[i]{
					break
			}
		}
		a[i],a[j-1] = a[j-1],a[i]
		sort.Ints(a[i + 1:])

	}
	fmt.Println(a)

}
var s string
var n,ans,length,carry float64
//var ans int
//var length int
//var carry int
//func max(x,y int)int{
//	if x > y{
//		return x
//	}
//	return y
//}
func maxf(x, y float64)float64{
	if x > y {
		return x
	}
	return y
}
func get(k int)int{
	var x float64
	var t float64 = 1
	i := k
	for ;i  >= 0; i -- {
		if x + maxf(float64(1), (float64)(s[i]-'0')) * float64(t) >=n{
			break
		}
		x += float64(s[i]-'0') * t
		t *= 10
	}
	for ;s[i+ 1] == '0'&& i < k-1;i ++{

	}
	ans += x * carry
	return i
}
func qq(){

	carry = 1
	fmt.Scan(&n, &s)
	i := len(s) - 1
	for ;i >=0;{
		i = get(i)
		carry *=n
	}
	fmt.Println(ans)

}

func main(){
	//a := [][]int{{28,4,-19,18,-7,-10,27,19,1,16,0,10,-17,11,11,27,-1,10,12,-1},
	//	{-2,-19,17,4,25,-20,4,3,4,28,-10,7,16,-14,-3,-19,6,17,-4,-7},
	//	{2,8,18,-17,-2,10,-6,-5,11,10,22,-6,19,-16,6,-4,18,5,22,-17},
	//	{-14,-7,-20,13,-19,-20,-15,21,-11,-10,-8,-9,10,13,6,-10,15,9,-15,-2},
	//	{-18,26,12,8,2,16,-17,12,0,-5,9,-3,-12,-11,3,-6,-18,16,-7,-14},
	//	{5,29,25,22,11,-3,-2,-15,4,13,-17,-2,0,-2,20,10,-18,6,25,-20},
	//	{5,-7,8,5,15,22,8,-5,22,-18,-5,-14,23,2,-8,12,-16,-18,12,-12},
	//	{27,18,4,11,-3,12,-4,-8,-3,25,-9,24,-14,5,11,-9,-17,0,25,-15},
	//	{26,-7,18,4,4,18,-17,9,-19,-9,-19,-8,-4,-13,10,-11,6,-16,-12,12},
	//	{28,22,7,11,-6,13,8,22,7,-14,17,14,10,29,16,9,-3,18,-9,10},
	//	{27,19,-10,-9,1,3,14,1,7,3,-3,16,-2,9,14,-7,-19,-5,23,19},
	//	{-17,7,-20,8,-5,-6,-2,25,29,16,23,4,4,27,16,17,9,20,-6,22},
	//	{2,9,-13,1,-18,25,4,7,25,26,-4,8,-19,18,6,-7,-5,7,21,-8},
	//	{-2,11,1,29,6,-16,-8,3,7,11,10,-2,-1,-20,20,4,19,5,29,-7},
	//	{29,-12,-3,17,6,19,23,12,-19,13,19,5,27,22,-17,27,10,-12,12,23},
	//	{24,16,4,25,15,13,24,-19,1,-7,-19,13,-13,14,13,26,9,18,-9,-18},
	//	{-17,4,-18,-18,-19,3,-13,12,23,-17,-10,-20,14,2,18,21,-12,27,-3,4},
	//	{27,13,12,14,16,-9,-2,-15,-20,8,-2,24,18,15,26,21,27,17,-15,-3},
	//	{25,-8,17,-10,-16,13,26,-11,-15,6,-5,-13,23,2,24,-4,5,8,-15,-1},
	//	{15,-12,18,5,-3,7,5,11,-4,-13,28,20,0,-4,-13,-5,-13,-8,-16,3}}

	//log.Println(find_last_le_idx(a, 3))
	//log.Println(q(a, -123))

	//aa := []int{2,3,1,3,4,6,1,2}
	//mm(aa, 1)
	//ini()
//inii()
	//next_per()
	qq()
}


// 318A-mic
package main

import (
	"fmt"
)

func main() {
	var m, pos int
	cou := 0
	k := 1
	fmt.Scan(&m, &pos)
	a := make([]int, m)
	for i := 0; i < m; {
		if k%2 != 0 {
			a[i] = k
			i++
			cou++
		}
		if k < m {
			k++
		} else {
			break
		}
	}
	k = 1
	for i := cou; i < m; {
		if k%2 == 0 {
			a[i] = k
			i++
			cou++
		}
		if k < m {
			k++
		} else {
			break
		}
	}
	fmt.Println(a[pos-1])
}


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 int
 	var idx int = 0

	fmt.Fscan(in,&n)
	fmt.Fscan(in,&k)

	arr := make([]int, n)

	for i := 1; i <= n; i++ {
		if i % 2 != 0 {
			arr[idx] = i
			idx++
		}
	}

	for i := 1; i <= n; i++ {
		if i % 2 == 0 {
			arr[idx] = i
			idx++
		}
	}

	fmt.Println(arr[k-1])
}


package main

import (
	//"bufio"
	"fmt"
//	"log"
	"os"
)

func solveFromFile() int {
	/*var nu int
	file, err := os.Open(os.Args[1])
	if err != nil {
		log.Fatalf("failed opening file: %s", err)
	}
	scanner := bufio.NewScanner(file)
	scanner.Scan()
	nu = fastGetInt(scanner.Bytes())

	defer file.Close()*/

	return -1//solution(nu)
}

//========== Implement Algorithm =======================
func solution(num1 int, num2 int) int {
	retval := 0
	if num2 <= num1/2+num1%2 {
		retval = num2*2 - 1
	} else {
		retval = num1- num1%num2*2-1
	}
	return retval
}

func main() {

	//================== Variables used ====================
	var num1, num2, ret int
	//======================================================

	if len(os.Args) >= 2 {
		//============== Get return value from File ============
		ret = solveFromFile()

	} else {
		//============== Get return value from STDIN ===========
		//scanner := bufio.NewScanner(os.Stdin)
		fmt.Scan(&num1)
		fmt.Scan(&num2)
		//scanner.Scan()
		//num = fastGetInt(scanner.Bytes())
		ret = solution(num1, num2)
	}

	//================== OUTPUT ============================
	fmt.Println(ret)
}


package main

import "fmt"

func main() {
	var k, n int
	x := 1
	fmt.Scanf("%d %d", &n, &k)
	for i := 1; i != k; i++ {
		x += 2
		if x > n {
			x = 2
		}
	}

	fmt.Println(x)
}


package main

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

var scanner *bufio.Scanner

func getI64() int64 {
  scanner.Scan()
  x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
  return x
}
func getI() int {
  return int(getI64())
}
func getF() float64 {
  scanner.Scan()
  x, _ := strconv.ParseFloat(scanner.Text(), 64)
  return x
}
func getS() string {
  scanner.Scan()
  return scanner.Text()
}

func main() {
  scanner = bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()

  n, m, a, b := getI(), getI(), getI(), getI()
  a--
  b--
  p, q := a%m, b%m
  result := 3
  if a/m == b/m || (p == 0 && (q == m-1 || b == n-1)) {
    result = 1
  } else if a/m + 1 == b/m || p == 0 || q == m-1 || b == n-1 {
    result = 2
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

import (
	"fmt"
)

func main() {
	var a, m int
	fmt.Scan(&a, &m)
	var v [10010]bool
	for {
		if v[a] {
			fmt.Println("NO")
			return
		}
		if a%m == 0 {
			fmt.Println("YES")
			return
		}
		v[a] = true
		a = (a + a%m) % m
	}
}


package main

import (
	"fmt"
)

func main() {
	var a, m int
	fmt.Scan(&a, &m)
	var v [10010]bool
	for {
		if v[a] {
			fmt.Println("No")
			return
		}
		if a%m == 0 {
			fmt.Println("Yes")
			return
		}
		v[a] = true
		a = (a + a%m) % m
	}
}


//package main
import "fmt"
func main(){
    a,m:= 0,1
    ma:=make(map[int]int)
    fmt.Scan(&a,&m)
    for true{
        _,ok:=ma[a];
        if ok{
            break
        }
        ma[a]=1;
        a*=2
        a%=m;
    }
    if _,ok:=ma[0];ok{
        fmt.Println("Yes")
    } else{
        fmt.Println("No")
    }
}


// 75A-mic
package main

import (
    "fmt"
)

func rem(x int64) int64 {
    var rr, r int64
    for x > int64(0) {
        if x%10 != 0 {
            rr *= 10
            rr += x % 10
        }
        x /= 10
    }

    r = 0
    for rr > int64(0) {
        r *= 10
        r += rr % 10
        rr /= 10
    }
    return r
}

func main() {
    var a, b,c int64
    fmt.Scan(&a, &b)
    c = a + b
    fmt.Println(rem(c))
    fmt.Println(rem(a))
    fmt.Println(rem(b))
    if rem(c) == rem(a)+rem(b) {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }

}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF87C(in io.Reader, out io.Writer) {
	n := 0
	Fscan(in, &n)

	type pair struct{ a0, len int }
	const mx = 1e5
	ps := [mx + 1][]pair{}
	for l := 2; l*(l+1)/2 <= mx; l++ {
		for a0 := 1; ; a0++ {
			s := (2*a0 + l - 1) * l / 2
			if s > mx {
				break
			}
			ps[s] = append(ps[s], pair{a0, l})
		}
	}
	sgs := [mx + 1]int{}
	for i := 3; i <= n; i++ {
		mex := map[int]bool{}
		for _, p := range ps[i] {
			s := sgs[p.a0] ^ sgs[p.a0+p.len]
			if i == n && s == 0 {
				Fprint(out, p.len)
				return
			}
			mex[s] = true
		}
		sg := 0
		for ; mex[sg]; sg++ {
		}
		sgs[i+1] = sgs[i] ^ sg
	}
	Fprint(out, -1)
}

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


package main

import "os"
import "bufio"
import "strconv"

func main(){
	var r1, r2 int
	var c1, c2 int
	var d1, d2 int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	r1, _= strconv.Atoi(r.Text())
	r.Scan()
	r2, _= strconv.Atoi(r.Text())
	r.Scan()
	c1, _= strconv.Atoi(r.Text())
	r.Scan()
	c2, _= strconv.Atoi(r.Text())
	r.Scan()
	d1, _= strconv.Atoi(r.Text())
	r.Scan()
	d2, _= strconv.Atoi(r.Text())

	var a, b, c, d int
	a = (r1+c1-d2)/2
	d = d1-a
	b = c2-d
	c = r2-d

	if a < 1 || b < 1 || c < 1 || d < 1 || a > 9 || b > 9 || c > 9 || d > 9 || a == b || a == c || a == d || b == c || b == d || c == d {
		w.WriteString("-1\n")
		w.Flush()
	} else {
		w.WriteString(strconv.Itoa(a)+" "+strconv.Itoa(b)+"\n")
		w.Flush()
		w.WriteString(strconv.Itoa(c)+" "+strconv.Itoa(d)+"\n")
		w.Flush()
	}
}


package main

import "fmt"

func main() {
    var r1,r2,c1,c2,d1,d2 int
    fmt.Scan(&r1,&r2,&c1,&c2,&d1,&d2)
    b := (d2+r1-c1)/2
    c := d2-b
    a := c1-c
    d := r2-c
    f := func(n int) bool {
        if (n >= 1) && (n <= 9) { return true }
        return false
    }
    if (a != b) && (a != c) && (a != d) && (b != c) && (b != d) && (c != d) && f(a) && f(b) && f(c) && f(d) {
        fmt.Println(a,b)
        fmt.Println(c,d)
    } else {
        fmt.Println(-1)
    }
}


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 n int
	for I(&n, " ") == nil {
		solve(n)
	}
}

func solve(n int) {
	var m int
	I(&m, "\n")
	max := int64(n - (m - 1))
	min := int64(n / m)
	if n%m == 0 {
		min = C(int(min)) * int64(m)
	} else {
		min = C(int(min))*int64(m-1) + C(int(min)+n%m)
	}
	max = C(int(max))
	O(min, " ")
	O(max, "\n")
}

func C(a int) int64 {
	return int64(a) * int64(a-1) / int64(2)
}


package main

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

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)

	n, m := int64(nextInt()), int64(nextInt())

	if n % m == 0 {
		println(pair(n/m) * m, pair(n-m+1))
	} else {
		println(pair(n/m) * (m-1) + pair(n/m + (n%m)), pair(n-m+1))
	}

	// println(n)
}

func pair(n int64) int64 {
	return n * (n-1) / 2
}

func next() string {
	if !scanner.Scan() {
		panic("Scan error")
	}
	return scanner.Text()
}

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

func nextFloat() float64 {
	n, err := strconv.ParseFloat(next(), 64)
	if err != nil {
		panic(err)
	}
	return n
}

func println(a ...interface{}) {
	fmt.Fprintln(writer, a...)
}


package main

import (
	"fmt"
)

func main() {
	var n, m int64
	fmt.Scan(&n, &m)
	max := n - m + 1
	min := n / m
	if min == 1 && n%m > 0 {
		min++
	}
	pair := func(x int64) int64 {
		return x * (x - 1) / 2
	}
	fmt.Println(pair(max), pair(min))
}


package main

import (
	"fmt"
)

func main() {
	var n, m int64
	fmt.Scanf("%d %d", &n, &m)
	var min int64 = 0
	nn := n
	mm := m
	for m > 0 {
		if (n % m == 0) {
			x := n / m
			min += m * x * (x - 1) / 2
			m = 0
		} else {
			x := n / m
			min += x * (x - 1) / 2
			n -= x
			m--
		}
	}
	x := nn - mm + 1
	max := x * (x - 1) / 2
	fmt.Printf("%d %d\n", min, max)
}


package main

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

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

func main() {
	var s, x1, x2, t1, t2, p, d int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &s, &x1, &x2, &t1, &t2, &p, &d)
	best := mabs(x1-x2) * t2
	traintime := 0
	if d == 1 {
		if p <= x1 {
			traintime = (x1 - p) * t1
		} else {
			traintime = (s-p)*t1 + (s-x1)*t1
			d = -1
		}
	} else {
		if p >= x1 {
			traintime = (p - x1) * t1
		} else {
			traintime = (p * t1) + (x1 * t1)
			d = 1
		}
	}
	if d == 1 {
		if x1 < x2 {
			traintime += (x2 - x1) * t1
		} else {
			traintime += (s-x1)*t1 + (s-x2)*t1
		}
	} else {
		if x2 < x1 {
			traintime += (x1 - x2) * t1
		} else {
			traintime += x1*t1 + x2*t2
		}
	}
	if traintime < best {
		best = traintime
	}
	fmt.Println(best)
}


package main

import "fmt"

func main() {
	var s, x1, x2, t1, t2, p, d int
	fmt.Scan(&s, &x1, &x2, &t1, &t2, &p, &d)
	byFoot := abs(x1-x2) * t2
	wT := abs(p-x1) * t1
	if x1 < p {
		if d == 1 {
			wT += 2 * (s - p) * t1
			d = -1
		}
	} else {
		if d == -1 {
			wT += 2 * p * t1
			d = 1
		}
	}
	tT := abs(x1-x2) * t1
	if x1 < x2 {
		if d == -1 {
			tT += 2 * x1 * t1
		}
	} else {
		if d == 1 {
			tT += 2 * (s - x1) * t1
		}
	}

	byTrain := tT + wT
	fmt.Println(min(byFoot, byTrain))
}

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

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