package main

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

func readInt(bytes []byte, from int, val *int) int {
	i := from
	sign := 1
	if bytes[i] == '-' {
		sign = -1
		i++
	}
	tmp := 0
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + int(bytes[i]-'0')
		i++
	}
	*val = tmp * sign
	return i
}

func readNum(reader *bufio.Reader) (a int) {
	bs, _ := reader.ReadBytes('\n')
	readInt(bs, 0, &a)
	return
}

func readTwoNums(reader *bufio.Reader) (a int, b int) {
	res := readNNums(reader, 2)
	a, b = res[0], res[1]
	return
}

func readThreeNums(reader *bufio.Reader) (a int, b int, c int) {
	res := readNNums(reader, 3)
	a, b, c = res[0], res[1], res[2]
	return
}

func readNNums(reader *bufio.Reader, n int) []int {
	res := make([]int, n)
	x := 0
	bs, _ := reader.ReadBytes('\n')
	for i := 0; i < n; i++ {
		for x < len(bs) && (bs[x] < '0' || bs[x] > '9') && bs[x] != '-' {
			x++
		}
		x = readInt(bs, x, &res[i])
	}
	return res
}

func readUint64(bytes []byte, from int, val *uint64) int {
	i := from

	var tmp uint64
	for i < len(bytes) && bytes[i] >= '0' && bytes[i] <= '9' {
		tmp = tmp*10 + uint64(bytes[i]-'0')
		i++
	}
	*val = tmp

	return i
}

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

	n, k := readTwoNums(reader)

	fmt.Println(solve(n, k))
}

const MAX_N = 500043
const MOD = 998244353

var F []int64

// var PM []int

func pow(a, b int64) int64 {
	var r int64 = 1
	for b > 0 {
		if b&1 == 1 {
			r *= a
			r %= MOD
		}
		a *= a
		a %= MOD
		b >>= 1
	}
	return r
}

func init() {
	F = make([]int64, MAX_N)
	F[0] = 1

	for i := 1; i < MAX_N; i++ {
		F[i] = int64(i) * F[i-1]
		F[i] %= MOD
	}
}

func IF(n int) int64 {
	x := F[n]
	return pow(x, MOD-2)
}

func nCr(n, r int) int64 {
	if n < r {
		return 0
	}
	res := F[n]
	res *= IF(r)
	res %= MOD
	res *= IF(n - r)
	res %= MOD
	return res
}

func solve(n, k int) int {
	var res int64

	for x := 1; x <= n; x++ {
		// x := PM[i]
		d := n / x
		if d < k {
			break
		}
		res += nCr(d-1, k-1)
		res %= MOD
	}

	return int(res)
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	sum := 0
	max := 0
	for i := 0; i < n; i++ {
		var a int
		fmt.Scan(&a)
		sum += a
		if max < a {
			max = a
		}
	}
	k := max
	for k*n-sum <= sum {
		k++
	}
	fmt.Println(k)
}


package main

import (
	"fmt"
)

func main() {
	var N int
	var A [110]int

	fmt.Scan(&N)
	for i := 0; i < N; i++ {
		fmt.Scan(&A[i])
	}

	sum, max := 0, 0
	for i := 0; i < N; i++ {
		sum += A[i]
		if max < A[i] {
			max = A[i]
		}
	}

	res := (2 * sum / N) + 1
	if res < max {
		res = max
	}

	fmt.Printf("%v\n", res)
}


package main

import "fmt"

func main() {
	var count int
	var point_war int
	sum_war := 0
	var sum_my int
	min_k := 0
	fmt.Scan(&count)
	var points [150]int
	var result int
	for i := 0; i < count; i++ {
		fmt.Scan(&point_war)
		points[i] = point_war
		sum_war += point_war
		if point_war > min_k {
			min_k = point_war
		}
	}
	for i := min_k; i <= 210; i++ {
		sum_my = 0
		for j := 0; j < count; j++ {
			sum_my += i - points[j]
		}
		if sum_my > sum_war {
			result = i
			break
		}
	}
	fmt.Println(result)
}


package main

import (
	"fmt"
	// "os"
	)

const INF = 0x3f3f3f3f

var n, m, tot int

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

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

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

func main() {
	// fd, _ := os.Open("in.txt")
	// os.Stdin = fd
	var T int = 1
	// fmt.Scanf("%d", &T)
	for ci:=1; ci<=T; ci++ {
		var l, r int
		fmt.Scanf("%d %d %d %d\n", &n, &m, &l, &r)
		// fmt.Printf("Case #%d: ", ci)
		if l==1 && r==n {
			fmt.Println(0)
		} else if l==1 {
			if m<=r {
				fmt.Println(1+r-m)
			} else {
				fmt.Println(1-r+m)
			}
		} else if r==n {
			if m<l {
				fmt.Println(1+l-m)
			} else {
				fmt.Println(1-l+m)
			}
		} else {
			mid := (l+r)>>1
			if m<=mid {
				fmt.Println(r+2-l+abs(m-l))
			} else {
				fmt.Println(r+2-l+abs(r-m))
			}
		}
	}
}


package main

/*
	If we breakdown the problem, we will found 3 cases:
	- if non-studies tabs exist both in left & right of studies tabs: 1, [2, 3, 4, 5], 6
	- if non-studies tabs exist only in right of studies tabs: [1, 2, 3], 4, 5, 6
	- if non-studies tabs exist only in left of studies tabs: 1, 2, 3, [4, 5, 6]

	For the first case the minimum number of seconds would be:
		min(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1
	In the second case:
		abs(pos-r) + 1
	In the third case:
		abs(pos-l) + 1
*/

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

func main() {
	var n, pos, l, r int
	stdin := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdin, "%d %d %d %d", &n, &pos, &l, &r)
	fmt.Println(solve(n, pos, l, r))
}

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

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

