package main
import "fmt"
func main() {
    var n uint64
    fmt.Scan(&n)
    if n%10 > 5 {
        fmt.Print(n+(10-(n%10)))
    } else {
        fmr.Print(n-(n%10))
    }
}


package main
import "fmt"
func main()
{
    var a int
    fmt.Scanf("%a", &a)
    fmt.Println(a / 2520)
}


package main
import "fmt"
func main() {
    var a long long
    fmt.Scanf("%lld", &a)
    fmt.Println(a / 2520)
}


package main
import "fmt"
func main() {
    var a long long
    fmt.Scanf("%d", &a)
    fmt.Println(a / 2520)
}


package main

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

var k_cf702d, a_cf702d, b_cf702d, t_cf702d int

func startCar(d int64) float64 {
	if d <= int64(k_cf702d) {
		return float64(int64(a_cf702d)*d)
	}
	return float64(a_cf702d*k_cf702d) + math.Min(float64(float64(t_cf702d) + startCar(d-int64(k_cf702d))), float64(int64(b_cf702d)*(d-int64(k_cf702d))))
}

func main() {
	fmt.Println(math.MaxInt32)
	fmt.Println(math.MaxInt64)
	fmt.Println(math.MaxFloat32)
	fmt.Println(math.MaxFloat64)
	scanner := bufio.NewScanner(os.Stdin)

	scanner.Buffer([]byte{}, int(math.Pow(10,8)))

	scanner.Scan()
	dkabtStr := scanner.Text()
	dkabtStrArr := strings.Split(dkabtStr, " ")
	d, _ := strconv.ParseInt(dkabtStrArr[0], 10, 64)
	k_cf702d, _ = strconv.Atoi(dkabtStrArr[1])
	a_cf702d, _ = strconv.Atoi(dkabtStrArr[2])
	b_cf702d, _ = strconv.Atoi(dkabtStrArr[3])
	t_cf702d, _ = strconv.Atoi(dkabtStrArr[4])

	resp := math.Min(float64(int64(b_cf702d)*d), startCar(d))

	fmt.Println(resp)
}


package main

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

func solve(k, a, b int64) int64 {
	a0 := a / k
	b0 := b / k
	if a - a0 * k > b0 * (k - 1) {
		return -1
	}
	if b - b0 * k > a0 * (k - 1) {
		return -1
	}
	return a0 + b0
}

func main() {
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	k := cin.nextInt64()
	a := cin.nextInt64()
	b := cin.nextInt64()
	fmt.Printf("%d\n", solve(k, a, b))
}

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r := r*10 + (p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r := r*10 + (p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}


package main

import (
	"fmt"
	"sort"
	"github.com/qiuyesuifeng/goyacc/Godeps/_workspace/src/github.com/cznic/mathutil"
)

func main() {
	li := make([]int, 5)
	sum := 0
	for i := 0 ; i < 5; i++ {
		fmt.Scanf("%d", &li[i])
		sum += li[i]
	}
	sort.Ints(li)
	cut := 0
	for i:=4; i>= 0; i-- {
		if i >= 2 && li[i] == li[i-1] && li[i-1] == li[i-2] {
			cut = mathutil.Max(cut, li[i] * 3)
		}
		if i >= 1 && li[i]  == li[i-1] {
			cut = mathutil.Max(cut, li[i] * 2)
		}
	}
	fmt.Printf("%d", sum-cut)
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1183H(_r io.Reader, _w io.Writer) {
	var n int
	var k, ans int64
	var s []byte
	Fscan(bufio.NewReader(_r), &n, &k, &s)
	prev := [26]int{}
	dp := make([][]int64, n+1)
	for i := range dp {
		dp[i] = make([]int64, n+1)
	}
	dp[0][0] = 1
	for i := 1; i <= n; i++ {
		c := s[i-1] - 'a'
		dp[i][0] = 1
		for j := 1; j <= i; j++ {
			dp[i][j] = dp[i-1][j] + dp[i-1][j-1]
			if p := prev[c]; p > 0 {
				dp[i][j] -= dp[p-1][j-1]
			}
		}
		prev[c] = i
	}
	k--
	for l := n - 1; l >= 0; l-- {
		cnt := dp[n][l]
		if cnt > k {
			ans += int64(n-l) * k
			k = 0
			break
		}
		k -= cnt
		ans += int64(n-l) * cnt
	}
	if k > 0 {
		ans = -1
	}
	Fprint(_w, ans)
}

//func main() { CF1183H(os.Stdin, os.Stdout) }


/*********************************************************************************
*     File Name           :     A.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-04 23:07]
*     Last Modified       :     [2014-03-04 23:29]
*     Description         :
**********************************************************************************/

package main

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

func main() {
    scanner.Split(bufio.ScanWords)

    var n, p, k = scanner.nextInt(), scanner.nextInt(), scanner.nextInt()
    if p-k > 1 {
        fmt.Print("<< ")
    }
    for i := max(1, p-k); i < p; i++ {
        fmt.Printf("%d ", i)
    }
    fmt.Printf("(%d)", p)
    for i := p + 1; i <= n && i <= p+k; i++ {
        fmt.Printf(" %d", i)
    }
    if p+k < n {
        fmt.Print(" >>")
    }
    fmt.Println()
}

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

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

func (self *Scanner) nextInt() int {
    x, err := strconv.Atoi(self.next())
    if err != nil {
        panic(err)
    }
    return x
}/*********************************************************************************
*     File Name           :     A.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-04 23:07]
*     Last Modified       :     [2014-03-04 23:29]
*     Description         :
**********************************************************************************/

package main

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

func main() {
    scanner.Split(bufio.ScanWords)

    var n, p, k = scanner.nextInt(), scanner.nextInt(), scanner.nextInt()
    if p-k > 1 {
        fmt.Print("<< ")
    }
    for i := max(1, p-k); i < p; i++ {
        fmt.Printf("%d ", i)
    }
    fmt.Printf("(%d)", p)
    for i := p + 1; i <= n && i <= p+k; i++ {
        fmt.Printf(" %d", i)
    }
    if p+k < n {
        fmt.Print(" >>")
    }
    fmt.Println()
}

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

type Scanner struct {
    *bufio.Scanner
}

var scanner = Scanner{bufio.NewScanner(os.Stdin)}

func (self *Scanner) next() string {
    if !self.Scan() {
        panic(self.Err())
    }
    return self.Text()
}

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


package main

import "testing"

func Test_paintTheNumbers(t *testing.T) {
	type args struct {
		n     int
		slice []int
	}
	tests := []struct {
		name string
		args args
		want int
	}{
		{
			name: "TC_01",
			args: args{
				n:     6,
				slice: []int{10, 2, 3, 5, 4, 2},
			},
			want: 3,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := paintTheNumbers(tt.args.n, tt.args.slice); got != tt.want {
				t.Errorf("paintTheNumbers() = %v, want %v", got, tt.want)
			}
		})
	}
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var i, n int64

	fmt.Scanf("%d", &n)

	total := 0
	for i = 1; i <= n; i++ {
		total += int64(math.Pow(2.0, float64(i)))
	}
	fmt.Println(total)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var n int64

	fmt.Scanf("%d", &n)

	total := 0
	for i := 1; i <= n; i++ {
		total += int64(math.Pow(2.0, float64(i)))
	}
	fmt.Println(total)
}


package main

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

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

	var n, t, d int
	Fscan(in, &n, &t)
	a := make([]int, n)
	for i := range a {
		Fscan(in, &a[i])
	}
	dp := []int{}
	for i := 0; i < n+10 && t > 0; i++ {
		t--
		cur := len(dp)
		for _, v := range a {
			if p := sort.SearchInts(dp, v+1); p < len(dp) {
				dp[p] = v
			} else {
				dp = append(dp, v)
			}
		}
		d = len(dp) - cur
		cur = len(dp)
	}
	if t == 0 {
		Fprint(out, len(dp))
		return
	}
	Fprintln(out, len(dp)+t*d)
}

//func main() { CF582B(os.Stdin, os.Stdout) }


// 378A
package main

import (
	"fmt"
	"math"
)

func main() {
    var a, b, wina, winb, draw int
    fmt.Scan(&a, &b)
    for x := 1; x <= 6; x++ {
		ai := float64(x)-a
		bi := float64(x)-b
        if math.Abs(ai) < math.Abs(bi) {
            wina++
        } else if math.Abs(ai) > math.Abs(bi) {
            winb++
        } else {
            draw++
        }
    }
    fmt.Println(wina, draw, winb)
}


package main

import (
	"fmt"
	"sort"
)

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

func main()  {
	var n, m int
	fmt.Scanln(&n,&m)
	//fmt.Println(n,m)
	a := make([]int, n)
	b := make([]int, m)
	for i := 0; i < n; i++{
		if(i < n-1){
			fmt.Scanf("%d",&a[i])
		} else {
			fmt.Scanf("%d\n",&a[i])
		}
		//fmt.Printf("%d\n",a[i])
	}
	for i := 0; i < m; i++{
		if(i < m-1){
			fmt.Scanf("%d",&b[i])
		} else {
			fmt.Scanf("%d\n",&b[i])
		}
		//fmt.Printf("%d\n",b[i])
	}
	sort.Ints(a)
	sort.Ints(b)
	var ans int = 99999999
	for i := 0; i < n; i++{
		for j := 0; j < m; j++{
			if a[i] == b[j]{
				ans = min(ans,a[i])
			}
		}
	}
	if(ans == 99999999){
		ans = min(a[0] * 10 + b[0], b[0] * 10 + a[0])
	}
	fmt.Println(ans)
}