func solve(n, pos, l, r int) int {
	isLeftExist := abs(1-l) > 0
	isRightExist := abs(r-n) > 0
	if isLeftExist && isRightExist {
		return min(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1
	} else if isRightExist {
		return abs(pos-r) + 1
	} else if isLeftExist {
		return abs(pos-l) + 1
	}
	return 0
}


// http://codeforces.com/contest/915/problem/B
package main

import "fmt"

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

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

// comentar que nem gente
func main() {
	var n, pos, l, r int
	fmt.Scanf("%d %d %d %d\n", &n, &pos, &l, &r)
	if l == 1 && r == n {
		fmt.Printf("0\n")
	} else if l == 1 {
		fmt.Printf("%d\n", abs(r - pos) + 1)
	} else if r == n {
		fmt.Printf("%d\n", abs(l - pos) + 1)
	} else {
		if abs(l - pos) < abs(r - pos) {
			fmt.Printf("%d\n", abs(l - pos) + r - l + 2)
		} else {
			fmt.Printf("%d\n", abs(r - pos) + r - l + 2)
		}
	}
}


package main

import "fmt"

func main() {
	var n, x int
	a := make(map[int]bool)
	fmt.Scan(&n)
	for ; n > 0; n-- {
		fmt.Scan(&x)
		if x > 0 {
			a[x] = true
		}
	}
	fmt.Print(len(a))
}


package main

import ("fmt";
		"sort")

type set map[int]bool
type long int64

func main(){
	var n, ans int
	scan(&n)
	s := make(set)
	for i := 0; i < n; i++{
		var t int
		scan(&t)
		s[t] = true
	}
	a := make([]int, len(s))
	p := 0
	for k,_ := range s{
		a[p] = k
		p++
	}
	sort.Ints(a)
	for _,k := range a{
		if k > 0{ans++}
	}
	sout(ans)
}

func scan(in ... interface{}){
	for _,k := range in{
		fmt.Scan(k)
	}
}

func sout(obj ... interface{}){
	for _, k := range obj{
		fmt.Print(k)
	}
	fmt.Println()
}


package main

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

var scanner *bufio.Scanner
var t [1e6 + 1]bool

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

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

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

func main() {
	init_scanner()
	size, ans := readInt(), 0
	m := make(map[int]bool)
	for i := 0; i < size; i++ {
		x := readInt()
		if x > 0 && !m[x] {
			ans += 1
			m[x] = true
		}
	}
	fmt.Println(ans)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	t := 1
	//fmt.Fscanf(in, "%d\n", &t)
	for tt := 0; tt < t; tt++ {
		n := int64(0)
		fmt.Fscanf(in, "%d\n", &n)
		ans := 10
		curNum := int64(1)
		for i := 2; i < 100; i++ {
			if curNum >= n {
				break
			}
			for j := 0; j < 10; j++ {
				if curNum >= n {
					break
				}
				curNum /= int64(i - 1)
				curNum *= int64(i)
				ans++
			}
		}
		a := "codeforces"
		ansS := []byte{}
		for i := 0; i < 10; i++ {
			for j := 0; j < ans/10; j++ {
				ansS = append(ansS, a[i])
			}
			if i+1 <= ans%10 {
				ansS = append(ansS, a[i])
			}
		}
		fmt.Fprintf(out, "%s\n", string(ansS))
	}
	return
}

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

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


package main

import (
	. "fmt"
	. "strings"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var k, n int64 = 0, 3
	Scan(&k)
	for {
		s := int64(1)
		for i := int64(0); i < 10; i++ {
			s *= (n + i) / 10
		}
		if s >= k {
			break
		}
		n++
	}
	for i, b := range "codeforces" {
		Print(Repeat(string(b), (int(n)+9-i)/10))
	}
}


/*
URL:
https://codeforces.com/problemset/problem/1368/B
*/

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 (
	k int64
)

func main() {
	k = ReadInt64()

	A := make([]int, 10)
	for i := 0; i < 10; i++ {
		A[i] = 1
	}

	for i := 0; i < 100000; i++ {
		val := int64(1)
		for _, a := range A {
			val *= int64(a)
		}

		if val >= k {
			break
		}

		A[i%10]++
	}

	ans := []rune{}
	memo := []rune("codeforces")
	for i := 0; i < 10; i++ {
		for j := 0; j < A[i]; j++ {
			ans = append(ans, memo[i])
		}
	}
	fmt.Println(string(ans))
}

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

/*********** 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"
	"os"
	"strconv"
)

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

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

	s, t := next(), next()
	pos1, pos2 := 0, 0
	cntMark := 0
	cntEqual := 0

	for i := range s {
		if s[i] == '+' {
			pos1++
		} else {
			pos1--
		}
	}

	for i := range t {
		switch t[i] {
		case '+':
			pos2++
		case '-':
			pos2--
		case '?':
			cntMark++
		}
	}
	// println(pos1, pos2, cntMark, s, t)
	permutation := 1 << uint64(cntMark)
	for k := 0; k < permutation; k++ {
		cnt := 0
		// println(k, cntMark)
		for i := 0; i < cntMark; i++ {
			// println(i, i&k)
			if (1<<uint64(i))&k > 0 {
				cnt++
			} else {
				cnt--
			}
		}
		// println(pos2, cnt, pos1)
		if pos2+cnt == pos1 {
			cntEqual++
		}
	}
	// println(permutation)
	println(float64(cntEqual)/float64(permutation))
}

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

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

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 printf(format string, a ...interface{}) {
	fmt.Fprintf(writer, format, a...)
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF476B(in io.Reader, out io.Writer) {
	var s, t string
	Fscan(in, &s, &t)
	p := Count(s, "+") - Count(s, "-") - Count(t, "+") + Count(t, "-")
	n := Count(t, "?")
	c := 0
	for sub := 0; sub < 1<<n; sub++ {
		s := 0
		for i := 0; i < n; i++ {
			if sub>>i&1 == 0 {
				s--
			} else {
				s++
			}
		}
		if s == p {
			c++
		}
	}
	Fprintf(out, "%.12f", float64(c)/float64(int(1)<<n))
}

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


//https://codeforces.com/problemset/problem/476/B
//http://bigocoder.com/courses/ORANGE03/ORANGE03_LEC03/ORANGE_L03P05/statement
package main

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

func solve(c int, n int) float64 {
	total := math.Pow(2, float64(n))
	p := permutation(c, n)

	//right permutation answer / total permutation
	return p / total
}

func permutation(c int, n int) float64 {
	return factorial(n) / (factorial(n-c) * factorial(c))
}

func factorial(n int) float64 {
	res := 1
	for i := 1; i <= n; i++ {
		res *= i
	}

	return float64(res)
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var command, received string
	var unrecognizedSignal int
	flag := true
	fmt.Fscanf(r, "%s\n", &command)
	fmt.Fscanf(r, "%s\n", &received)
	cache := map[byte]int{}

	for i := range command {
		cache[command[i]]++
	}

	for i := range received {
		if received[i] == '?' {
			unrecognizedSignal++
		} else {
			cache[received[i]]--
		}
	}

	for _, v := range cache {
		if v < 0 {
			flag = false
			break
		}
	}

	if flag {
		if unrecognizedSignal > 0 {
			fmt.Fprintf(os.Stdout, "%.10f\n", solve(cache['+'], unrecognizedSignal))

		} else {
			fmt.Fprintf(os.Stdout, "%.10f\n", float64(1))
		}
	} else {
		fmt.Fprintf(os.Stdout, "%.10f\n", float64(0))
	}

}


package main

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

func main() {
	var target int = 0
	var start int = 0
	var question_marks int = 0

	reader := bufio.NewReader(os.Stdin)
	// Command
	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		for i := 0; i < len(s); i++ {
			if s[i] == '+' {
				target++
			} else if s[i] == '-' {
				target--
			}
		}
	}

	// Received
	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		for i := 0; i < len(s); i++ {
			if s[i] == '+' {
				start++
			} else if s[i] == '-' {
				start--
			} else if s[i] == '?' {
				question_marks++
			}
		}
	}

	var distance int = int(math.Abs(float64(target - start)))
	var prob float64
	if distance > question_marks {
		prob = 0.0
	} else if distance == question_marks {
		prob = math.Pow(0.5, float64(question_marks))
	} else { // distance < question_marks
		if (question_marks-distance)%2 != 0 {
			prob = 0.0
		} else {
			towards := distance + (question_marks-distance)/2
			prob = float64(factorial(question_marks)) /
				float64(factorial(towards)*factorial(question_marks-towards)*
					(1<<uint(question_marks)))
		}
	}

	fmt.Printf("%0.12f\n", prob)
}

func factorial(n int) int64 {
	if n <= 1 {
		return int64(n)
	} else {
		return int64(n) * factorial(n-1)
	}
}


package main

import "fmt"

func pow(x, n int) int {
	result := 1
	for i := 0; i < n; i++ {
		result *= x
	}
	return result
}

func main() {
	var s1, s2 string
	var ask, finish, current int
	fmt.Scan(&s1, &s2)
	for i := 0; i < len(s1); i++ {
		if s1[i] == '+' {
			finish += 1
		} else {
			finish -= 1
		}

		switch s2[i] {
		case '+':
			current += 1
		case '-':
			current -= 1
		case '?':
			ask += 1
		}
	}
	if ask == 0 {
		if finish == current {
			fmt.Println(1)
			return
		} else {
			fmt.Println(0)
			return
		}
	}
	power := pow(2, ask)
	res := 0
	for i := 0; i < power; i ++ {
		sum := 0
		for j := 0; j < ask; j++ {
			if i&pow(2, j) > 0 {
				sum += 1
			} else {
				sum -= 1
			}
		}
		if finish == current+sum {
			res += 1
		}
	}
	fmt.Println(float64(res) / float64(power))
}


package main

import (
	"fmt"
)

func fact(x int64) int64 {
	if x == 0 {
		return 1
	}
	return fact(x-1) * x
}

func combi(n, r int64) int64 {
	return fact(n) / fact(n-r) / fact(r)
}

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	var ans, move, unknown, diff, reverse int64
	for _, r := range a {
		switch r {
		case '+':
			ans++
		case '-':
			ans--
		}
	}
	for _, r := range b {
		switch r {
		case '+':
			move++
		case '-':
			move--
		case '?':
			unknown++
		}
	}
	diff = ans - move
	if diff < 0 {
		diff = -diff
	}
	if diff > unknown || (diff-unknown)%2 > 0 {
		fmt.Println("0")
		return
	}
	reverse = (unknown - diff) / 2
	if reverse < 0 {
		reverse = -reverse
	}
	fmt.Printf("%.11f\n", float64(combi(unknown, reverse))/float64(int(1)<<uint(unknown)))
}


package main

import (
	. "fmt"
	. "strings"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var s, t string
	Scan(&s, &t)
	p := Count(s, "+") - Count(s, "-") - Count(t, "+") + Count(t, "-")
	n := Count(t, "?")
	c := 0
	for sub := 0; sub < 1<<n; sub++ {
		s := 0
		for i := 0; i < n; i++ {
			if sub>>i&1 == 0 {
				s--
			} else {
				s++
			}
		}
		if s == p {
			c++
		}
	}
	Printf("%.12f", float64(c)/float64(int(1)<<n))
}


/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

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 (
	a, b, x, n int64
)

// ↓でもいい
func main() {
	a, b, n, x = ReadInt64_4()

	A := [][]int64{
		[]int64{a + 1, NegativeMod(-a, MOD)},
		[]int64{1, 0},
	}

	AK := powMat(A, n-1, MOD)

	ans := int64(0)

	big := (a*x + b) % MOD
	big *= AK[0][0]
	ans += big
	ans %= MOD

	sml := AK[0][1]
	sml *= x
	sml %= MOD
	ans += sml
	ans %= MOD

	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

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

/*********** 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...)
}


/*
URL:
https://codeforces.com/problemset/problem/678/D
*/

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 (
	a, b, x, n int64
)

func main() {
	a, b, n, x = ReadInt64_4()

	// A := [][]int64{
	// 	[]int64{a + 1, -a},
	// 	[]int64{1, 0},
	// }
	A := [][]int64{
		[]int64{a + 1, NegativeMod(-a, MOD)},
		[]int64{1, 0},
	}

	AK := powMat(A, n-1, MOD)

	ans := int64(0)

	big := (a*x + b) % MOD
	big *= AK[0][0]
	ans += big
	ans %= MOD

	sml := AK[0][1]
	sml *= x
	sml %= MOD
	ans += sml
	ans %= MOD

	fmt.Println(ans)
}

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

// n*nのint型正方行列を生成する
func newMat(n int64) [][]int64 {
	var i int64

	A := make([][]int64, n)
	for i = 0; i < n; i++ {
		A[i] = make([]int64, n)
	}

	return A
}

// 行列A, Bに関するA*Bの計算
func mul(A, B [][]int64, mod int64) [][]int64 {
	var i, j, k int64
	var lenA, lenB, lenB0 int64
	lenA = int64(len(A))
	lenB = int64(len(B))
	lenB0 = int64(len(B[0]))

	C := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		C[i] = make([]int64, lenB0)
	}

	for i = 0; i < lenA; i++ {
		for k = 0; k < lenB; k++ {
			for j = 0; j < lenB0; j++ {
				C[i][j] = (C[i][j] + A[i][k]*B[k][j]) % mod
			}
		}
	}

	return C
}

// 行列Aに関するA^nの計算
func powMat(A [][]int64, n, mod int64) [][]int64 {
	var i int64
	var lenA int64
	lenA = int64(len(A))

	B := make([][]int64, lenA)
	for i = 0; i < lenA; i++ {
		B[i] = make([]int64, lenA)
	}

	for i = 0; i < lenA; i++ {
		B[i][i] = 1
	}
	for n > 0 {
		if n&1 == 1 {
			B = mul(B, A, mod)
		}
		A = mul(A, A, mod)
		n = (n >> 1)
	}

	return B
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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


package main

import (
	"fmt"
)

func main() {
	var n int
	var str string

	fmt.Scan(&n)
	fmt.Scan(&str)

	var cnt int = 0
	for i := 0; i < n; i++ {
		if str[i] == '0' {
			cnt++
		}
	}

	var retstr string = ""
	if n - cnt == 0 {
		retstr = "0"
	} else if cnt == 0 {
		retstr = "1"
	} else {
		retstr = "1"
		for cnt != 0 {
			retstr = retstr + "0"
			cnt--
		}
	}

	fmt.Println(retstr)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var (
		n int
		s []byte
	)

	fmt.Scanln(&n)
	fmt.Scanln(&s)

	cnt := 0
	zeroes := 0
	for i := 0; i < n; i++ {
		if s[i] == '1' {
			cnt++
		} else {
			zeroes++
		}
	}

	for i := 0; i < 200; i++ {
		cnt = int(math.Ceil(float64(cnt) / 2.0))
	}

	// for i := n - 1; i > 0; i-- {
	// 	for j := n - 1; j > 0; j-- {
	// 		if s[j] == '0' {
	// 			s[j], s[j-1] = s[j-1], s[j]
	// 		}
	// 	}
	// }

	if cnt == 0 {
		fmt.Println("0")

		return
	}

	res := ""
	for i := 0; i < cnt; i++ {
		res += "1"
	}

	for i := 0; i < zeroes; i++ {
		res += "0"
	}

	fmt.Println(res)
}


package main

import (
	"fmt"
	"os"
)

func main() {
	var a, count0,count1 int
	var s string
	fmt.Scanf("%d\n", &a)
	fmt.Scanf("%s\n", &s)
	for _, v := range s{
		if v == '0'{
			count0++
		} else if v == '1'{
			count1++
		}
	}
	if count0 == 1 && count1 == 0{
		fmt.Println(0)
		os.Exit(0)
	}
	var ss = "1"
	for i:=0;i<count0;i++{
		ss+="0"
	}
	fmt.Println(ss)
}


package main

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

func main() {
    //io
    scanner := bufio.NewReader(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    //---
    var s string
    fmt.Fscan(scanner, &s)

    cnt := strings.Count(s, "Danil") + strings.Count(s, "Olya")
    cnt += strings.Count(s, "Slava") + strings.Count(s, "Ann") + strings.Count(s, "Nikita")
    if(cnt == 1) {
        writer.WriteString("YES")
    } else {
        writer.WriteString("NO")
    }
    writer.Flush()
}


package main
import (
	"fmt"
)

func main(){
	var str string
	fmt.Scanf("%s\n", &str)
	var dest = [5]string {"Danil", "Olya", "Slava", "Ann" ,"Nikita"}
	sum := 0
	for i := 0; i < 5; i++{
		sum += matchStr(str, dest[i])
	}
	if sum == 1{
		fmt.Println("YES")
	}else{
		fmt.Println("NO")
	}
}

func matchStr(src string, dest string) int{
	sum := 0
	for i := 0; i + len(dest) - 1 < len(src); i++{
		flag := true
		for j := 0; j < len(dest); j++{
			if src[i + j] != dest[j]{
				flag = false
			}
		}
		if flag {
			sum++
		}
	}
	return sum
}


package main

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

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

	var s string
	Fscan(in, &s)
	c := 0
	for _, name := range []string{"Danil", "Olya", "Slava", "Ann", "Nikita"} {
		c += strings.Count(s, name)
	}
	if c == 1 {
		Fprintln(out, "YES")
	} else {
		Fprintln(out, "NO")
	}
}

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


package main

import "fmt"

func main() {
    var h,m int
    fmt.Scanf("%d:%d\n",&h,&m)
    for {
        m++
        if m > 59 {
            m = 0
            h++
            if h > 23 { h = 0 }
        }
        if (h%10 == m/10) && (h/10 == m%10) { break }
    }
    fmt.Printf("%02d:%02d\n",h,m)
}


// 108A-mic_rizal
package main

import (
    "fmt"
    "strconv"
    "strings"
)

func check(h, m int) bool {
    if h%10 == m/10 && h/10 == m%10 {
        return true
    }
    return false
}

func main() {
    var h, m int
    var s string
    fmt.Scan(&s)
    k := strings.SplitN(s, ":", 2)
    h, _ = strconv.Atoi(k[0])
    m, _ = strconv.Atoi(k[1])
    for {
        m++
        if m == 60 {
            h++
            m = 0
        }
        if h == 24 {
            h = 0
        }
        if check(h, m) {
            break
        }
    }

    if h < 10 {
        fmt.Print("0")
        fmt.Print(h)
        fmt.Print(":")
    } else {
        fmt.Print(h)
        fmt.Print(":")
    }
    if m < 10 {
        fmt.Print("0")
        fmt.Print(m)
    } else {
        fmt.Print(m)
    }
    fmt.Println()
}


package main

import "fmt"
import "os"

func main(){
	var a , b , c , d int
	fmt.Scanf("%d%d\n" , &a , &b)
	fmt.Scanf("%d%d" , &c , &d)
	for i:=0 ; i<=110 ; i++ {
		if (b+i*a-d) % c == 0 && b+i*a-d >= 0 {
			fmt.Printf("%d\n" ,b+i*a)
			os.Exit(0)
		}
	}
	fmt.Printf("-1\n")
}


package main

import (
	"fmt"
)

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

	offset := make(map[int]bool)

	for i := 0; ; i++ {
		t := i*a + b
		if t-d >= 0 {
			if (t-d)%c == 0 {
				fmt.Println(t)
				return
			}
			l := (t - d) / c
			off := t - (l*c + d)
			if offset[off] {
				break
			} else {
				offset[off] = true
			}
		}
	}

	fmt.Println(-1)
}


package main

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