package main

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

func solve() {
	n := readInt()
	m := readInt()

	ns := make(map[int]bool, n)
	for i := 0; i < n; i++ {
		ns[readInt()] = true
	}

	ms := make(map[int]bool, m)
	for i := 0; i < m; i++ {
		ms[readInt()] = true
	}

	for i := 1; i <= 9; i++ {
		if ms[i] && ns[i] {
			fmt.Println(i)
			return
		}
	}
	for i := 10; i <= 99; i++ {
		if ms[i/10] && ns[i%10] {
			fmt.Println(i)
			return
		}
		if ns[i/10] && ms[i%10] {
			fmt.Println(i)
			return
		}
	}
}

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


package main

import (
	"fmt"
	"sort"
)

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

func main()  {
	var n, m int
	fmt.Scanf("%d%d",&n,&m)
	a := make([]int, n)
	b := make([]int, m)
	for i := 0; i < n; i++{
		fmt.Scanf("%d",&a[i])
	}
	for i := 0; i < n; i++{
		fmt.Scanf("%d",&b[i])
	}
	sort.Ints(a)
	sort.Ints(b)
	var ans int = 99999999
	for i := 0; i < n; i++{
		for j := 0; j < m; j++{
			if a[i] == b[j]{
				ans = min(ans,a[i])
			}
		}
	}
	if(ans == 0){
		ans = min(a[0] * 10 + b[0], b[0] * 10 + a[0])
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"sort"
)

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

func main()  {
	var n, m int
	fmt.Scanf("%d %d",&n,&m)
	a := make([]int, n)
	b := make([]int, m)
	for i := 0; i < n; i++{
		fmt.Scanf("%d",&a[i])
	}
	for i := 0; i < m; i++{
		fmt.Scanf("%d",&b[i])
	}
	sort.Ints(a)
	sort.Ints(b)
	var ans int = 99999999
	for i := 0; i < n; i++{
		for j := 0; j < m; j++{
			if a[i] == b[j]{
				ans = min(ans,a[i])
			}
		}
	}
	if(ans == 99999999){
		ans = min(a[0] * 10 + b[0], b[0] * 10 + a[0])
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"sort"
)

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

func main()  {
	var n, m int
	fmt.Scanf("%d%d",&n,&m)
	a := make([]int, n)
	b := make([]int, m)
	for i := 0; i < n; i++{
		fmt.Scanf("%d",&a[i])
	}
	for i := 0; i < m; i++{
		fmt.Scanf("%d",&b[i])
	}
	sort.Ints(a)
	sort.Ints(b)
	var ans int = 99999999
	for i := 0; i < n; i++{
		for j := 0; j < m; j++{
			if a[i] == b[j]{
				ans = min(ans,a[i])
			}
		}
	}
	if(ans == 99999999){
		ans = min(a[0] * 10 + b[0], b[0] * 10 + a[0])
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"sort"
)

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

func main()  {
	var n, m int
	fmt.Scanln(&n,&m)
	fmt.Println(n,m)
	a := make([]int, n)
	b := make([]int, m)
	for i := 0; i < n; i++{
		if(i < n-1){
			fmt.Scanf("%d",&a[i])
		} else {
			fmt.Scanf("%d\n",&a[i])
		}
		fmt.Printf("%d\n",a[i])
	}
	for i := 0; i < m; i++{
		if(i < m-1){
			fmt.Scanf("%d",&b[i])
		} else {
			fmt.Scanf("%d\n",&b[i])
		}
		fmt.Printf("%d\n",b[i])
	}
	sort.Ints(a)
	sort.Ints(b)
	var ans int = 99999999
	for i := 0; i < n; i++{
		for j := 0; j < m; j++{
			if a[i] == b[j]{
				ans = min(ans,a[i])
			}
		}
	}
	if(ans == 99999999){
		ans = min(a[0] * 10 + b[0], b[0] * 10 + a[0])
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"sort"
)

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

func main()  {
	var n, m int
	fmt.Scanln(&n,&m)
	fmt.Println(n,m)
	a := make([]int, n)
	b := make([]int, m)
	for i := 0; i < n; i++{
		if(i < n-1){
			fmt.Scanf("%d",&a[i])
		} else {
			fmt.Scanf("%d\n",&a[i])
		}
		//fmt.Printf("%d\n",a[i])
	}
	for i := 0; i < m; i++{
		if(i < m-1){
			fmt.Scanf("%d",&b[i])
		} else {
			fmt.Scanf("%d\n",&b[i])
		}
		//fmt.Printf("%d\n",b[i])
	}
	sort.Ints(a)
	sort.Ints(b)
	var ans int = 99999999
	for i := 0; i < n; i++{
		for j := 0; j < m; j++{
			if a[i] == b[j]{
				ans = min(ans,a[i])
			}
		}
	}
	if(ans == 99999999){
		ans = min(a[0] * 10 + b[0], b[0] * 10 + a[0])
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"sort"
)

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

func main()  {
	var n, m int
	fmt.Scanf("%d %d\n",&n,&m)
	a := make([]int, n)
	b := make([]int, m)
	for i := 0; i < n; i++{
		if i != n-1{
			fmt.Scanf("%d",&a[i])
		}else{
			fmt.Scanf("%d\n",&a[i])
		}
	}
	for i := 0; i < m; i++{
		if i != m-1{
			fmt.Scanf("%d",&b[i])
		}else{
			fmt.Scanf("%d\n",&b[i])
		}

	}
	sort.Ints(a)
	sort.Ints(b)
	var ans int = 99999999
	for i := 0; i < n; i++{
		for j := 0; j < m; j++{
			if a[i] == b[j]{
				ans = min(ans,a[i])
			}
		}
	}
	if(ans == 99999999){
		ans = min(a[0] * 10 + b[0], b[0] * 10 + a[0])
	}
	fmt.Println(ans)


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, z, cnt, cnt1, cnt2 int

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

	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &z)

		t[i] = z
	}

	for x, y := range t {
		cnt += y
		if cnt > m {
			cnt2 = cnt
			sort.Ints(t[:x])
			for i := len(t[:x]) - 1; i >= 0; i-- {

				cnt2 -= t[i]
				cnt1++

				if cnt2 <= m {
					res[x] = cnt1
					cnt1 = 0
					break
				}
			}
		} else {
			res[x] = 0
		}
	}

	for _, y := range res {
		fmt.Printf("%d ", y)
	}

}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, m := 0, 0
	fmt.Fscanf(in, "%d %d\n", &n, &m)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &a[i])
	}
	cnt := make([]int, 101)
	sum := 0
	for i := 0; i < n; i++ {
		ans := 0
		sum += a[i]
		tmp := sum
		//fmt.Println("begin", i)
		for j := 100; j >= 1; j-- {
			if tmp <= m {
				break
			}
			if cnt[j] == 0 {
				continue
			}
			//fmt.Println(j, cnt[j], tmp)
			need := (tmp - m) / j
			if (tmp-m)%j != 0 {
				need++
			}
			if need <= cnt[j] {
				ans += need
				tmp -= need * j
			} else {
				ans += cnt[j]
				tmp -= cnt[j] * j
			}
		}
		cnt[a[i]]++
		if i != 0 {
			fmt.Fprintf(out, " ")
		}
		fmt.Fprintf(out, "%d", ans)
	}
	fmt.Fprintf(out, "\n")
	return
}

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

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

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

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

func ok(a, b int) bool {
	if min(abs(a-b), abs(a+b)) <= min(abs(a), abs(b)) && max(abs(a+b), abs(a-b)) >= max(abs(a), abs(b)) {
		return true
	}
	return false
}


package main

import (
	"fmt"
)

func main() {
	var d, cnt, index int
	var st, st1 string
	fmt.Scanln(&d)

	for d > 0 {
		fmt.Scanln(&st)
		fmt.Scanln(&st1)
		a := make([]rune, 0)
		b := make([]rune, 0)

		for _, y := range st {
			a = append(a, y)
		}
		if len(st) > len(st1) {
			cnt = 5
		}

		for _, y := range st1 {
			if len(b) > len(a) {
				cnt = 5
				break
			}
			if (index <= len(a)-1) && (a[index] == y) {
				b = append(b, y)
				index++
				continue
			} else if (len(b) > 1) && (y == b[len(b)-1]) {
				continue
			} else {
				cnt = 5
				break
			}
		}

		if cnt == 5 {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
		cnt = 0
		index = 0

		d--
	}
}


package main

import (
	"fmt"
	"sort"
)

var(
	n int				/*Number of students*/
	M int				/*Maximum time*/
	t[110] int  		/*Students' time*/
	sum[110] int 		/*sum [0..i)*/
	buffer[110] int 	/*used for sorting*/
)

func main(){
	//input
	fmt.Scanf("%d %d", &n, &M)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &t[i])
	}

	sum[0] = 0
	for i := 1; i < n; i++ {
		sum[i] = sum[i - 1] + t[i - 1]
	}
	buffer = sum

	for i := 0; i < n; i++ {	/*Next student*/
		ans := 0
		required := M - t[i]
		current := sum[i]
		if current > required{
			copy(buffer[0:i], t[0:i])
			sort.Ints(buffer[0:i])
		}
		for current > required {
			ans++
			current -= buffer[i - ans]  /*M > t[i]*/
		}
		fmt.Printf("%d ",  ans)
	}
}