func solve() {
	a := readInt()
	b := readInt()
	c := readInt()
	d := readInt()
	for i := 0; i < 100000; i++ {
		if i >= b && i >= d {
			if (i-b)%a == 0 && (i-d)%c == 0 {
				fmt.Println(i)
				return
			}
		}
	}
	fmt.Println(-1)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main
import "fmt"
func main(){
    var n,i,k,sum,c int32
    fmt.Scanln(&n,&k)
    for i=1;i<=n;i++{
        var a int32
        fmt.Scanf("%d",&a)
        if a>8{
            sum=sum+a-8
            c=c+8
        }else{
			if a+sum>8{
       		    sum=sum-8+a
         	   	c=c+8
      		}else{
            	c=c+a+sum
            	sum=0
        	}
		}
        if (c>=k){
            break
    	}
    }
    if c>=k{
        fmt.Println(i)
    }else{
        fmt.Println(-1)
    }
}


package main

import "fmt"

func main() {
    var n, k int
    fmt.Scan(&n, &k)
    minDays := 0
    for candyAtHand, i:= 0,0; i<n; i++ {
        var candyReceived int
        fmt.Scan(&candyReceived)
        candyAtHand += candyReceived
        if k > 0 {
            if candyAtHand >= 8 {
                k -= 8
                candyAtHand -= 8
            } else {
                k -= candyAtHand
                candyAtHand = 0
            }
        }
        if k <= 0 {
            minDays = i+1
            break
        }
    }
    if k <= 0 {
        fmt.Print(minDays)
    } else {
        fmt.Print(-1)
    }
}


package main

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

func solve() {
	n := readInt()
	k := readInt()
	cur := 0
	for i := 0; i < n; i++ {
		cur += readInt()
		if cur >= 8 {
			k -= 8
			cur -= 8
		} else {
			k -= cur
			cur = 0
		}
		if k <= 0 {
			fmt.Println(i + 1)
			return
		}
	}
	fmt.Println(-1)
}

var scanner *bufio.Scanner

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

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

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

// IO

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

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

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

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

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


package main

import (
        "fmt"
)

var s string
var num int
var str [120]string

func main() {
        fmt.Scan(&s)
        fmt.Scan(&num)
        for i := 0; i < num; i++ {
                fmt.Scan(&str[i])
        }
        for i := 0; i < num; i++ {
                if str[i] == s {
                        fmt.Println("YES")
                        return
                }
                for j := 0; j < num; j++ {
                        if str[i][0] == s[1] && str[j][1] == s[0] {
                                fmt.Println("YES")
                                return
                        }
                }
        }
        fmt.Println("NO")
}


package main

import (
    "fmt"
)

func main(){
    var target string
	_, err := fmt.Scanln(&target)
	if err != nil {
		fmt.Println(err)
		return
	}

    var count, first, second int
	_, err = fmt.Scanln(&count)
	if err != nil {
		fmt.Println(err)
		return
	}

    for i:=0; i < count; i++{
        var word string
		_, err = fmt.Scanln(&word)
		if err != nil {
			fmt.Println(err)
			return
		}

		if word == target {
			fmt.Println("YES")
			return
		}
        hasFirst := word[0] == target[1]
        hasSecond := word[1] == target[0]

        if hasFirst{
            first++
        }
        if hasSecond{
            second++
        }
    }
    if first > 0 && second > 0 {
        fmt.Println("YES")
    }else{
    fmt.Println("NO")
}
}


package main

import (
	"fmt"
)

func main() {
	var (
		password string
		words    int
		fi, se   bool
	)

	fmt.Scan(&password)
	fmt.Scan(&words)

	for i := 0; i < words; i++ {
		var word string
		fmt.Scan(&word)

		if word == password {
			fmt.Print("YES\n")
			return
		}

		if exist := word[0] == password[1]; exist {
			fi = true
		}
		if exist := word[1] == password[0]; exist {
			se = true
		}

		if fi && se {
			fmt.Print("YES\n")
			return
		}
	}

	fmt.Print("NO\n")
}


package main

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

func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	var n int
	var s []byte
	Fscan(in, &n, &s)

	if n == 1 {
		Fprintln(out, 0)
		return
	}
	s = append([]byte{0}, s...)
	s = append(s, 0)

	ans := 0
	//s2 := []byte{}
	//for i := byte('z'); i >= 'a'; i-- {
	//	lp := 0
	//	for j, b := range s {
	//		//if j > 0 && lc == 0 {
	//		//	lc = s[j-1]
	//		//}
	//		if b == i && (s[j]-1 == s[lp] || s[j]-1 == s[j+1]) {
	//			ans++
	//
	//		} else {
	//			s2 = append(s2, b)
	//			lp = j
	//		}
	//	}
	//	s = s2
	//	s2 = []byte{}
	//}

	for curB := byte('z'); curB >= 'a'; curB-- {
		for {
			del := false
			for i, b := range s {
				if b == curB && (s[i]-1 == s[i-1] || s[i]-1 == s[i+1]) {
					ans++
					del = true
					s = append(s[:i], s[i+1:]...)
				}
			}
			if !del {
				break
			}
		}
	}

	Fprintln(out, ans)
}

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


package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	rls := solve(n, s)
	fmt.Println(rls)
}

func solve(n int, s string) int {
	chs := []rune(s)
	for ch := 'z'; ch > 'a'; ch-- {
		for i := 1; i < len(chs); i++ {
			for i < len(chs) && chs[i] == ch && chs[i-1] == ch-1 {
				chs = append(chs[:i], chs[i+1:]...)
			}
		}
		for i := len(chs) - 2; i >= 0; i-- {
			if i+1 < len(chs) && chs[i] == ch && chs[i+1] == ch-1 {
				chs = append(chs[:i], chs[i+1:]...)
			}
		}
	}
	return len(s) - len(chs)
}


package main

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

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

	var n int
	fmt.Fscanf(r, "%d\n", &n)

	var s string
	fmt.Fscanf(r, "%s\n", &s)

	deleted := make(map[int]bool)

	count := 0
	for ch := byte('z'); ch >= 'a'; ch-- {
		for i, _ := range s {
			cur := s[i]
			if cur != ch {
				continue
			}

			can := false

			j := i
			for j >= 0 && (deleted[j] || s[j] == cur) {
				j--
			}
			if j >= 0 && s[j]+1 == cur {
				can = true
			}

			j = i
			for j < n && (deleted[j] || s[j] == cur) {
				j++
			}
			if j < n && s[j]+1 == cur {
				can = true
			}

			if can {
				deleted[i] = true
				count++
			}
		}
	}

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

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


package main

import "fmt"

func isVowel(c byte) bool {
    if c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' {
        return true
    } else {
        return false
    }
}

func main() {
    var s string
    fmt.Scanf("%s", &s)
    succ := true
    for i, c := range []byte(s) {
        cur := true
        if !isVowel(c) && c != 'n' {
            cur = (i < len(s) - 1) && isVowel(s[i+1])
        }
        if !cur {
            succ = false
        }
    }
    if succ {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


package main

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

func readLine(reader *bufio.Reader) string {
	line, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}
	return strings.TrimRight(string(line), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}

func main() {
	vowels := make(map[rune]int)
	var l rune
	for l = 'a'; l <= 'z'; l++ {
		if l == 'a' {
			vowels[l] = -1
		}
		if l == 'e' {
			vowels[l] = -1
		}
		if l == 'i' {
			vowels[l] = -1
		}
		if l == 'o' {
			vowels[l] = -1
		}
		if l == 'u' {
			vowels[l] = -1
		}
	}

	isBerlanese := true
	var word string
	fmt.Scanf("%s", &word)

	if len(word) > 1 {
		for i := 0; i < len(word)-1; i++ {
			if isBerlanese == false {
				break
			}
			letter := rune(word[i])
			nextLetter := rune(word[i+1])
			if letter == 'n' {
				continue
			}

			_, isVowel := vowels[letter]
			if isVowel == true {
				continue
			} else {
				_, nextIsVowel := vowels[nextLetter]
				if nextIsVowel == false {
					isBerlanese = false
					break
				}
			}
		}
	} else {
		letter := rune(word[0])
		if letter == 'n' {
			isBerlanese = true
		} else if _, V := vowels[letter]; V == true {
			isBerlanese = true
		} else {
			isBerlanese = false
		}
	}

	letter := rune(word[len(word)-1])
	if _, okay := vowels[letter]; !(okay == true || letter == 'n') {
		isBerlanese = false
	}
	if isBerlanese == true {
		fmt.Printf("%s\n", "YES")
	} else {
		fmt.Printf("%s\n", "NO")
	}
}


package main

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

func main() {
	vocal := map[string]bool{
		"a": true,
		"i": true,
		"u": true,
		"e": true,
		"o": true,
	}
	sc := bufio.NewScanner(os.Stdin)
	sc.Scan()
	word := sc.Text()
	for i := 0; i < len(word); i++ {
		// get status
		ch := string(word[i])
		isLast := (i == len(word)-1)
		isVocal := vocal[ch]
		isN := (ch == "n")
		// get next char
		nextCh := ""
		if !isLast {
			nextCh = string(word[i+1])
		}
		// infer if word is belanese
		if !isN && (!isVocal && !vocal[nextCh] || !isVocal && isLast) {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}


package main

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

func main() {
	var str string
	stdin := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdin, "%s", &str)
	shouldCheck := 0
	for i := 0; i < len(str); i++ {
		ch := string(str[i])
		num, err := strconv.Atoi(ch)
		if err != nil {
			if ch == "a" || ch == "i" || ch == "u" || ch == "e" || ch == "o" {
				shouldCheck++
			}
		} else {
			if num%2 != 0 {
				shouldCheck++
			}
		}
	}
	fmt.Println(shouldCheck)
}


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', '1', '3', '5', '7', '9':
			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 == 1 {
				ans++
			}
		} else {
			if strings.IndexByte("aeiou", s[i]) != -1 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


package main

import "fmt"

func main() {
	var n uint64
	fmt.Scan(&n)

	f := []uint64{1, 2}
	for i := 2; true; i++ {
		f = append(f, 0)
		f[i] = f[i-1] + f[i-2]
		if f[i] > n {
			fmt.Println(i - 1)
			break
		}
	}
}


package main

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

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

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

	if n == 2 {
		fmt.Fprint(w, 1)
		return
	}

	win := 0
	var a, b uint64 = 1, 2
	var c uint64
	for ; c <= n; win++ {
		c = a + b
		a, b = b, c
	}
	fmt.Fprintln(w, win)
}

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

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

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

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


package main

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

func solve() {
    n := readInt64()
    mx := 88
    mem := make([]int64, mx)
    mem[1], mem[2] = 2, 3
    for i := 3; i < mx; i++ {
        mem[i] = mem[i-1]+mem[i-2]
    }
    ans := 0
    for i, v := range mem {
        if n >= v {
            ans = i
        }
    }
    fmt.Println(ans)
}

// Helpers

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

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

// Math

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

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

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

// IO

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

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

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

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

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

// Sort

type Ints64 []int64

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

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


package main

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

func solve() bool {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	scanner.Scan()
	maj := scanner.Text()
	for i := 0; i < len(maj)-1; i++ {
		if maj[i] == maj[i+1] && maj[i] != '?' {
			return false
		}
	}
	// A?A -> Yes
	// A?B -> No
	for i := range maj {
		if maj[i] == '?' {
			if i == 0 || i == len(maj)-1 {
				return true
			}
			if maj[i-1] == '?' || maj[i+1] == '?' {
				return true
			}
			if maj[i-1] == maj[i+1] {
				return true
			}
		}
	}
	return false
}

func main() {
	if solve() {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main
import "fmt"
func main(){
	var(
		n int
		s string
	)
	fmt.Scan(&n,&s)
	for i:=0;i<n-1;i++{
		if s[i]!='?'&&s[i]==s[i+1]{
			fmt.Println("No")
			return
		}
	}
	for i:=0;i<n;i++{
		if s[i]=='?'&&(i==0||i==n-1||s[i+1]=='?'||s[i-1]=='?'||s[i-1]==s[i+1]){
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


package main
import (
	"fmt"
	"strings"
)
func main(){
	var(
		n int
		s string
	)
	fmt.Scan(&n,&s)
	if strings.Count(s,"MM")>0||strings.Count(s,"CC")>0||strings.Count(s,"YY")>0{
		fmt.Println("No")
		return
	}
	if s[0]=='?'||s[n-1]=='?'||strings.Count(s,"??")>0||strings.Count(s,"M?M")>0||strings.Count(s,"C?C")>0||strings.Count(s,"Y?Y")>0{
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}


package main

import "fmt"

func main() {
	l := []int{0, 0, 0}
	fmt.Scan(&l[0], &l[1], &l[2])
	r := l[0] + l[1] - l[2]
	for _, x := range l {
		if r > x {
			r = x
		}
	}
	fmt.Println(r)
}


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

package main

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

const debug = true

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

	in := gsli(reader)

	n := in[0]
	k := in[1]
	t := in[2]

	ans := 0
	if t <= k {
		ans = t
	} else if t <= n {
		ans = k
	} else {
		ans = k + n - t
	}

	fmt.Println(ans)

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// String helpers

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

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

// Math helpers

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

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

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

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

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

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

// Output helpers

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

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

// Debug helpers

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

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


package main

import "fmt"

func main(){
	var n,k,t int
	fmt.Scanf("%d %d %d",&n,&k,&t)
	if t<=k{
		fmt.Println(t)
	} else{
		if t<=n {
			fmt.Println(k)
		}else {
			fmt.Println(k-(t-n))
		}
	}
}


package main

import "fmt"

func main() {
	var a, b int64
	fmt.Scan(&a, &b)
	c := a + b

	a1 := removeZeros(a)
	b1 := removeZeros(b)
	c1 := removeZeros(c)

	if a1+b1 == c1 {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

func removeZeros(a int64) int64 {
	var b int64
	for ; a > 0; a /= 10 {
		d := a % 10
		if d > 0 {
			b = b*10 + d
		}
	}

	var ret int64
	for ; b > 0; b /= 10 {
		ret = ret*10 + b%10
	}

	return ret
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)
	zero := regexp.MustCompile(`0`)

	with_zero := [2]int{0, 0}
	no_zero := [2]int{0, 0}

	for i := 0; i < 2; i++ {
		if s, err := reader.ReadString('\n'); err != nil {
			if err == io.EOF {
				break
			} else {
				return
			}
		} else {
			s = re.ReplaceAllString(s, "")
			n, err := strconv.Atoi(s)
			if err != nil {
				return
			}
			with_zero[i] = n

			s = zero.ReplaceAllString(s, "")
			z, err := strconv.Atoi(s)
			if err != nil {
				return
			}
			no_zero[i] = z
		}
	}

	sum := with_zero[0] + with_zero[1]
	sum_string := strconv.Itoa(sum)
	sum_no_zero := no_zero[0] + no_zero[1]

	sz := zero.ReplaceAllString(sum_string, "")
	sum_remove_zero, err := strconv.Atoi(sz)
	if err != nil {
		return
	}

	if sum_no_zero == sum_remove_zero {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
	"fmt"
)

// down with zeroes
func tonumwz(x string) (ret int32) {
	for _, xi := range x {
		if xi != '0' {
			ret = ret*10 + int32(xi-'0')
		}
	}
	return
}

func main() {

	var (
		na, nb, nc int32
		a, b, c    string
	)

	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Sscanf(a, "%d", &na)
	fmt.Sscanf(b, "%d", &nb)
	nc = na + nb
	c = fmt.Sprint(nc)
	//println(a, b, c)
	//println(na, nb, nc)

	na = tonumwz(a)
	nb = tonumwz(b)
	nc = tonumwz(c)
	//println(na, nb, nc)
	//println(na, nb, nc)

	if nc == na+nb {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")

	}

}


package main

import "fmt"

func main() {
    var k,l int64
    fmt.Scan(&k,&l)
    a, ans := k, 0
    for a < l {
        a *= k
        ans++
    }
    if a == l {
        fmt.Println("YES")
        fmt.Println(ans)
    } else {
        fmt.Println("NO")
    }
}


package main

import (
	"fmt"
)

func main() {
	var a,b,k int64
	c:=0
	fmt.Scan(&a,&b)
	k=a
	for ;k<b; {
		k*=a
		c++
	}
	if k==b {
		fmt.Println("YES")
		fmt.Println(c)
	} else {
	fmt.Println("NO") }
}


package main

import (
    "fmt"
    "math"
)

func main() {
    var k,a,b,v int
    fmt.Scan(&k,&a,&b,&v)
    n := int(math.Ceil(float64(a)/float64(v)))
    ans := b/(k-1)
    if (ans*k) > n {
        ans = int(math.Ceil(float64(n)/float64(k)))
    }
    n -= (ans*k)
    if (b%(k-1) != 0) && (n >= 0) {
        ans++
        n -= (b%(k-1))+1
    }
    if (n >= 0) { ans += n }
    fmt.Println(ans)
}


package main

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

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

func main(){
	var k int
	var a, b int
	var v int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	k, _ = strconv.Atoi(r.Text())
	r.Scan()
	a, _ = strconv.Atoi(r.Text())
	r.Scan()
	b, _ = strconv.Atoi(r.Text())
	r.Scan()
	v, _ = strconv.Atoi(r.Text())
	box := 0
	x := 0
	for a > 0 {
		x = min(k-1, b)
		a -= (x+1)*v
		b -= x
		box += 1
	}
	w.WriteString(strconv.Itoa(box)+"\n")
	w.Flush()
}


package main

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

func solve() {
	n := readInt()
	k := readInt()
	cnt := make([]int, 5)
	have := make([]int, 5)
	have[4] = n
	have[2] = 2 * n
	for i := 0; i < k; i++ {
		x := readInt()
		for x >= 3 {
			if have[4] > 0 {
				have[4]--
				x -= 4
			} else if have[2] > 0 {
				have[2]--
				x -= 2
			} else {
				fmt.Println("NO")
				return
			}
		}
		if x > 0 {
			cnt[x]++
		}
	}
	for cnt[2] > 0 {
		if have[2] > 0 {
			have[2]--
			cnt[2]--
		} else if have[4] > 0 {
			cnt[2]--
			have[4]--
			have[1]++
		} else {
			cnt[2]--
			cnt[1] += 2
		}
	}
	if cnt[1] <= have[1]+have[2]+have[4]*2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

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

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

import "fmt"

func main() {
    var n int					// membuat variabel b dengan jenis int
    var x,y int				// membuat variabel x dan y dengan jenis int
    fmt.Scan(&n) 			// mengambil input
    upper, lower, f := 0, 0, false  // membuat variabel upper, lower dan f yang diisi 0 , 0 dan false
    for i := 0; i < n; i++ {	// looping
        fmt.Scan(&x,&y)			// mengambil input kedua
        if (x+y)%2 == 1 { f = true } // jika x + y dimodulo 2 sama dengan 1 maka f sama dengan true
        upper = (upper+x)%2			// upper sama dengan upper di tambah x kemudian dimodulo 2
        lower = (lower+y)%2				// lower sama dengan lower di tambah y kemudian dimodulo 2
    }
    if (upper+lower) == 0 {			// jika upper ditambah lower sama dengan 0
        fmt.Println(0)					// maka cetak 0
    } else if ((upper+lower) == 2) && f { // jika upper + lower sama dengan 2 dan f
        fmt.Println(1)						// maka cetak 1
    } else {
        fmt.Println(-1)						// lainnya maka cetak -1
    }
}


package main

import (
	"fmt"
)

// 1200
// 28.05.2020
// https://codeforces.com/problemset/problem/353/A

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

	xs := make([]int, n)
	ys := make([]int, n)

	var sumx, sumy int
	for i := 0; i < n; i++ {
		var x, y int
		fmt.Scanln(&x, &y)
		xs[i] = x
		ys[i] = y

		sumx += x
		sumy += y
	}
	if sumx%2 == 0 && sumy%2 == 0 {
		fmt.Println("0")
		return
	}
	if sumx%2 == 1 && sumy%2 == 1 {
		for i := 0; i < n; i++ {
			if xs[i]%2 != ys[i]%2 {
				fmt.Println("1")
				return
			}
		}
	}
	fmt.Println("-1")
}


package main

import "fmt"

func main() {
    var n int
    var x,y int
    fmt.Scan(&n)
    upper, lower, f := 0, 0, false
    for i := 0; i < n; i++ {
        fmt.Scan(&x,&y)
        if (x+y)%2 == 1 { f = true }
        upper = (upper+x)%2
        lower = (lower+y)%2
    }
    if (upper+lower) == 0 {
        fmt.Println(0)
    } else if ((upper+lower) == 2) && f {
        fmt.Println(1)
    } else {
        fmt.Println(-1)
    }
}


package main

import (
	"fmt"
)

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

 	candlesOut = a
    for candlesOut>=b {
    	a+=candlesOut/b
    	candlesOut=candlesOut/b + candlesOut%b
    }

	fmt.Println(a)
}


package main

import (
    "fmt"
)

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

    remain := 0
    ans := 0
    for a > 0 {
        ans += a

        a += remain
        remaked := a / b
        remain = a - remaked*b
        a = remaked
    }

    fmt.Println(ans)
}


package main

import "fmt"

// https://codeforces.com/problemset/problem/379/A
// комментарии к решению
// Итеративным подходом зажигаем все свежие свечи,
// потом делаем из необходимого кол-ва использованных свежие свечи
// и так до тех пор, пока не закончатся нормальные свечи и
// из использованных нельзя будет сделать ниодной нормальной
func taskSolution(a, b int) (ans int) {
	r, n := a, 0
	for r > 0 || n >= b {
		ans, r, n = ans+r, r/b+n/b, n%b+r%b
	}
	return ans
}

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

	fmt.Println(taskSolution(a, b))
}


package main

import (
"fmt"
"os"
)

func main() {
	var b, y, yb, gb, bb int64

	fmt.Fscan(os.Stdin, &b)
	fmt.Fscan(os.Stdin, &y)
	fmt.Fscan(os.Stdin, &yb)
	fmt.Fscan(os.Stdin, &gb)
	fmt.Fscan(os.Stdin, &bb)

	if b - gb - (yb * 2) >= 0 {
		if y - gb - (bb * 3) >= 0 {
			fmt.Print(0)
		} else {
			fmt.Print(gb + (bb * 3) - y)
		}
	} else {
		if y - gb - (bb * 3) >= 0 {
			fmt.Print(gb + (yb * 2) - b)
		} else {
			fmt.Print((gb * 2) + (bb * 3) + (yb * 2) - b - y )
		}
	}
}


package main

import (
	"fmt"
	"io"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	"strings"
)

// Case .
type Case struct {
	a, b, x, y, z int64
}

func solve(c Case, w io.Writer) {
	a := 2*c.x + c.y - c.a
	b := c.y + 3*c.z - c.b
	if a < 0 {
		a = 0
	}
	if b < 0 {
		b = 0
	}
	w.Write(([]byte)(fmt.Sprintf("%d\n", a+b)))
}

func parseInput(lines <-chan string, res chan<- Case) {
	for {
		ab1, ok := <-lines
		if !ok {
			close(res)
			return
		}
		ab := int64s(words(ab1))
		xyz := int64s(words(<-lines))
		res <- Case{ab[0], ab[1], xyz[0], xyz[1], xyz[2]}
	}
}

func int64s(w []string) []int64 {
	res := make([]int64, 0, len(w))
	for _, word := range w {
		i, err := strconv.ParseInt(word, 10, 64)
		if err != nil {
			panic(err)
		}
		res = append(res, i)
	}
	return res
}

func words(s string) []string {
	prep := strings.Split(s, " ")
	res := make([]string, 0, len(prep))
	for _, l := range prep {
		if len(l) > 0 {
			res = append(res, l)
		}
	}
	return res
}

func run() error {
	exp, err := ioutil.ReadFile("expected.txt")
	if err == nil {
		fmt.Println("--------- expected --------- ")
		fmt.Println((string)(exp))
		fmt.Println("--------- computed --------- ")
	}

	inData, err := ioutil.ReadAll(os.Stdin)
	//inData, err := ioutil.ReadFile("in.txt")
	if err != nil {
		return fmt.Errorf("read input: %s", err)
	}
	lines := make(chan string, 8)
	cases := make(chan Case, 8)
	go func() {
		for _, line := range strings.Split((string)(inData), "\n") {
			s := strings.TrimSpace(line)
			if len(s) > 0 {
				lines <- s
			}
		}
		close(lines)
	}()
	go parseInput(lines, cases)
	for c := range cases {
		solve(c, os.Stdout)
	}
	return nil
}

func main() {
	if err := run(); err != nil {
		log.Fatal(err)
	}
}


package main

/*
	The idea to solve this problem is basically we just need to calculate
	how many A & B we need more. If we breakdown the recipe, we would get
	following formula:
	- needA = 2x + y
	- needB = 3z + y

	After that we just need to calculate how much we need from each
	kind of crystal then combine it.
*/

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

func main() {
	// in codeforces it seems int is equivalent with int32
	// so we need to say explicitly we need int64 to avoid overflow
	var a, b, x, y, z int64
	stdio := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdio, "%d %d\n%d %d %d", &a, &b, &x, &y, &z)

	// calculate total crystal we need for each kind of crystal
	needA := (2 * x) + y
	needB := (3 * z) + y
	// calculate total crystal should acquired
	fmt.Println(diff(a, needA) + diff(b, needB))
}

// calculate how much we need from each kind of crystal
func diff(have int64, want int64) int64 {
	if want >= have {
		return want - have
	}
	return 0
}


package main

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

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

	var l, r int64
	Fscan(in, &l, &r)
	if l == r {
		Fprint(out, 0)
		return
	}
	for m := l ^ r; ; m &= m - 1 {
		if m&(m-1) == 0 {
			Fprint(out, m<<1-1)
			return
		}
	}
}

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


package main

import (
	"fmt"
)

func main() {
	var l, r int64
	fmt.Scan(&l, &r)

	var p uint64
	for i := uint64(1); l != 0 || r != 0; i++ {
		if l&1^r&1 == 1 {
			p = (1 << i) - 1
		}
		l >>= 1
		r >>= 1
	}
	fmt.Println(p)
}


package main

import (
	"bufio"
	"fmt"
	_ "math"
	"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...) }

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()

	var l,r int64

	scanf("%d %d\n", &l, &r)

	var i uint
	var p uint

	for l|r >0 {
		i++
		if l&1 ^ r&1 != 0 {
			p=i
		}
		l>>=1
		r>>=1
	}
	ans := (int64(1<<p)-int64(1))
	printf("%d\n", ans)
}


package main

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

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

func main() {
	defer out.Flush()
	var n int
	fmt.Fscan(in, &n)
	a := make([]int, n)
	for i := range a {
		fmt.Fscan(in, &a[i])
	}
	sort.Ints(a)
	ans := int64(0)
	max := a[n-1] + 1
	for i := n - 1; max > 0 && i >= 0; i-- {
		if a[i] >= max {
			ans += int64(max)
			max = max - 1
		} else {
			ans += int64(a[i])
			max = a[i] - 1
		}
	}
	fmt.Fprintln(out, ans)
}


package main

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

func main() {
    stin := bufio.NewScanner(os.Stdin)
    stin.Scan()
    ns,_ := strconv.ParseInt(stin.Text(), 10, 32)
    n := int(ns)
    stin.Scan()
    ss := strings.Fields(stin.Text())
    var a []int
    for i := 0; i < n; i++ {
        q,_ := strconv.ParseInt(ss[i], 10, 32)
        a = append(a, int(q))
    }
    sort.Sort(sort.Reverse(sort.IntSlice(a)))

    var totalLength int64 = int64(a[0])
    for i := 1; i < n; i++ {
        if a[i] == a[i-1] {
            for j := i; j < n && a[j] == a[i-1]; j++ {
                if a[j] > 0 {
                    a[j] -= 1
                }
            }
        }
        totalLength += int64(a[i])
    }
    fmt.Printf("%v", totalLength)
}


package main

import (
	"fmt"
)

func main() {
	var num int
	fmt.Scan(&num)
	track := make(map[int64]bool)
	total := int64(0)

	for i := 0; i < num; i++ {
		var curr int64
		fmt.Scan(&curr)

		for curr > 0 && track[curr] {
			curr--
		}
		track[curr] = true
		total += curr
	}
	fmt.Println(total)
}


package main

import "fmt"

func Abs(x int64) int64 {
	if x < 0 {
		return -x
	}
	return x
}

func main() {
	var a, b, c int64
	fmt.Scan(&a, &b, &c)

	is := false
	if b == a {
		is = true
	} else {
		if c != 0 && (b-a)/c > 0 && (b-a)%c == 0 {
			is = true
		}
	}

	if is {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import "fmt"

func main() {
    var a, b, c int
    fmt.Scan(&a, &b, &c)
    if c == 0  {
        if a == b {
            fmt.Print("YES")
        } else {
            fmt.Print("NO")
        }
        return
    }
    if (b-a)%c == 0 && (b-a)/c >= 0 {
        fmt.Print("YES")
    } else {
        fmt.Print("NO")
    }

}


package main

import "fmt"

func main() {
	var (
		a, b, c int
	)
	fmt.Scanf("%d%d%d", &a, &b, &c)
	if checkNum(a, b, c) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}
func checkNum(a, b, c int) bool {
	if c == 0 {
		return a == b
	}
	leftOver := b - a
	if leftOver%c == 0 && leftOver/c >= 0 {
		return true
	}
	return false
}


package main

import (
	"fmt"
)

func main() {
	var n, ans int
	var a = make([]int, 3)
	fmt.Scanln(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	if n != 2 {
		ans = a[0] ^ a[1] ^ a[2]
	} else {
		dp := make([][]int, 301)
		for i := 0; i <= 300; i++ {
			dp[i] = make([]int, 301)
			for j := 0; j <= 300; j++ {
				if j < i {
					dp[i][j] = dp[j][i]
				} else if i != 0 || j != 0 {
					dp[i][j] = 1
					for x := 1; x <= i; x++ {
						dp[i][j] &= dp[i-x][j]
						dp[i][j] &= dp[i][j-x]
						dp[i][j] &= dp[i-x][j-x]
					}
					for x := i + 1; x <= j; x++ {
						dp[i][j] &= dp[i][j-x]
					}
					dp[i][j] ^= 1
				}
			}
		}
		ans = dp[a[0]][a[1]]
	}
	if ans == 0 {
		fmt.Println("BitAryo")
	} else {
		fmt.Println("BitLGM")
	}
}


package main

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

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

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

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

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	n, k := ReadInt32(), ReadInt32()

	mod := n % k
	result := n + (k - mod)

	PrintInts(result)
}


package main

import (
	"fmt"
)

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

	if n < k {
		fmt.Println(k)
	} else {
		if n/k >= 10000 {
			for i := n + 1; ; i++ {
				if i%k == 0 {
					fmt.Println(i)
					break
				}
			}
		} else {
			for i := 2; ; i++ {
				if i*k > n {
					fmt.Println(i * k)
					break
				}
			}
		}
	}
}


package main

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

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}
func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var n, k int
	fmt.Fscan(r, &n, &k)

	fmt.Fprintln(w, ((n / k) + 1) * k)

}


package main

import "fmt"

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

func main() {
	var x, y, a, b int
	fmt.Scan(&x, &y, &a, &b)

	var z uint64
	z = uint64(x) * uint64(y) / uint64(gcd(x, y))

	ans := uint64(b)/z - uint64(a-1)/z
	fmt.Println(ans)
}


// 340A-mic
package main

import (
    "fmt"
)

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

func main() {
    var x, y, a, b int64
    fmt.Scan(&x, &y, &a, &b)
    var z int64 = (x * y) / gcd(x, y)
    var ans int64 = b/z - ((a - 1) / z)
    fmt.Println(ans)
}


package main

import (
    "fmt"
)

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

func main() {
    var a, b, x, y int
    fmt.Scanf("%d%d%d%d", &a, &b, &x, &y)
    c := a*b/gcd(a, b)
    fmt.Println(y/c-(x-1)/c)
}


package main

import "fmt"

func main() {

    var n int64
    fmt.Scanf("%v\n", &n)
    var count int64 = 0;

    var i,x int64 = 9,1;

    for n > 0 {
        if n < i {
            count += n*x;
        } else {
            count += i*x;
        }
        n -= i
        i *= 10
        x++
    }
    fmt.Printf("%v\n",count)
}


package main

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

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

func count(n int64) int64 {
	if n < 10 {
		return int64(n)
	}
	var l, p int64 = 1, 1
	for p * 10 <= n {
		l++
		p *= 10
	}

	return l * ((n / p - 1) * p + (n % p + 1)) + count(p - 1)
}

func main() {

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

	fmt.Fprintln(out, count(NextInt64()))
}

func Next() string{
	if !in.Scan() {
		panic("Scan error")
	}
	return in.Text()
}

func NextInt() int{
	ret, _ := strconv.Atoi(Next())
	return ret
}

func NextInt64() int64 {
	ret, _ := strconv.ParseInt(Next(), 10, 64)
	return ret
}


package main

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

func main() {
    //io
    scanner := bufio.NewReader(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    //---
    var n, d, c, ans int64

    fmt.Fscan(scanner, &n)
    for c = 1; c <= n; c *= 10 {
        d++
    }
    //writer.WriteString(strconv.Itoa(c))
    c /= 10
    ans = (n - c + 1) * d;
    for d > 0 {
        ans += (c - c / 10) * (d-1);
        d--
        c /= 10
    }

    writer.WriteString(strconv.FormatInt(ans, 10))
    writer.Flush()
}


package main

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

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

	var n string
	fmt.Fscan(reader, &n)

	mp := make(map[string]int)
	mp["0"] = 2
	mp["1"] = 7
	mp["2"] = 2
	mp["3"] = 3
	mp["4"] = 3
	mp["5"] = 4
	mp["6"] = 2
	mp["7"] = 5
	mp["8"] = 1
	mp["9"] = 2

	fmt.Println(mp[string(n[0])] * mp[string(n[1])])

}


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)

	m := map[uint8]int{
		'0' : 2,
		'1' : 7,
		'2' : 2,
		'3' : 3,
		'4' : 3,
		'5' : 4,
		'6' : 2,
		'7' : 5,
		'8' : 1,
		'9' : 2,
	}

	n := next()

	println(m[n[0]] * m[n[1]])
}

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 s string
	fmt.Scan(&s)
	rs := []rune(s)
	d1 := int(rs[0] - '0')
	d2 := int(rs[1] - '0')
	t := []int{2, 7, 2, 3, 3, 4, 2, 5, 1, 2}
	fmt.Println(t[d1] * t[d2])
}


package main
import
(
  "fmt"
  // "math"
)
func main(){
 var i int
 fmt.Scanf("%d" , &i)
 // temp:= i
 x :=1
 count := 0
 var s []int
 if(i>81){
   x =x-81
 }

 for ;x<i;x++{
   if ((i-x)>81){
     continue
   }
   temp := x
    rs := (i-x)
    // temp2 :=1
    // fmt.Println(x)
    sum :=0
   for ;temp>0;temp/=10{

    // fmt.Println(mult)
  //  var digits [] int

     xlast := temp%10
     sum +=xlast

    //  res := temp + xlast
    //  fmt.Println(temp,xlast)

   }
   if sum==rs{
     s = append(s,x)
        count ++
   }
 }
 if (count == 0){
fmt.Println(0)
}else
{
  fmt.Println(count)
  for x:=0;x<count;x++{
    fmt.Println(s[x])
  }
}
}


package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()

	l := len(strconv.Itoa(N))
	ans := make([]int, 0)

	for i := max(0, N-9*l); i <= N; i++ {
		j := i
		total := i
		for j > 0 {
			total += j % 10
			j /= 10
		}

		if total == N {
			ans = append(ans, i)
		}
	}
	fmt.Println(len(ans))
	PrintI(ans...)
}