package main
import
(
  "fmt"
  // "math"
)
func main(){
 var i int
 fmt.Scanf("%d" , &i)
 // temp:= i
 x :=1
 count := 0
 var s []int
 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
(
  "fmt"
  // "math"
)
func main(){
 var i int
 fmt.Scanf("%d" , &i)
 // temp:= i
 x := 0
 count := 0
 var s []int

 for ;x<i;x++{
   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
{
  for x:=0;x<count;x++{
    fmt.Println(count)
    fmt.Println(s[x])
  }
}
}


package main
import
(
  "fmt"
  // "math"
)
func main(){
 var i int
 fmt.Scanf("%d" , &i)
 // temp:= i
 x :=1
 count := 0
 var s []int
 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
{
  for x:=0;x<count;x++{
    fmt.Println(count)
    fmt.Println(s[x])
  }
}
}


package main
import
(
  "fmt"
  "math"
)
func main(){
 var i int
 fmt.Scanf("%d" , &i)
 // temp:= i
 x := 0
 count := 0
 var s []int
 for ;x<i;x++{
   temp := x
    rs := (i-x)
    // temp2 :=1
    // fmt.Println(x)
   for mult :=1;temp>0;mult++{

    // fmt.Println(mult)

    coef := math.Pow(10,float64(mult))
    //  fmt.Println(coef)
     xlast := x%int(coef)
     temp = x/int(coef)
     if temp == 0{
       break
     }
     res := temp + xlast
    //  fmt.Println(temp,xlast)
     if rs==res{
       s = append(s,x)
          count ++
     }
   }

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


package main
import
(
  "fmt"
  // "math"
)
func main(){
 var i int
 fmt.Scanf("%d" , &i)
 // temp:= i
 x :=1
 count := 0
 var s []int
 for ;x<i;x++{
   if ((i-x)>81){
     break
   }
   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
{
  for x:=0;x<count;x++{
    fmt.Println(count)
    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"
  // "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 (
	"fmt"
	"os"
	"bufio"
)

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

func main () {
	in := bufio.NewReader(os.Stdin);
	out := bufio.NewWriter(os.Stdout);
	var n int;
	var s string;

	fmt.Fscanln(in, &n);
	fmt.Fscanln(in, &s);
	var maxs [26]int;
	d := make([]int, n);
	ans := 0;
	for i := 0; i < n; i++ {
		for j := s[i] + 1; j <= 'z'; j++ {
			d[i] = Max(d[i], maxs[j - 'a'] + 1);
		}
		if (d[i] == 0) {
			d[i] = 1;
		}
		if (d[i] > ans) {
			ans = d[i];
		}
		maxs[s[i] - 'a'] = Max(maxs[s[i] - 'a'], d[i]);
	}
	fmt.Fprintln(out, ans);
	for _, x := range d {
		fmt.Fprint(out, x, " ");
	}
	out.Flush();
}


package main

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

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

func main () {
	in := bufio.NewReader(os.Stdin);
	out := bufio.NewWriter(os.Stdout);
	var n int;
	var s string;

	fmt.Fscanln(in, &n);
	fmt.Fscanln(in, &s);
	var maxs [26]int;
	d := make([]int, n);
	ans := 0;
	for i := 0; i < n; i++ {
		for j := s[i] + 1; j <= 'z'; j++ {
			d[i] = Max(d[i], maxs[j - 'a'] + 1);
		}
		if (d[i] == 0) {
			d[i] = 1;
		}
		if (d[i] > ans) {
			ans = d[i];
		}
		maxs[s[i] - 'a'] = Max(maxs[s[i] - 'a'], d[i]);
	}
	if (ans > 2) {
		fmt.Fprintln(out, "NO");
	} else {
		fmt.Fprintln(out, "YES");
		for _, x := range d {
			fmt.Fprint(out, x - 1);
		}
	}
	out.Flush();
}


// Author: sighduck
// URL: https://codeforces.com/contest/1150/problem/A

package main

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

func min(a []int) int {
	minElem := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] < minElem {
			minElem = a[i]
		}
	}
	return minElem
}

func max(a []int) int {
	maxElem := a[0]
	for i := 1; i < len(a); i++ {
		if a[i] > maxElem {
			maxElem = a[i]
		}
	}
	return maxElem
}

func Solve(n int, m int, r int, s []int, b[]int) int {
	minBuyPrice := min(s)
	maxSellPrice := max(b)
	if maxSellPrice > minBuyPrice {
		shares := r / minBuyPrice
		remainder := r % minBuyPrice
		return shares * maxSellPrice + remainder
	}
	return r
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	var n, m, r int
	fmt.Fscanf(reader, "%d %d %d\n", &n, &m, &r)
	s := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(reader, &s[i])
	}
	b := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Fscan(reader, &b[i])
	}

	fmt.Fprintf(writer, "%d\n", Solve(n, m, r, s, b))
}


package main

import "fmt"

func min(a,b int) int  {
	if(a < b){
		return a
		}
	return b
}
func katta(a,b int) int  {
	if(a < b){
		return b
	}
	return a
}
func ab(x int) int {
	if(x <= -1){
		x *= -1
	}
	return x
}
//a b c d e f g h j k l m n o p q r s t u v w x y z
func calc(s string) (res int) {

	res += min(ab(int(s[0]) - int('A')) ,ab(int('Z') - int(s[0])) + 1)
	res += min(ab(int(s[1]) - int('C')),ab(int('Z') - int(s[1])) + 3)
	res += min(ab(int(s[2])- int('T')),min(ab(int('Z') - int(s[2])) + 20,ab(int('A') - int(s[2]))+7))
	res += min(ab(int(s[3])- int('G')),ab(int('Z') - int(s[3])) + 7)
	return
}

func main()  {
	var n , m ,r int
	fmt.Scanf("%d %d %d",&n,&m,&r)
	maxe := 0
	mine := 1001
	var x int
	for i := 0 ; i < n;i++{
		fmt.Scan(&x)
		if(x < mine){
			mine = x
		}
	}
	for i := 0 ; i< m ;i ++{
		fmt.Scan(&x)
		if(x > maxe){
			maxe = x
		}
	}
	fmt.Println(katta(((r/mine) * maxe) + r % mine,r))

}


package main

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

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

	var n, x int64
	Fscan(in, &n, &x)
	ans := int64(1e18)
	f := func(p, e int64) {
		c := int64(0)
		for pp := p; pp <= n; pp *= p {
			c += n / pp
		}
		if c/e < ans {
			ans = c / e
		}
	}
	for i := int64(2); i*i <= x; i++ {
		e := int64(0)
		for ; x%i == 0; x /= i {
			e++
		}
		if e > 0 {
			f(i, e)
		}
	}
	if x > 1 {
		f(x, 1)
	}
	Fprint(out, ans)
}

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


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

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, b int64
)

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

	memo := TrialDivision(b)

	counts := make(map[int64]int64)
	for a := range memo {
		cnt := int64(0)
		cur := a
		for n/cur != 0 {
			cnt += n / cur

			cur *= a
		}

		counts[a] = cnt
	}

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

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

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

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

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

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

	return p
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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


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

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, b int64
)

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

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

	memo := TrialDivision(b)

	counts := make(map[int64]int64)
	for a := range memo {
		cnt := int64(0)
		cur := a
		for n/cur != 0 {
			cnt += n / cur

			cur *= a
		}

		counts[a] = cnt
	}

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

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

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

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

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

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

	return p
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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


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

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, b int64
)

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

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

	memo := TrialDivision(b)

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

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

			cur *= a
		}

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

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

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

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

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

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

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

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

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

	return p
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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


package main
import "fmt"
func main() {
    var a, b, c, d, e, f int
    fmt.Scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    if ((a * c * e < b * d * f) || ((a == 0) && (b * d > 0)) || (c == 0) && (d > 0)) {
        fmt.Printf("Ron\n");
    } else {
        fmt.Printf("Hermione\n");
    }
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF300C(in io.Reader, out io.Writer) {
	const m int64 = 1e9 + 7
	const mx int = 1e6
	F := [mx + 1]int64{1}
	for i := 1; i <= mx; i++ {
		F[i] = F[i-1] * int64(i) % m
	}
	pow := func(x, n int64) int64 {
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % m
			}
			x = x * x % m
		}
		return res
	}
	invF := [...]int64{mx: pow(F[mx], m-2)}
	for i := mx; i > 0; i-- {
		invF[i-1] = invF[i] * int64(i) % m
	}
	var a, b, n int
	Fscan(in, &a, &b, &n)
	C := func(k int) int64 { return F[n] * invF[k] % m * invF[n-k] % m }
	ans := int64(0)
	d := n * a
	for i := 0; i <= n; i++ {
		v := d
		for ; v > 0; v /= 10 {
			if v%10 != a && v%10 != b {
				break
			}
		}
		if v == 0 {
			ans = (ans + C(i)) % m
		}
		d += b - a
	}
	Fprint(out, ans)
}

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


package main
import "fmt"
const MAX int64 = 1e7
const MOD int64 = 1e9+7
var isgood [MAX]bool
func Max(a, b int64) int64 {
	if (a < b) {
		return b
	}
	return a
}
func Init(a, b, n int64) {
	var k int64
	for k = 0; k < MAX; k++ { isgood[k] = true }
	for k = 1; k <= Max(a,b) * n; k++ {
		p := k
		for p > 0 {
			if p % 10 != a && p % 10 != b {
				isgood[k] = false
				break
			}
			p /= 10
		}
	}
}

func EE(a, b int64) int64 {
	var (
		r=a%b
		x0 int64=1
		y0 int64=0
		x1 int64=0
		y1 int64=1
		mod=b
	)
	for r > 0 {
		f:=a/b
		tx:=x0-f*x1
		ty:=y0-f*y1
		x0=x1
		y0=y1
		x1=tx
		y1=ty
		a=b
		b=r
		r=a%b
	}
	return (x1%mod+mod)%mod
}

func main() {
	var a,b,n int64
	fmt.Scanf("%d%d%d",&a,&b,&n)
	Init(a,b,n)
	var (
		choose int64=1
		x int64=0
		y int64
	)
	cnt := make(map[int64]int64)
	for x <= n {
		y=n-x
		s:=a*x+b*y
		if isgood[s] { cnt[s]=(cnt[s]+choose)%MOD }
		choose=((choose*(n-x))%MOD)*EE(x+1,MOD)%MOD
		x++
	}
	var ans int64 = 0
	for k,v := range cnt {
		if isgood[k] { ans = (ans + v) % MOD }
	}
	fmt.Println(ans)
}


package main
import "fmt"

const INF int64 = 2147483647
const MAX int64 = 1e7
const MOD int64 = 1e7+9
var isgood [MAX]bool
func Max(a, b int64) int64 {
	if (a < b) {
		return b
	}
	return a
}
func Init(a, b, n int64) {
	var k int64
	for k = 0; k < MAX; k++ { isgood[k] = true }
	for k = 1; k <= Max(a,b) * n; k++ {
		p := k
		for p > 0 {
			if p % 10 != a && p % 10 != b {
				isgood[k] = false
				break
			}
			p /= 10
		}
	}
}

func EE(a, b int64) int64 {
	var (
		r=a%b
		x0 int64=1
		y0 int64=0
		x1 int64=0
		y1 int64=1
		mod=b
	)
	for r > 0 {
		f:=a/b
		tx:=x0-f*x1
		ty:=y0-f*y1
		x0=x1
		y0=y1
		x1=tx
		y1=ty
		a=b
		b=r
		r=a%b
	}
	return (x1%mod+mod)%mod
}

func main() {
	var a,b,n int64
	fmt.Scanf("%d%d%d",&a,&b,&n)
	Init(a,b,n)
	var (
		choose int64=1
		x int64=0
		y int64
	)
	cnt := make(map[int64]int64)
	for x <= n {
		y=n-x
		s:=a*x+b*y
		if isgood[s] { cnt[s]=(cnt[s]+choose)%MOD }
		choose=((choose*(n-x))%MOD)*EE(x+1,MOD)%MOD
		x++
	}
	var ans int64 = 0
	for k,v := range cnt {
		if isgood[k] { ans = (ans + v) % MOD }
	}
	fmt.Println(ans)
}


package main

import "fmt"

func main() {
    var s string
    ans := true
    for i := 0; i < 8; i++ {
        fmt.Scan(&s)
        if ans {
            for i := 0; i < 8; i++ {
                if s[i] == s[(i+1)%8] { ans = false; break }
            }
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}


package main

import (
	"fmt"
)

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

		var line string
		fmt.Scanln(&line)

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

	fmt.Println("YES")
}


package main

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

func main() {
	valid := true

	in := bufio.NewReader(os.Stdin)

	for i:=0; i<8; i++ {
		line, _, _ := in.ReadLine()
		a := string(line)

		valid = valid && checkString(a)
	}

	if valid {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}

func checkString(a string) bool {
	for i := 0; i < len(a)-1; i++ {
		if a[i] == a[i+1] {
			return false
		}
	}

	if a[len(a)-1] == a[0] {
		return false
	}

	return true;
}


package main

import (
	"fmt"
)

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


package main

import "fmt"

func main() {
    var s string                    // membuat variabel s dengan tipe data string
    ans := true                     // membuat variabel ans dengan tipe data boolean dengan nilai awal true
    for i := 0; i < 8; i++ {        // looping sebanyak 8 kali
        fmt.Scan(&s)                // menerima input string s
        if ans {                    // jika ans masih bernilai true
            for i := 0; i < 8; i++ {                            // looping sebanyak 8 kali (jumlah huruf pada string s)
                if s[i] == s[(i+1)%8] { ans = false; break }    // jika ada karakter yang bersebelahan dan nilainya sama maka ans diisi false dan break
            }
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }    // mencetak output "YES" jika ans = true, "NO" jika ans = false
}


package main

import (
	"fmt"
)

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

		var line string
		fmt.Scanln(&line)

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

	fmt.Println("YES")
}


package main

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

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

type Vertice struct {
	X int
	Y int
}

func dist(a, b Vertice) int {
	x, y := a.X-b.X, a.Y-b.Y
	return x*x + y*y
}

func isRight(a, b, c Vertice) bool {
	es := []int{dist(a, b), dist(b, c), dist(c, a)}
	sort.Ints(es)

	if es[0] == 0 || es[1] == 0 || es[2] == 0 {
		return false
	}

	return es[0]+es[1] == es[2]
}

func getAdjs(v Vertice) []Vertice {
	return []Vertice{Vertice{v.X - 1, v.Y}, Vertice{v.X + 1, v.Y}, Vertice{v.X, v.Y - 1}, Vertice{v.X, v.Y + 1}}
}

func solve(a, b, c Vertice) string {
	if isRight(a, b, c) {
		return "RIGHT"
	}

	for i := 0; i < 3; i++ {
		var v1, v2, v3 Vertice
		switch i {
		case 0:
			v1, v2, v3 = a, b, c
		case 1:
			v1, v2, v3 = b, c, a
		case 2:
			v1, v2, v3 = c, a, b
		}
		adjs := getAdjs(v1)
		for _, v := range adjs {
			if isRight(v, v2, v3) {
				return "ALMOST"
			}
		}
	}

	return "NEITHER"
}

func main() {
	defer w.Flush()

	a, b, c := Vertice{}, Vertice{}, Vertice{}
	fmt.Fscanf(r, "%d %d %d %d %d %d", &a.X, &a.Y, &b.X, &b.Y, &c.X, &c.Y)

	fmt.Fprintf(w, "%v", solve(a, b, c))
}


package main

import (
	"fmt"
)

type Pont struct {
	x, y int32
}

func (o *Pont) read() {
	fmt.Scan(&o.x)
	fmt.Scan(&o.y)
}

func (o *Pont) add(oo Pont) {
	o.x += oo.x
	o.y += oo.y
}

func (o *Pont) eq(oo Pont) bool {
	return o.x == oo.x && o.y == oo.y
}

func isRA(A, B, C Pont) bool {
	AB := Pont{B.x - A.x, B.y - A.y}
	AC := Pont{C.x - A.x, C.y - A.y}
	return 0 == AB.x*AC.x+AB.y*AC.y
}

func isRATRI(A, B, C Pont) bool {
	if A.eq(B) || A.eq(C) || B.eq(C) {
		return false
	}
	return isRA(A, B, C) || isRA(B, A, C) || isRA(C, A, B)
}

func main() {

	var (
		P     [3]Pont
		dir   = [4]Pont{Pont{0, 1}, Pont{1, -1}, Pont{-1, -1}, Pont{-1, 1}}
		delta = Pont{1, 0}
		i, j  int32
	)

	P[0].read()
	P[1].read()
	P[2].read()
	if isRATRI(P[0], P[1], P[2]) {
		fmt.Println("RIGHT")
		return
	}

	almost := false

outer:
	for i = 0; i < 3; i++ {
		for j = 0; j < 4; j++ {
			P[i].add(dir[j])
			//			fmt.Println(P)
			if isRATRI(P[0], P[1], P[2]) {
				almost = true
				break outer
			}
		}
		// ez a j-s ciklusban volt
		P[i].add(delta)

	}

	if almost {
		fmt.Println("ALMOST")

	} else {
		fmt.Println("NEITHER")
	}

}


package main

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

var r *bufio.Reader = bufio.NewReader(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

type Vertice struct {
	X int
	Y int
}

func dist(a, b Vertice) int {
	x, y := a.X-b.X, a.Y-b.Y
	return x*x + y*y
}

func isRight(a, b, c Vertice) bool {
	es := []int{dist(a, b), dist(b, c), dist(c, a)}
	sort.Ints(es)

	return es[0]+es[1] == es[2]
}

func getAdjs(v Vertice) []Vertice {
	return []Vertice{Vertice{v.X - 1, v.Y}, Vertice{v.X + 1, v.Y}, Vertice{v.X, v.Y - 1}, Vertice{v.X, v.Y + 1}}
}

func solve(a, b, c Vertice) string {
	if isRight(a, b, c) {
		return "RIGHT"
	}

	for i := 0; i < 3; i++ {
		var v1, v2, v3 Vertice
		switch i {
		case 0:
			v1, v2, v3 = a, b, c
		case 1:
			v1, v2, v3 = b, c, a
		case 2:
			v1, v2, v3 = c, a, b
		}
		adjs := getAdjs(v1)
		for _, v := range adjs {
			if isRight(v, v2, v3) {
				return "ALMOST"
			}
		}
	}

	return "NEITHER"
}

func main() {
	defer w.Flush()

	a, b, c := Vertice{}, Vertice{}, Vertice{}
	fmt.Fscanf(r, "%d %d %d %d %d %d", &a.X, &a.Y, &b.X, &b.Y, &c.X, &c.Y)

	fmt.Fprintf(w, "%v", solve(a, b, c))
}


package main

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

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

var memo map[int]int

func pow3(n, m int) int {
	x, present := memo[n]
	if present {
		return x
	}
	x = (pow3(n/2, m) * pow3(n-n/2, m)) % m
	memo[n] = x
	return x
}

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

	n := scanInt(scanner)
	m := scanInt(scanner)
	memo = map[int]int{ 0: 1%m, 1: 3%m }
	x := pow3(n, m) - 1
	if x == -1 {
		x = m-1
	}
	writer.WriteString(fmt.Sprintf("%d\n", x))
}


package main

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

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

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

	n := int64(scanInt(scanner))
	m := int64(scanInt(scanner))
	x := int64(1)
	for i := int64(1); i <= n; i++ {
		x *= 3
		if x >= m {
			x = ((x%m)*(n/i))%m
			for j := n%i; j != 0; j-- {
				x *= 3
				if x >= m {
					x %= m
				}
			}
			break
		}
	}
	x--
	if x == -1 {
		x = m-1
	}
	writer.WriteString(fmt.Sprintf("%d\n", x))
}


package main

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

func main(){
	var n, m int64
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.ParseInt(r.Text(), 0, 64)
	r.Scan()
	m, _ = strconv.ParseInt(r.Text(), 0, 64)
	var a int64 = 3
	var b int64 = 1
	for n > 0 {
		if n%2 != 0 {
			b = (b*a)%m
		}
		a = (a*a)%m
		n = n/2
	}
	w.WriteString(strconv.FormatInt((b-1+m)%m, 10)+"\n")
	w.Flush()
}


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


package main

import (
	"fmt"
	"math"
)

var allLuckNumber[] int64

func dfs(dep int, number int64, num4, num7 int){
	if num4 == num7{
		allLuckNumber = append(allLuckNumber, number)
	}
	if dep > 10{
		return;
	}
	dfs(dep + 1, number * 10 + 4, num4 + 1, num7)
	dfs(dep + 1, number * 10 + 7, num4, num7 + 1)
}

func main(){
	var n, ans int64
	ans = math.MaxInt64
	dfs(0, 4, 1, 0)
	dfs(0, 7, 0 ,1)
	fmt.Scan(&n)
	for _,each := range allLuckNumber{
		if each >= n && each < ans{
			ans = each
		}
	}
	fmt.Println(ans)

}


//  URL: http://codeforces.com/contest/96/problem/B
//  ~ Basic Implementation Problem, Brute Force. DP version can be found in
//  95B, where constraints are big (can't just generate all permutations).

package main

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

func isSuperLuckyNumber(n string) bool {
	return strings.Count(n, "4") == strings.Count(n, "7")
}

func _solve(s string, minLength int, maxLength int, queue []string, answers []string) string {
	elem := queue[0]
	if minLength <= len(elem) && len(elem) <= maxLength {
		elemInt, _ := strconv.Atoi(elem)
		sInt, _ := strconv.Atoi(s)
		if isSuperLuckyNumber(elem) && sInt <= elemInt {
			return elem
		}
	}
	if len(elem) <= maxLength {
		queue = append(queue, elem+"4")
		queue = append(queue, elem+"7")
		answers = append(answers, elem)
		return _solve(s, minLength, maxLength, queue[1:], answers)
	}
	return _solve(s, minLength, maxLength, queue[1:], answers)
}

func findMinAndMaxLength(s string) (int, int) {
	if len(s)%2 == 0 {
		return len(s), len(s) + 2
	}
	return len(s) + 1, len(s) + 1
}

func solve(s string) string {
	minLength, maxLength := findMinAndMaxLength(s)
	return _solve(s, minLength, maxLength, []string{"4", "7"}, []string{})
}

func main() {
	reader, writer := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	var s string
	fmt.Fscanf(reader, "%s", &s)
	fmt.Fprintln(writer, solve(s))
}


// 257A-mic_rizal
package main

import (
    "fmt"
    "sort"
)

func main() {
    var n, m, k, i, x, l int
    fmt.Scan(&n, &m, &k)
    var a []int
    for i = 1; i <= n; i++ {
        fmt.Scan(&x)
        a = append(a, x)
        l++
    }
    sort.Sort(sort.IntSlice(a))
    pos := n - 1
    for k < m && pos >= 0 {
        k += a[pos] - 1
        pos--
    }
    if k < m {
        fmt.Println("-1")
    } else {
        fmt.Println(n - pos - 1)
    }
}


package main

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

func main(){
	var n, m, k int
	var a [50]int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	m, _ = strconv.Atoi(r.Text())
	r.Scan()
	k, _ = strconv.Atoi(r.Text())
	sum := 0
	x := 0
	i := 0
	for i=0; i<n; i++ {
		r.Scan()
		x, _ = strconv.Atoi(r.Text())
		a[x-1] += 1
	}
	for m>k {
		for i=49; i>=0; i-- {
			if a[i] > 0 {
				k += i;
				a[i] -= 1
				sum += 1
				break
			}
		}
		if i<0 {
			w.WriteString("-1\n")
			w.Flush()
			return
		}
	}
	w.WriteString(strconv.Itoa(sum)+"\n")
	w.Flush()
}


// 257A
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)
	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	sort.Sort(sort.IntSlice(a))
	for i := 0; i < n; i++ {
		if x >= m {
			fmt.Print(i)
			return
		} else {
			x += a[n-i-1] - 1
		}
	}
	if x >= m {
		fmt.Print(n)
	} else {
		fmt.Print(-1)
	}
}