func mapToString(arr []int) []string {
	ret := make([]string, len(arr))
	for i := 0; i < len(arr); i++ {
		ret[i] = strconv.Itoa(arr[i])
	}
	return ret
}

func PrintI(args ...int) {
	fmt.Println(strings.Join(mapToString(args), " "))
}

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

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

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

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

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

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

	return mp
}

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


package main

import "fmt"

var (
	read  = fmt.Scan
	print = fmt.Println
)

func main() {
	var n, k int64
	read(&n, &k)
	if n/k%2 == 1 {
		print("YES")
	} else {
		print("NO")
	}
}


package main

import "fmt"

func main() {
	var n, k int64
	fmt.Scanf("%d %d", &n, &k)
	ret := false

	println(n)

	if k == n {
		ret = true
	} else {
		div := n / k

		if div%2 == 0 {
			ret = false
		} else {
			ret = true
		}
	}

	if ret {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)
	if garland, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		garland = re.ReplaceAllString(garland, "")

		needs := make([]int, 4)
		color_idx := make([]int, 4) // Index of RBYG

		for i := 0; i < len(garland); i++ {
			k := i % 4
			if 'R' == garland[i] {
				color_idx[0] = k
			} else if 'B' == garland[i] {
				color_idx[1] = k
			} else if 'Y' == garland[i] {
				color_idx[2] = k
			} else if 'G' == garland[i] {
				color_idx[3] = k
			} else if '!' == garland[i] {
				needs[k]++
			} else {
				fmt.Println("Error")
				return
			}
		}

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


package main

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

func main() {
	sc := NewScanner()
	S := sc.NextLine()
	color := map[int]rune{}

	for i, v := range S {
		if v == '!' {
			continue
		}
		color[i % 4] = v
	}
	ans := map[rune]int{}

	for i, v := range S {
		if v == '!' {
			ans[color[i % 4]]++
		}
	}
	fmt.Println(ans['R'], ans['B'], ans['Y'], ans['G'])

}

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

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

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

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

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

	return mp
}

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