package main

import (
    "fmt"
    "sort"
)

func main() {
    var n,m,k int
    fmt.Scan(&n,&m,&k)
    a := make([]int,n)
    for i := 0; i < n; i++ {
        fmt.Scan(&a[i])
    }
    sort.Ints(a)
    for ; (k > 0) && (m > 0); k-- {
        if (m <= k) { m = 0; break; }
        if k == 1 {
            for (len(a) != 0) && (a[len(a)-1] > 1){
                m -= a[len(a)-1]
                a = a[:len(a)-1]
                if (m > 0) { m++ } else { break }
            }
        } else {
            if len(a) != 0 {
                m -= a[len(a)-1]
                a = a[:len(a)-1]
            } else {
                m--
            }
        }
    }
    if (m > 0) { fmt.Println(-1) } else { fmt.Println(n-len(a)) }
}


package main

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

func main(){
	var n, m, k int
	var a [50]int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	n, _ = strconv.Atoi(r.Text())
	r.Scan()
	m, _ = strconv.Atoi(r.Text())
	r.Scan()
	k, _ = strconv.Atoi(r.Text())
	sum := 0
	x := 0
	i := 0
	for i:=0; i<n; i++ {
		r.Scan()
		x, _ = strconv.Atoi(r.Text())
		a[x-1] += 1
	}
	for m>k {
		for i:=49; i>=0; i-- {
			if a[i] > 0 {
				k += i;
				a[i] -= 1
				sum += 1
				break
			}
		}
		if i<0 {
			w.WriteString("-1")
			return
		}
	}
	w.WriteString(strconv.Itoa(sum)+"\n")
	w.Flush()
}


package main

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

type SA []int

func (s SA) Len() int {
	return len(s)
}

func (s SA) Swap(a, b int) {
	tmp := s[a]
	s[a] = s[b]
	s[b] = tmp
}
func (s SA) Less(i, j int) bool {
	if s[i] < s[j] {
		return true
	}
	return false
}
func tryS(mat SA, n int, m int64, day int) bool {
	dcnt := 0
	k := 0
	var sum int64 = 0
	for i := n-1; i >= 0; i-- {
		if mat[i] > k {
			dcnt++
			sum += int64(mat[i] - k)
		}else{
			continue
		}
		if dcnt == day {
			k++
			dcnt = 0
		}
		if sum >= m {
			break
		}
	}
	if sum >= m {
		return true
	} else {
		return false
	}
}
func solveD(mat SA, n int, m int64) int {
	l := 1
	r := n
	ans := -1
	var sum int64 = 0
	for i := 0; i < n; i++ {
		sum += int64(mat[i])
	}
	if sum < m {
		return -1
	}
	for l <= r {
		mid := ((l + r) >> 1)
		if tryS(mat, n, m, mid) {
			ans = mid
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return ans
}
func main() {
	var n int
	var m int64
	buf := bufio.NewReader(os.Stdin)
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	mat := make(SA, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(buf, "%d", &mat[i])
	}
	sort.Sort(mat)
	fmt.Printf("%d\n", solveD(mat, n, m))
}


package main

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

const mod =  998244353
var n, m, L, R int

func pw(a int, b int) int {
	if a == 0 {
		if b == 0 {
			return 1
		}
		return 0
	}
	var ret = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret = int(int64(ret) * int64(a) % mod)
			b--
		} else {
			a = int(int64(a) * int64(a) % mod)
			b /= 2
		}
	}
	return ret
}

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d %d %d", &n, &m, &L, &R)

	var diff = R - L + 1
	var odd = diff / 2
	var evn = diff / 2

	if diff % 2 != 0 {
		if L % 2 == 0 {
			evn++
		} else {
			odd++
		}
	}

	var T = int(int64(n) * int64(m) % (mod - 1))
	var ret = pw(evn + odd, T)
	ret = (ret + pw(evn - odd + mod, T)) % mod

	if ret < 0 {
		ret += mod
	}

	if int64(n) * int64(m) % 2 == 1 {
		evn, odd = odd, evn
		ret += pw(evn + odd, T)
		ret %= mod
		ret += pw(evn - odd + mod, T)
		ret %= mod
	}

	ret = int(int64(ret) * int64(pw(2, mod - 2)) % mod)
	fmt.Fprintf(writer, "%d", ret)
}


package main

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

const mod =  998244353
var n, m, L, R int

func pw(a int, b int) int {
	if a == 0 {
		if b == 0 {
			return 1
		}
		return 0
	}
	var ret = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret = int(int64(ret) * int64(a) % mod)
			b--
		} else {
			a = int(int64(a) * int64(a) % mod)
			b /= 2
		}
	}
	return ret
}

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d %d %d", &n, &m, &L, &R)

	var diff = R - L + 1
	var odd = diff / 2
	var evn = diff / 2

	if diff % 2 != 0 {
		if L % 2 == 0 {
			evn++
		} else {
			odd++
		}
	}

	var T = int(int64(n) * int64(m) % (mod - 1))
	var ret = pw(evn + odd, T)
	ret = (ret + pw(evn - odd, T)) % mod

	if ret < 0 {
		ret += mod
	}

       // review
	ret = int(int64(ret) * int64(pw(2, mod - 2)) % mod)
	fmt.Fprintf(writer, "%d", ret)
}


package main

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

const mod =  998244353
var n, m, L, R int

func pw(a int, b int) int {
	if a == 0 {
		if b == 0 {
			return 1
		}
		return 0
	}
	var ret = 1
	for b > 0 {
		if (b & 1) == 1 {
			ret = int(int64(ret) * int64(a) % mod)
			b--
		} else {
			a = int(int64(a) * int64(a) % mod)
			b /= 2
		}
	}
	return ret
}

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d %d %d", &n, &m, &L, &R)

	var diff = R - L + 1
	var odd = diff / 2
	var evn = diff / 2

	if diff % 2 != 0 {
		if L % 2 == 0 {
			evn++
		} else {
			odd++
		}
	}

	var T = int(int64(n) * int64(m) % (mod - 1))
	var ret = pw(evn + odd, T)
	ret = (ret + pw(evn - odd, T)) % mod

	if ret < 0 {
		ret += mod
	}

	ret = int(int64(ret) * int64(pw(2, mod - 2)) % mod)
	fmt.Fprintf(writer, "%d", ret)
}


package main

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

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

const mod =  998244353
const N = 2
var n, m, L, R int

type matrix struct {
	f[N][N] int64
}

func print_out(a matrix)  {
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			fmt.Fprintf(writer, "%d ", a.f[i][j])
		}
		fmt.Fprintf(writer, "\n")
	}
}

func mul(a matrix, b matrix) matrix {
	var c = matrix{}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			for k := 0; k < N; k++ {
				c.f[i][j] += a.f[i][k] * b.f[k][j]
				c.f[i][j] %= mod
			}
		}
	}
	return c
}

func pw(a matrix, b int64) matrix {
	var ret = matrix{}
	for i := 0; i < N; i++ {
		ret.f[i][i] = 1
	}

	for b > 0 {
		if (b & 1) == 1 {
			ret = mul(ret, a)
			b--
		} else {
			a = mul(a, a)
			b /= 2
		}
	}
	return ret
}

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

	var O = int64(R - L + 1) / 2
	var E = int64(R - L + 1) / 2
	if (R - L + 1) % 2 != 0 {
		if L%2 == 0 {
			E++
		} else {
			O++
		}
	}

	var T = int64(n) * int64(m)

	var mt = matrix{}
	mt.f[0][0] = E
	mt.f[0][1] = O
	mt.f[1][0] = O
	mt.f[1][1] = E

	//print_out(mt)

	mt = pw(mt, T - 1)

	//print_out(mt)

	var dp_odd = O
	var dp_evn = E

	var fn_dp_odd = mt.f[0][0] * dp_odd % mod + mt.f[1][0] * dp_evn % mod
	fn_dp_odd %= mod

	var fn_dp_evn = mt.f[1][0] * dp_odd % mod + mt.f[1][1] * dp_evn % mod
	fn_dp_evn %= mod

	var ret int64
	if T % 2 == 1 {
		ret = (fn_dp_odd + fn_dp_evn) % mod
	} else {
		ret = fn_dp_evn
	}

	fmt.Fprintf(writer, "%d", ret)
}


package main

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

const mod =  998244353
var n, m, L, R int

func pw(a int64, b int64) int64 {
	if a == 0 {
		if b == 0 {
			return 1
		}
		return 0
	}
	var ret = int64(1)

	for b > 0 {
		if (b & 1) == 1 {
			ret = ret * a % mod
			b--
		} else {
			a = a * a % mod
			b /= 2
		}
	}
	return ret
}

func main()  {
	var reader = bufio.NewReader(os.Stdin)
	var writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	fmt.Fscanf(reader, "%d %d %d %d", &n, &m, &L, &R)

	var diff = R - L + 1
	var odd = diff / 2
	var evn = diff / 2

	if diff % 2 != 0 {
		if L % 2 == 0 {
			evn++
		} else {
			odd++
		}
	}

	var T = int64(n) * int64(m)

	var ret = pw(int64(evn + odd), T)
	ret = (ret + pw(int64(evn - odd + mod), T)) % mod

	if ret < 0 {
		ret += mod
	}

	if T % 2 == 1 {
		evn, odd = odd, evn
		ret += pw(int64(evn + odd), T)
		ret %= mod
		ret += pw(int64(evn - odd + mod), T)
		ret %= mod
	}

	ret = ret * pw(2, mod - 2) % mod
	fmt.Fprintf(writer, "%d", ret)
}


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


package main

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

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

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

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

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

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    a := ReadInt32()
    m := ReadInt32()
    f := false
    d := make(map[int]bool)

    for {
        q := a % m
        if q == 0 {
            f = true
            break
        } else if _, r := d[q]; r {
            f = false
            break
        } else {
            d[q] = true
            a += q
        }
    }

    if f {
        writer.WriteString("Yes\n")
    } else {
        writer.WriteString("No\n")
    }
}


package main

import (
	"fmt"
)

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


package main

import (
	"fmt"
)

func main() {
	var a, m int
	fmt.Scanf("%d %d ", &a, &m)
	var b [111111]int
	for i := 0; i <= m; i++ {
		b[i] = 0
	}
	for {
		if a == 0 {
			fmt.Printf("Yes\n")
			break
		}
		if b[a] == 1 {
			fmt.Printf("No\n")
			break
		}
		b[a] = 1
		a += a % m
		a %= m
	}
}


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


package main

import (
	"fmt"
)

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

}


package main

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

func main() {

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

	var n int

	fmt.Fscan(input, &n)

	fmt.Println(2*n*(n-1) + 1)

}


package main

import (
    "fmt"
)

func main() {
    var n int
    fmt.Scanf("%d", &n)
    ans := 1
    x := 4
    for i := 2; i <= n; i++ {
        ans += x
        x += 4
    }
    fmt.Println(ans)
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf ( "%d", &n )
	ans := 1
	for i := 1 ; i <= n ; i++ {
		ans += i * 2
		ans += 2 * ( i - 2 )
	}

	fmt.Println ( ans )
}


package main

import (
    "fmt"
)

func main() {
    var x int
    fmt.Scan(&x)
    fmt.Println(x * x + (x - 1) * (x - 1))
}


package main

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

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

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

	fmt.Fscan(input, &n)

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

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

	fmt.Println(d[n])

}


// Author: sighduck
// URL: https://codeforces.com/contest/1180/problem/A

package main

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

func Solve(n int) int {
	return 2*n*n - 2*n + 1
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

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

	fmt.Fprintf(writer, "%d\n", Solve(n))
}


package main

import "fmt"

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

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

func main(){
	var n int
	fmt.Scanln(&n)
	fmt.Println(2 * n * (n - 1) + 1)
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()

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

	fmt.Fscanf(reader, "%d\n", &n)

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

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

	fmt.Fprintf(writer, "%d\n", d[n])
}


package main

import (
	"fmt"
	//"sort"
	//"math"
)

func main() {
	var m,x,y int
	var a [100]int
	s,t:=0,0
	flag:=false
    	fmt.Scan(&m)
	for i:=0;i<m;i++ {
	    	fmt.Scan(&a[i])
	    	t+=a[i]
	}
	fmt.Scan(&x,&y)
	for i:=0;i<m;i++ {
		s+=a[i]
		if s>=x && s<=y && t-s>=x && t-s<=y {
			fmt.Println(i+2)
			flag=true
		}
	}
	if flag==false {
		fmt.Println("0")
	}
}


// hey project main.go
package main

import (
    "fmt"
)

func main() {
    var m, sum, try, x, y int
    fmt.Scan(&m)
    ar := make([]int, m)
    for i := 0; i < m; i++ {
        fmt.Scan(&ar[i])
        sum += ar[i]
    }
    fmt.Scan(&x, &y)
    //fmt.Print(sum, "\n")
    for i := 0; i < m; i++ {
        try += ar[i]
        //fmt.Print("try%y:", try%y)
        //fmt.Print("i:", i, "try:", try, "\n")

        if try%y >= x || (try%x <= y-x && try >= y) {
            if (sum-try)%y >= x || ((sum-try)%x <= y-x && (sum-try) >= y) {
                fmt.Print(i + 2)
                return
            }
        }
    }
    fmt.Print(0)
}