package main

import (
	"fmt"
	)

func main() {
	var input string
	fmt.Scanln(&input)
	d := map[string]int{
		"R":0,
		"B":1,
		"Y":2,
		"G":3,
	}
	cnt := []int{0, 0, 0, 0}
	mod := []int{-1, -1, -1, -1}
	for i, s := range(input) {
		if string(s) == "!" {
			continue
		}
		x := d[string(s)]
		cnt[x]++
		mod[x] = i % 4
	}
	for i := 0; i < 4; i++ {
		val := len(input) / 4
		if len(input) % 4 > mod[i] {
			val++
		}
		fmt.Printf("%d ", val - cnt[i])
	}
}


package main

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

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

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

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

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

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

func solve(s string) {
	ss := []byte(s)
	vk := []byte("VK")
	max := bytes.Count(ss, vk)
	for i := range ss {
		if ss[i] == 'V' {
			ss[i] = 'K'
		} else {
			ss[i] = 'V'
		}
		mx := bytes.Count(ss, vk)
		if mx > max {
			max = mx
		}
		if ss[i] == 'V' {
			ss[i] = 'K'
		} else {
			ss[i] = 'V'
		}
	}
	O(max, "\n")
}


package main

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

func solve() {
	str := readString()
	a := []byte(str)
	ans := 0
	for _, v := range []byte("VK") {
		for i := 0; i < len(a); i++ {
			prev := a[i]
			a[i] = v
			res := 0
			for j := 0; j < len(a)-1; j++ {
				if a[j] == 'V' && a[j+1] == 'K' {
					res++
					j++
				}
			}
			ans = max(ans, res)
			a[i] = prev
		}
	}
	fmt.Println(ans)
}

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

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

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