// hey project main.go
package main

import (
    "fmt"
)

func main() {
    var m, sum, try, x, y int
    fmt.Scan(&m)
    ar := make([]int, m)
    for i := 0; i < m; i++ {
        fmt.Scan(&ar[i])
        sum += ar[i]
    }
    fmt.Scan(&x, &y)
    //fmt.Print(sum, "\n")
    for i := 0; i < m; i++ {
        try += ar[i]
        //fmt.Print("try%y:", try%y)
        //fmt.Print("i:", i, "try:", try, "\n")

        if try%y > x || (try%x <= y-x && try > y) {
            if (sum-try)%y > x || ((sum-try)%x <= y-x && (sum-try) > y) {
                fmt.Print(i + 2)
                return
            }
        }
    }
    fmt.Print(0)
}


// hey project main.go
package main

import (
    "fmt"
)

func main() {
    var m, sum, try, x, y int
    fmt.Scan(&m)
    ar := make([]int, m)
    for i := 0; i < m; i++ {
        fmt.Scan(&ar[i])
        sum += ar[i]
    }
    fmt.Scan(&x, &y)
    //fmt.Print(sum, "\n")
    for i := 0; i < m; i++ {
        try += ar[i]
        //fmt.Print("try%y:", try%y)
        //fmt.Print("i:", i, "try:", try, "\n")

        if try%y >= x || (try%x <= y-x && try >= y) {
            if (sum-try)%y > x || ((sum-try)%x <= y-x && (sum-try) >= y || (sum-try) == x) {
                fmt.Print(i + 2)
                return
            }
        }
    }
    fmt.Print(0)
}


package main

import "fmt"

func main() {
    var m,x,y int
    var c [105]int
    fmt.Scan(&m)
    group2 := 0
    for i := 1; i <= m; i++ {
        fmt.Scan(&c[i])
        group2 += c[i]
    }
    fmt.Scan(&x,&y)
    ans, group1 := 1, 0
    for ((group1 < x) || (group1 > y) || (group2 < x) || (group2 > y)) && (ans <= m) {
        group1 += c[ans]
        group2 -= c[ans]
        ans++
    }
    if ans <= m { fmt.Println(ans) } else { fmt.Println(0) }
}


package main

import "fmt"

func main() {
    var m,x,y int               // membuat variabel m, x, dan y dengan tipe data int
    var c [105]int              // membuat variabel c dengan tipe data array of int dengan ukuran 105
    fmt.Scan(&m)                // menerima input nilai m
    group2 := 0                 // membuat variabel group2 dengan tipe int dengan nilai awal 0
    for i := 1; i <= m; i++ {   // looping sebanyak m kali
        fmt.Scan(&c[i])         // menerima input nilai c[i]
        group2 += c[i]          // tambahkan nilai c[i] ke group2
    }
    fmt.Scan(&x,&y)             // menerima input nilai x dan y
    ans, group1 := 1, 0         // membuat variabel ans tipe int dengan nilai awal 1 dan group1 tipe int dengan nilai awal 0
    for ((group1 < x) || (group1 > y) || (group2 < x) || (group2 > y)) && (ans <= m) { // jika group1,group2 < x dan group1,group2 > y dan ans <= m
        group1 += c[ans]        // maka group1 ditambahkan dengan c[ans]
        group2 -= c[ans]        // group2 dikurangi dengan c[ans]
        ans++                   // ans ditambahkan dengan 1
    }
    if ans <= m { fmt.Println(ans) } else { fmt.Println(0) }    // jika ans <= m, maka cetak output nilai dari ans. Jika tidak, cetak output nilai 0
}


package main

import (
	"fmt"
	//"sort"
	//"math"
)

func main() {
	var m,x,y int
	var a [100]int
	s,t:=0,0
	flag:=false
    	fmt.Scan(&m)
	for i:=0;i<m;i++ {
	    	fmt.Scan(&a[i])
	    	t+=a[i]
	}
	fmt.Scan(&x,&y)
	for i:=0;i<m;i++ {
		s+=a[i]
		if s>=x && s<=y && t-s>=x && t-s<=y {
			fmt.Println(i+2)
			flag=true
			break
		}
	}
	if flag==false {
		fmt.Println("0")
	}
}


// hey project main.go
package main

import (
    "fmt"
)

func main() {
    var m, sum, try, x, y int
    fmt.Scan(&m)
    ar := make([]int, m)
    for i := 0; i < m; i++ {
        fmt.Scan(&ar[i])
        sum += ar[i]
    }
    fmt.Scan(&x, &y)
    //fmt.Print(sum, "\n")
    for i := 0; i < m; i++ {
        try += ar[i]
        //fmt.Print("try%y:", try%y)
        //fmt.Print("i:", i, "try:", try, "\n")

        if try <= y && try >= x {
            if (sum-try) <= y && (sum-try) >= x {
                fmt.Print(i + 2)
                return
            }
        }
    }
    fmt.Print(0)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var r, h float64
	fmt.Scan(&r, &h)
	h, count := h-r*math.Floor(h/r), 2*int(h/r)
	if h+r >= r*(math.Sqrt(3)/2+1) {
		count += 3
	} else if h >= r/2 {
		count += 2
	} else {
		count += 1
	}
	fmt.Println(count)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var r, h float64
	fmt.Scan(&r, &h)
	h, count := h-r*math.Floor(h/r), 2*int(h/r)
	if h >= r*(math.Sqrt(3)+6)/4 {
		count += 3
	} else if h >= r/2 {
		count += 2
	} else {
		count += 1
	}
	fmt.Println(count)
}


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

func vk(s string) int {
	return strings.Count(s, "VK")
}

func main() {
	var arr []byte
	var c byte
	var max int
	for {
		fmt.Scanf("%c", &c)
		if c == '\n' {
			break
		}
		arr = append(arr, c)
	}
	for i := 0; i < len(arr); i++ {
		if arr[i] == 'V' {
			arr[i] = 'K'
			if vk(string(arr)) > max {
				max = vk(string(arr))
			}
			arr[i] = 'V'
		} else {
			arr[i] = 'V'
			if vk(string(arr)) > max {
				max = vk(string(arr))
			}
			arr[i] = 'K'
		}
	}
	fmt.Println(max)
}


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"
	"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, a, b int
	fmt.Fscan(r, &n)
	k := make([]int, 0, n)
	sum := 0
	koa := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a)
		if i == 0 {
			b = a
			koa = a
			k = append(k, 1)
		}
		if i > 0 && b/2 >= a {
			koa += a
			k = append(k, i+1)
		}
		sum += a
	}
	if koa >= sum/2 {
		fmt.Fprintln(w, len(k))
		for i, e := range k {
			if i == 0 {
				fmt.Fprintf(w, "%d", e)
			} else {
				fmt.Fprintf(w, " %d", e)
			}
		}
	} else {
		fmt.Fprintln(w, 0)
	}

}


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, a, b int
	fmt.Fscan(r, &n)
	k := make([]int, 0, n)
	sum := 0
	koa := 0
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &a)
		if i == 0 {
			b = a
			koa = a
			k = append(k, 1)
		}
		if i > 0 && b/2 >= a {
			koa += a
			k = append(k, i+1)
		}
		sum += a
	}
	if 2 * koa > sum {
		fmt.Fprintln(w, len(k))
		for i, e := range k {
			if i == 0 {
				fmt.Fprintf(w, "%d", e)
			} else {
				fmt.Fprintf(w, " %d", e)
			}
		}
	} else {
		fmt.Fprintln(w, 0)
	}

}


package main

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

const (
	EPS = 1e-8
)

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

type Light struct {
	p complex128
	a float64
}

type Line struct {
	p1, p2 complex128
}

func CrossProduct(a complex128, b complex128) float64 {
	return real(a)*imag(b) - real(b)*imag(a)
}

func Roatate(x complex128, a float64) complex128 {
	r, t := cmplx.Polar(x)
	return cmplx.Rect(r, t+a)
}

func Intersact(a Line, b Line) (intersaction complex128, isIntersact bool) {
	s1 := CrossProduct(a.p2-a.p1, b.p1-a.p1)
	s2 := CrossProduct(a.p2-a.p1, b.p2-a.p1)
	if math.Abs(s2-s1) >= EPS {
		isIntersact = true
		intersaction = complex(real(b.p1)*s2-real(b.p2)*s1, imag(b.p1)*s2-imag(b.p2)*s1) / complex(s2-s1, 0.0)
	}
	return
}

func foo(l float64, lit Light, r float64) float64 {
	v1 := complex(l-real(lit.p), 0-imag(lit.p))
	v2 := Roatate(v1, lit.a)
	if imag(v2) > -EPS {
		return r
	}

	p1 := complex(0.0, 0.0)
	p2 := complex(100.0, 0.0)
	inter, _ := Intersact(Line{lit.p, lit.p + v2}, Line{p1, p2})
	return real(inter)
}

func main() {
	var (
		n    int
		l, r float64
		lits []Light
	)

	fmt.Fscan(reader, &n, &l, &r)
	for i := 0; i < n; i++ {
		var x, y, a float64
		fmt.Fscan(reader, &x, &y, &a)
		lits = append(lits, Light{complex(x, y), a * math.Pi / 180.0})
	}

	f := make([]float64, 1<<uint(n))
	for i := range f {
		f[i] = l
	}
	for i := 0; i < (1 << uint(n)); i++ {
		for j := 0; j < n; j++ {
			if k := i | 1<<uint(j); i != k {
				cur := foo(f[i], lits[j], r)
				if cur > f[k] {
					f[k] = cur
				}
			}
		}
	}
	fmt.Print(math.Min(f[(1<<uint(n))-1]-l, r-l))
}


package main

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

const (
	EPS = 1e-8
)

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

type Light struct {
	p complex128
	a float64
}

type Line struct {
	p1, p2 complex128
}

func CrossProduct(a complex128, b complex128) float64 {
	return real(a)*imag(b) - real(b)*imag(a)
}

func Roatate(p complex128, a float64) complex128 {
	return p * complex(math.Cos(a), math.Sin(a))
}

func Intersact(a Line, b Line) (intersaction complex128, isIntersact bool) {
	var (
		s1 = CrossProduct(a.p2-a.p1, b.p1-a.p1)
		s2 = CrossProduct(a.p2-a.p1, b.p2-a.p1)
		s  = s2 - s1
	)
	if math.Abs(s) >= EPS {
		isIntersact = true
		intersaction = complex((real(b.p1)*s2-real(b.p2)*s1)/s, (imag(b.p1)*s2-imag(b.p2)*s1)/s)
	}
	return
}

func foo(l float64, lit Light, r float64) float64 {
	v1 := complex(l-real(lit.p), 0-imag(lit.p))
	v2 := Roatate(v1, lit.a)
	if imag(v2) > -EPS {
		return r
	}

	p1 := complex(0.0, 0.0)
	p2 := complex(100.0, 0.0)
	inter, _ := Intersact(Line{lit.p, lit.p + v2}, Line{p1, p2})
	return real(inter)
}

func main() {
	var (
		n    int
		l, r float64
		lits []Light
	)

	fmt.Fscan(reader, &n, &l, &r)
	for i := 0; i < n; i++ {
		var x, y, a float64
		fmt.Fscan(reader, &x, &y, &a)
		lits = append(lits, Light{complex(x, y), a * math.Pi / 180.0})
	}

	f := make([]float64, 1<<uint(n))
	for i := range f {
		f[i] = l
	}
	for i := 0; i < (1 << uint(n)); i++ {
		for j := 0; j < n; j++ {
			if k := i | 1<<uint(j); i != k {
				cur := foo(f[i], lits[j], r)
				if cur > f[k] {
					f[k] = cur
				}
			}
		}
	}
	fmt.Print(math.Min(f[(1<<uint(n))-1]-l, r-l))
}


package main

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

const (
	EPS = 1e-8
)

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

type Light struct {
	p complex128
	a float64
}

type Line struct {
	p1, p2 complex128
}

func CrossProduct(a complex128, b complex128) float64 {
	return real(a)*imag(b) - real(b)*imag(a)
}

func Roatate(x complex128, a float64) complex128 {
	r, t := cmplx.Polar(x)
	return cmplx.Rect(r, t+a)
}

func Intersact(a Line, b Line) (intersaction complex128, isIntersact bool) {
	s1 := CrossProduct(a.p2-a.p1, b.p1-a.p1)
	s2 := CrossProduct(a.p2-a.p1, b.p2-a.p1)
	if math.Abs(s2-s1) >= EPS {
		isIntersact = true
		intersaction = complex(real(b.p1)*s2-real(b.p2)*s1, imag(b.p1)*s2-imag(b.p2)*s1) / complex(s2-s1, 0.0)
	}
	return
}

func foo(l float64, lit Light, r float64) float64 {
	v1 := complex(l-real(lit.p), 0-imag(lit.p))
	v2 := Roatate(v1, lit.a)
	if imag(v2) > -EPS {
		return r
	}

	p1 := complex(0.0, 0.0)
	p2 := complex(10.0, 0.0)
	inter, _ := Intersact(Line{lit.p, lit.p + v2}, Line{p1, p2})
	return real(inter)
}

func main() {
	var (
		n    int
		l, r float64
		lits []Light
	)

	fmt.Fscan(reader, &n, &l, &r)
	for i := 0; i < n; i++ {
		var x, y, a float64
		fmt.Fscan(reader, &x, &y, &a)
		lits = append(lits, Light{complex(x, y), a * math.Pi / 180.0})
	}

	f := make([]float64, 1<<uint(n))
	for i := range f {
		f[i] = l
	}
	for i := 0; i < (1 << uint(n)); i++ {
		for j := 0; j < n; j++ {
			if k := i | 1<<uint(j); i != k {
				cur := foo(f[i], lits[j], r)
				if cur > f[k] {
					f[k] = cur
				}
			}
		}
	}
	fmt.Print(f[(1<<uint(n))-1] - l)
}


package main

import "fmt"

var x, k, A, B, res int64

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


package main

import "fmt"

var x, k, A, B, res int64

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


package main

import "fmt"

var x, k, A, B, res int64

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


package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return a * b % n
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	p, q := 1, 1
	for i := 0; i < k; i++ {
		p = mul(p, n - i)
		q = mul(q, i + 1)
	}
	return mul(p, inv(q))
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	p := 0
	h += 1
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b + kb - 1, kb - 1)
			c1 := cnk(a - ka * h + ka - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}


package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return a * b % n
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

var facts []int
var ifacts []int

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	return mul(mul(facts[n], ifacts[k]), ifacts[n-k])
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	p := 0
	h += 1
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b + kb - 1, kb - 1)
			c1 := cnk(a - ka * h + ka - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	m := 200100
	facts = make([]int, m)
	ifacts = make([]int, m)
	facts[0] = 1
	for i := 1; i < m; i++ {
		facts[i] = mul(facts[i-1], i)
	}
	ifacts[m-1] = inv(facts[m-1])
	for i := m-2; i >= 0; i-- {
		ifacts[i] = mul(ifacts[i+1], i+1)
	}
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}


package main

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

const (
	n = 1000000007
)

func sum(a, b int) int {
	s := a + b
	if s >= n {
		return s - n
	}
	return s
}

func mul(a, b int) int {
	return a * b % n
}

func g0(a, b, h, w int) int {
	if a == 0 && b == 0 {
		return 1
	}
	var s int
	for x := h + 1; x <= a; x++ {
		s += g0(b, a - x, w, h)
	}
	return s
}

func f0(a, b int) int {
	if a == 0 || b == 0 {
		return 1
	}
	var s int
	for x := 1; x <= a; x++ {
		s += f0(b, a - x)
	}
	return s
}

func power(a, n int) int {
	r := 1
	for n > 0 {
		if (n & 1) != 0 {
			r = mul(r, a)
		}
		n /= 2
		if n > 0 {
			a = mul(a, a)
		}
	}
	return r
}

func inv(a int) int {
	return power(a, n - 2)
}

var facts []int
var ifacts []int

func cnk(n, k int) int {
	if k < 0 || k > n || n < 0 {
		return 0
	}
	return mul(mul(facts[n], ifacts[k]), ifacts[n-k])
}

func f1(a, b int) int {
	return sum(cnk(a + b - 1, a), cnk(a + b - 1, b))
}

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

func solve(a, b, h int) int {
	q := f1(a, b)
	p := 0
	h += 1
	for ka := 1; ka * h <= a; ka++ {
		for kb := max(1, ka - 1); kb <= ka + 1 && kb <= b; kb++ {
			c0 := cnk(b - 1, kb - 1)
			c1 := cnk(a - ka * (h - 1) - 1, ka - 1)
			// fmt.Printf("%d %d %d %d\n", ka, kb, c0, c1)
			d := mul(c0, c1)
			if ka == kb {
				p = sum(p, d)
			}
			p = sum(p, d)
		}
	}
	return mul(p, inv(q))
}

func main() {
	m := 200100
	facts = make([]int, m)
	ifacts = make([]int, m)
	facts[0] = 1
	for i := 1; i < m; i++ {
		facts[i] = mul(facts[i-1], i)
	}
	ifacts[m-1] = inv(facts[m-1])
	for i := m-2; i >= 0; i-- {
		ifacts[i] = mul(ifacts[i+1], i+1)
	}
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	a := cin.nextInt()
	b := cin.nextInt()
	h := cin.nextInt()
	fmt.Printf("%d\n", solve(b, a, h))
}

// some io

type ParserReader struct {
	r   io.ByteReader
	err error
	c   byte
}

func NewParser(r io.ByteReader) *ParserReader {
	return &ParserReader{r, nil, 0}
}

func (p *ParserReader) next() error {
	p.c, p.err = p.r.ReadByte()
	return p.err
}

func isDigit(c byte) bool {
	return '0' <= c && c <= '9'
}

func (p *ParserReader) nextUInt64() uint64 {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint64
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint64(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextUInt() uint {
	for !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var r uint
	for isDigit(p.c) && p.err == nil {
		r = r*10 + uint(p.c - '0')
		p.next()
	}
	return r
}

func (p *ParserReader) nextInt64() int64 {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int64(p.nextUInt64())
	if sign {
		return -r
	}
	return r
}

func (p *ParserReader) nextInt() int {
	for p.c != '-' && !isDigit(p.c) && p.err == nil {
		p.next()
	}
	var sign bool
	if p.c == '-' {
		sign = true
	}
	r := int(p.nextUInt())
	if sign {
		return -r
	}
	return r
}