func main() {
	n, l := read2i()
	k := readis(n)
	s := readis(n)
	if found(k, s, l) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
	writer.Flush()
}

func found(k, s []int, l int) bool {
	s = decrease(s, 0, l)
	for i := range k {
		tempK := decrease(k, i, l)
		if reflect.DeepEqual(s, tempK) {
			return true
		}
	}
	return false
}

func decrease(values []int, pos, l int) []int {
	ans := make([]int, len(values))
	for i := range ans {
		ans[(i-pos+len(ans))%len(ans)] = (values[i] - values[pos] + l) % l
	}
	return ans
}

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

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

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

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

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

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

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

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

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

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

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

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

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


package main
import (
	"fmt"
)

func cmp_slice_int(a, b []int) bool {
	la, lb := len(a), len(b)
	if la != lb {
		return false
	}
	for i, v := range a {
		if v != b[i] {
			return false
		}
	}
	return true
}

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

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

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	for i := 0; i < n; i++ {
		fmt.Scan(&b[i])
	}

	for i := 0; i < l; i++ {
		if cmp_slice_int(a, b) {
			fmt.Println("YES")
			return
		}
		for j := 0; j < n; j++ {
			a[j]++
		}
		if a[n-1] >= l {
			a = append(a[n-1:], a[:n-1]...)
			a[0] = a[0] % l
		}
	}

	fmt.Println("NO")
}


package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	L := sc.NextInt()

	A := sc.NextIntArray()
	B := sc.NextIntArray()

	dA := make([]int, N)
	dB := make([]int, N)

	for i := 0; i < N; i++ {
		dA[i] = (L + A[(N + i + 1) % N] - A[i]) % L
	}
	for i := 0; i < N; i++ {
		dB[i] = (L + B[(N + i + 1) % N] - B[i]) % L
	}

	for i := 0; i < N; i++ {
		ok := true
		for j := 0; j < N; j++ {
			if dA[(i + j) % N] != dB[j] {
				ok = false
				break
			}
		}
		if ok {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}

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

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

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

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

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

	return mp
}

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


package main

import (
	"fmt"
)

func canReach(a, b, c int) bool {
	if b == 0 && c == 1 {
		return false
	}
	if c == 0 && b == 1 {
		return false
	}
	if a > 0 {
		return true
	}
	if b > 0 && c > 0 {
		return true
	}
	return false
}

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

	counts := [3]int{}

	var s string
	fmt.Scan(&s)
	for _, r := range s {
		switch r {
		case 'R':
			counts[0]++
		case 'G':
			counts[1]++
		case 'B':
			counts[2]++
		}
	}

	if canReach(counts[2], counts[1], counts[0]) {
		fmt.Print("B")
	}
	if canReach(counts[1], counts[0], counts[2]) {
		fmt.Print("G")
	}
	if canReach(counts[0], counts[1], counts[2]) {
		fmt.Print("R")
	}
	fmt.Println()
}


package main

import "fmt"

var mem [205][205][205]bool

func can(r, g, b int) {
	if mem[r][g][b] {
		return
	}
	mem[r][g][b] = true
	if r >= 1 && g >= 1 {
		can(r-1, g-1, b+1)
	}
	if r >= 1 && b >= 1 {
		can(r-1, g+1, b-1)
	}
	if g >= 1 && b >= 1 {
		can(r+1, g-1, b-1)
	}
	if r >= 2 {
		can(r-1, g, b)
	}
	if g >= 2 {
		can(r, g-1, b)
	}
	if b >= 2 {
		can(r, g, b-1)
	}
}

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	var r, g, b int
	for _, c := range s {
		switch c {
		case 'B':
			b++
		case 'G':
			g++
		case 'R':
			r++
		default:
			panic(c)
		}
	}

	can(r, g, b)

	var res []byte
	if mem[0][0][1] {
		res = append(res, 'B')
	}
	if mem[0][1][0] {
		res = append(res, 'G')
	}
	if mem[1][0][0] {
		res = append(res, 'R')
	}
	fmt.Printf("%s\n", res)
}


package main

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

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()
}

type State struct {
  B, G, R int
}

var queue = []*State{}
var seen = make([]bool, 201 * 201 * 201)

func push(b, g, r int) {
  i := 201 * 201 * b + 201 * g + r
  if seen[i] {
    return
  }
  seen[i] = true
  queue = append(queue, &State{ b, g, r })
}

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

  _ = getI()
  s := getS()
  b, g, r := 0, 0, 0
  for _, ch := range s {
    if ch == 'B' {
      b++
    } else if ch == 'G' {
      g++
    } else {
      r++
    }
  }
  push(b, g, r)
  tail := 0
  for tail < len(queue) {
    x := queue[tail]
    tail++
    b, g, r = x.B, x.G, x.R
    if b > 0 && g > 0 {
      push(b - 1, g - 1, r + 1)
    }
    if b > 0 && r > 0 {
      push(b - 1, g + 1, r - 1)
    }
    if g > 0 && r > 0 {
      push(b + 1, g - 1, r - 1)
    }
    if b > 1 {
      push(b - 1, g, r)
    }
    if g > 1 {
      push(b, g - 1, r)
    }
    if r > 1 {
      push(b, g, r - 1)
    }
  }

  if seen[201 * 201] {
    writer.WriteString("B")
  }
  if seen[201] {
    writer.WriteString("G")
  }
  if seen[1] {
    writer.WriteString("R")
  }
  writer.WriteString("\n")
}


package main

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

var writer *bufio.Writer
var scanner *bufio.Scanner

func main() {
	ini()
	defer writer.Flush()

	n := scanString()
	k := scanInt()

	cntZeros := strings.Count(n, "0")

	if cntZeros < k {
		writer.WriteString(strconv.Itoa(len(n)-1))
		return
	}

	result := 0
	cnt:= 0
	for i:=len(n)-1; i>=0; i-- {
		if n[i] == '0' {
			cnt++
		} else {
			result++
		}

		if cnt == k {
			break
		}
	}
	writer.WriteString(strconv.Itoa(result))

	return

}

func ini() {
	scanner = bufio.NewScanner(os.Stdin)
	writer = bufio.NewWriter(os.Stdout)
	scanner.Split(bufio.ScanWords)
}

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

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


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)

	if s, err := reader.ReadString('\n'); err != nil {
		if err != io.EOF {
			return
		}
	} else {
		nk := strings.Split(re.ReplaceAllString(s, ""), " ")
		n := nk[0]
		l := len(n)
		k, err := strconv.Atoi(nk[1])
		if err != nil {
			return
		}

		remove := 0
		cnt_0 := 0
		for i := l - 1; i >= 0; i-- {
			if n[i] == '0' {
				cnt_0++
				if cnt_0 == k {
					break
				}
			} else {
				remove++
			}
		}

		if cnt_0 < k {
			fmt.Println(l - 1)
		} else {
			fmt.Println(remove)
		}
	}
}


package main

import "fmt"

func main(){
	var n, k int
	fmt.Scan(&n, &k)
	result := 0
	count := 0
	x := n
	for ; k != 0 && n != 0; {
		if n % 10 != 0{
			result++
		} else{
			k--
		}
		count++
		n /= 10
	}
	if k != 0 && x != 0{
		fmt.Println(count-1)
	} else{
		fmt.Println(result)
	}
}


package main

import "fmt"

func main()  {
	var stones string
	fmt.Scan(&stones)
	var instructions string
	fmt.Scan(&instructions)
	steps := 0

	for index :=0;index < len(instructions); index++ {
		if stones[steps] == instructions[index] {
			steps++
		}
	}
	fmt.Print(steps+1);
}


package main

import "fmt"

func main() {
    var s,t string
    fmt.Scan(&s)
    fmt.Scan(&t)
    pos := 0
    for i := 0; i < len(t); i++ {
        if t[i] == s[pos] {
            pos++
        }
    }
    fmt.Println(pos+1)
}


package main

import (
	"fmt"
)

func main() {
	var a,b string
	var p int
	fmt.Scan(&a,&b)
	for i:=0;i<len(b);i++ {
		if a[p]==b[i] {
			p++
		}
	}
	p+=1
	fmt.Println(p)
}


// 226A
package main

import (
	"fmt"
)

func pow(x, n, mod int64) int64 {
	var a, t int64
	a = 1
	t = x
	for n != 0 {
		if n&1 == 1 {
			a = (a * t) % mod
		}
		t = (t * t) % mod
		n >>= 1
	}
	return int64(a)
}
func main() {
	var a, x, c int64
	fmt.Scan(&a, &x)
	c = pow(3, a, x)
	fmt.Println((c - 1 + x) % x)
}