package main

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

func main() {
	sc := NewScanner()
	N, K := sc.NextInt64(), sc.NextInt64()

	Div2 := int64(0)
	Div5 := int64(0)
	tmp := N
	for tmp%2 == 0 {
		tmp /= 2
		Div2++
	}

	for tmp%5 == 0 {
		tmp /= 5
		Div5++
	}
	for i := int64(0); i < K-Div2; i++ {
		N *= 2
	}
	for i := int64(0); i < K-Div5; i++ {
		N *= 5

	}

	fmt.Println(N)

}

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

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

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

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

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

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

func main() {
	defer w.Flush()
	var n uint64
	for I(&n, "\n") == nil {
		solve(n)
	}
}

func solve(n uint64) {
	a, b, c := uint64(1234567), uint64(123456), uint64(1234)
	for i := uint64(0); i <= n/a; i++ {
		aa := a * i
		for j := uint64(0); j <= (n-aa)/b; j++ {
			bb := aa + j*b
			if (n-bb)%c == 0 {
				O("YES", "\n")
				return
			}
		}
	}
	O("NO", "\n")
}


package main

import (
	"fmt"
)

func main() {
	const house int = 1234567
	const car int = 123456
	const computer int = 1234

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

	ok := false
	for i := 0; i <= n/house; i++ {
		for j := 0; j <= (n-house*i)/car; j++ {
			if (n-house*i-car*j)%computer == 0 {
				ok = true
				break
			}
		}
		if ok {
			break
		}
	}

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


package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	a, _ := in.ReadString('\n')
	a = strings.Trim(a, "\r\n")
	n, _ := strconv.ParseInt(string(a), 10, 64)
	for a := int64(0); a <= 1000; a++ {
		for b := int64(0); b <= 1000; b++ {
			if c := (n - a*1234567 - b*123456) / 1234; c >= 0 && a*1234567+b*123456+c*1234 == n {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}


package main

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

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

	queue := make([]int, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan() && i < n; i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		queue[i] = a
	}

	buses := 0
	seats := 0
	for i := 0; i < n; i++ {
		if seats < queue[i] {
			buses++
			seats = m - queue[i] // queue[i] <= m
		} else {
			seats -= queue[i]
		}
	}

	fmt.Println(buses)
}


// 435A-mic
package main

import (
    "fmt"
)

func main() {
    var n, m, x, t, c int
    fmt.Scan(&n, &m)
    for n > 0 {
        fmt.Scan(&x)
        if t+x > m {
            c++
            t = x
        } else {
            t += x
        }
        n--
    }
    fmt.Println(c + 1)
}


package main

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

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

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

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

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

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

func solve(n int) {
	var m int
	I(&m, "\n")
	o := 0
	ans := 1
	for i := 0; i < n; i++ {
		var t int
		s := " "
		if i == n-1 {
			s = "\n"
		}
		I(&t, s)
		if o+t <= m {
			o += t
		} else {
			ans++
			o = t
		}
	}
	O(ans, "\n")
}


/*
URL:
https://codeforces.com/contest/1452/problem/D
*/

package main

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

var (
	n int64

	// A, B [200000+50]int64
	a, b int64
	dp   [200000 + 50]int64
)

func main() {
	defer stdout.Flush()

	n = readll()

	dp[0] = 1
	a = 1
	for i := int64(1); i <= n; i++ {
		if i%2 == 1 {
			dp[i] += a
			dp[i] %= MOD

			b += dp[i]
			b %= MOD
		} else {
			dp[i] += b
			dp[i] %= MOD

			a += dp[i]
			a %= MOD
		}

		// dp[i] %= MOD
		// a %= MOD
		// b %= MOD
	}

	// debugf("dp[:n+1]: %v\n", dp[:n+1])
	// debugf("dp[n]: %v\n", dp[n])

	d := modpow(2, n, MOD)

	ans := dp[n] * ModInv(d, MOD)
	ans %= MOD

	fmt.Println(ans)
}

// ModInv returns $a^{-1} mod m$ by Fermat's little theorem.
// O(1), but C is nearly equal to 30 (when m is 1000000000+7).
func ModInv(a, m int64) int64 {
	return modpow(a, m-2, m)
}

func modpow(a, e, m int64) int64 {
	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := modpow(a, halfE, m)
		return half * half % m
	}

	return a * modpow(a, e-1, m) % m
}

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

/********** common constants **********/

const (
	// MOD = 1000000000 + 7
	MOD     = 998244353
	ALPH_N  = 26
	INF_I64 = math.MaxInt64
	INF_B60 = 1 << 60
	INF_I32 = math.MaxInt32
	INF_B30 = 1 << 30
	NIL     = -1
	EPS     = 1e-10
)

/********** bufio setting **********/

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

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

// min returns the min integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func min(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m > integer {
			m = integer
		}
	}
	return m
}

// max returns the max integer among input set.
// This function needs at least 1 argument (no argument causes panic).
func max(integers ...int) int {
	m := integers[0]
	for i, integer := range integers {
		if i == 0 {
			continue
		}
		if m < integer {
			m = integer
		}
	}
	return 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 *int, target int) bool {
	if *updatedValue > target {
		*updatedValue = target
		return true
	}
	return false
}

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

// sum returns multiple integers sum.
func sum(integers ...int) int {
	var s int
	s = 0

	for _, i := range integers {
		s += i
	}

	return s
}

// abs is integer version of math.Abs
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

// pow is integer version of math.Pow
// pow calculate a power by Binary Power (二分累乗法(O(log e))).
func pow(a, e int) int {
	if a < 0 || e < 0 {
		panic(errors.New("[argument error]: PowInt does not accept negative integers"))
	}

	if e == 0 {
		return 1
	}

	if e%2 == 0 {
		halfE := e / 2
		half := pow(a, halfE)
		return half * half
	}

	return a * pow(a, e-1)
}

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

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

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

//str := reads()
//i := readi()
//X := readis(n)
//S := readrs()
//a := readf()
//A := readfs(n)

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

/*********** Input ***********/

var (
	// reads returns a WORD string.
	reads  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()
	}
}

// readi returns an integer.
func readi() int {
	return int(_readInt64())
}
func readi2() (int, int) {
	return int(_readInt64()), int(_readInt64())
}
func readi3() (int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64())
}
func readi4() (int, int, int, int) {
	return int(_readInt64()), int(_readInt64()), int(_readInt64()), int(_readInt64())
}

// readll returns as integer as int64.
func readll() int64 {
	return _readInt64()
}
func readll2() (int64, int64) {
	return _readInt64(), _readInt64()
}
func readll3() (int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64()
}
func readll4() (int64, int64, int64, int64) {
	return _readInt64(), _readInt64(), _readInt64(), _readInt64()
}

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

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

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

// readf returns an float64.
func readf() float64 {
	return float64(_readFloat64())
}

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

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

// readrs returns a rune slice.
func readrs() []rune {
	return []rune(reads())
}

/*********** Output ***********/

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

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

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

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

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


package main

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

// github.com/EndlessCheng/codeforces-go
func run(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const mod = 998244353
	pow := func(x, n int64) int64 {
		x %= mod
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	inv := func(a int64) int64 { return pow(a, mod-2) }
	div := func(a, b int64) int64 { return a%mod * inv(b) % mod }
	var n int
	Fscan(in, &n)
	f := make([]int64, n+10)
	f[0] = 1
	f[1] = div(1, 2)
	f[2] = div(1,4)
	for i := 3; i <= n; i++ {
		f[i] = div(2*f[i-1]+f[i-2],4)
	}
	Fprint(out, f[n])
}

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


package main

import (
	"fmt"
)

const (
	mod = 998244353
	i2  = (mod + 1) / 2
)

func main() {
	n := 0
	fmt.Scanf("%d", &n)
	f, f1 := uint32(1), uint32(0)
	for i := 1; i < n; i++ {
		f, f1 = (f+f1)%mod, f
	}

	fmt.Printf("%d\n", (uint64(f)*exp(i2, n))%mod)
}

func exp(a uint64, p int) (r uint64) {
	r = 1
	for ; p > 0; p /= 2 {
		if p%2 == 1 {
			r = (a * r) % mod
		}
		a = (a * a) % mod
	}
	return r
}


package main

import "fmt"

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

func main() {
    var n,x int
    fmt.Scan(&n)
    a := -1
    for i := 0; i < n ; i++ {
        fmt.Scan(&x)
        if a == -1 { a = x } else { a = gcd(a,x) }
    }
    fmt.Println(a*n)
}


// 389A-mic
package main

import (
    "fmt"
    "math/big"
)

func gcd(x, y int64) int64 {
    return new(big.Int).GCD(nil, nil, big.NewInt(x), big.NewInt(y)).Int64()
}

func main() {
    var n, g, k, i int64
    fmt.Scan(&n, &g)
    for i = 1; i < n; i++ {
        fmt.Scan(&k)
        g = gcd(g, k)
    }
    fmt.Println(g * n)
}


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

package main

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

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

func main() {
	defer writer.Flush()

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

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

	ans := int64(0)
	for i:=int64(0);i<(int64(1) << n);i++ {
		sum := int64(0)
		min := int64(math.MaxInt64)
		max := int64(math.MinInt64)
		for j:=int64(0);j<n;j++ {
			if i & (int64(1) << j) != 0 {
				if min > arr[j] {
					min = arr[j]
				}
				if max < arr[j] {
					max = arr[j]
				}
				sum += arr[j]
			}
		}

		if sum >= l && sum <= r && (max-min) >= x {
			ans++
		}
	}

	printf("%d\n", ans)

}


package main

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

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

	c := make([]int, n)
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; i < n && scanner.Scan(); i++ {
		_c, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}
		c[i] = _c
	}

	ways := 0

	mask := (1 << uint(n)) - 1
	for mask > 0 {
		m := mask

		cnt := 0
		sum := 0
		max := -1
		min := -1
		for i := 0; i < n; i++ {
			v := m % 2
			if v == 1 {
				cnt++
				sum += c[i]
				if c[i] > max {
					max = c[i]
				}
				if c[i] < min || min < 0 {
					min = c[i]
				}
			}
			m /= 2
		}
		if cnt >= 2 && sum >= l && sum <= r && max-min >= x {
			ways++
		}

		mask -= 1
	}

	fmt.Println(ways)
}


package main

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

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

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

	n, l, r, x := nextInt(), nextInt(), nextInt(), nextInt()
	c := make([]int, n)
	cnt := 0

	for i := range c {
		c[i] = nextInt()
	}

	sort.Ints(c)

	for i := 0; i < (1 << uint(n)); i++ {
		sum := 0
		min, max := -1, -1

		for j := 0; j < n; j++ {
			if ((1 << uint(j)) & i) > 0 {
				sum += c[j]

				if min == -1 {
					min = j
				}
				max = j
			}
		}

		if min != max && c[max]-c[min] >= x && sum >= l && sum <= r {
			cnt++
		}
		// println(i, sum, min, max)
	}

	println(cnt)
}

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

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

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

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

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

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


package main

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

type in struct {
	Scanner *bufio.Scanner
}

func (in *in) s() string {
	in.Scanner.Scan()
	return in.Scanner.Text()
}
func (in *in) i() int {
	ret, _ := strconv.ParseInt(in.s(), 10, 32)
	return int(ret)
}
func (in *in) i64() int64 {
	ret, _ := strconv.ParseInt(in.s(), 10, 64)
	return ret
}
func (in *in) f() float64 {
	ret, _ := strconv.ParseFloat(in.s(), 64)
	return ret
}
func (in *in) ss(n int64) []string {
	a := make([]string, n)
	for i := range a {
		a[i] = in.s()
	}
	return a
}
func (in *in) is(n int64) []int64 {
	a := make([]int64, n)
	for i := range a {
		a[i] = in.i64()
	}
	return a
}
func (in *in) fs(n int64) []float64 {
	a := make([]float64, n)
	for i := range a {
		a[i] = in.f()
	}
	return a
}
func (in *in) imat(h int64, w int64) [][]int64 {
	a := make([][]int64, h)
	for y := range a {
		a[y] = make([]int64, w)
		for x := range a[y] {
			a[y][x] = in.i64()
		}
	}
	return a
}

func stdin() in {
	scn := bufio.NewScanner(os.Stdin)
	scn.Split(bufio.ScanWords)
	max := 1048576
	buf := make([]byte, max)
	scn.Buffer(buf, max)
	return in{Scanner: scn}
}

type arr []int

func (a arr) Len() int {
	return len(a)
}

func (a arr) Less(i, j int) bool {
	return a[i] < a[j]
}

func (a arr) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

const maxn = 2e5 + 7
const inf = 0x3f3f3f3f

func main() {
	in := stdin()
	n, k := in.i(), in.i()
	ar := make([]arr, maxn)
	for i := 0; i < n; i++ {
		for x, cnt := in.i(), 0; x > 0; x /= 2 {
			ar[x] = append(ar[x], cnt)
			cnt++
		}
	}
	ans := inf
	for i := 0; i < maxn; i++ {
		if len(ar[i]) < k {
			continue
		}
		sort.Sort(ar[i])
		sum := 0
		for j := 0; j < k; j++ {
			sum += ar[i][j]
		}
		if sum < ans {
			ans = sum
		}
	}
	fmt.Println(ans)
}


package main

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

/* solution */

type nodeType struct {
	next [2]*nodeType
	// count of digits need to be removed
	// ...from the end of binary value (count of divisions by 2)
	// ...to make an added value equal to the current
	cuts [20]int
	cnt  int
}

func solve() {

	n, k := readInt(), readInt()
	root := &nodeType{}

	for i := 0; i < n; i++ {

		v := readInt()

		digits := make([]int, 0)
		for v > 0 {
			// reversed binary representation of the value
			digits = append(digits, v%2)
			v = v / 2
		}

		addToTree(root, digits, len(digits))

	}

	printInt(search(root, k))

}

func search(node *nodeType, k int) int {

	if node == nil || node.cnt < k {
		return 1000000000 // INF
	}

	s0 := 0
	rem := k - node.cuts[0] // how many equal values do we need more
	for i := 1; rem > 0 && i < 20; i++ {
		if rem > node.cuts[i] {
			s0 += node.cuts[i] * i
			rem -= node.cuts[i]
		} else {
			s0 += rem * i
			rem = 0
		}
	}

	s1, s2 := search(node.next[0], k), search(node.next[1], k)

	return min(s0, min(s1, s2))

}

func addToTree(node *nodeType, digits []int, idx int) {

	node.cnt++
	node.cuts[idx]++

	idx--
	if idx < 0 {
		return
	}

	next := node.next[digits[idx]]
	if next == nil {
		node.next[digits[idx]] = &nodeType{}
		next = node.next[digits[idx]]
	}

	addToTree(next, digits, idx)

}

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

/* stubs */

func main() {

	var f *os.File
	if runtime.GOROOT() == "C:\\Soft\\Go" {
		f, _ = os.Open("input.txt")
		defer f.Close()
	} else {
		f = os.Stdin
	}

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

	reader = bufio.NewScanner(f)

	const maxCapacity = 1024 * 1024
	buf := make([]byte, maxCapacity)
	reader.Buffer(buf, maxCapacity)

	reader.Split(bufio.ScanWords)

	solve()

}

var reader *bufio.Scanner
var writer *bufio.Writer

func read() string {
	reader.Scan()
	return reader.Text()
}

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

func print(s string) {
	writer.WriteString(s)
	writer.WriteString("\n")
}

func printInt(i int) {
	print(strconv.Itoa(i))
}

func printInt64(i int64) {
	print(strconv.FormatInt(i, 10))
}

func readInt64() int64 {
	reader.Scan()
	ret, _ := strconv.ParseInt(reader.Text(), 10, 64)
	return ret
}


package main

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

var scanner *bufio.Scanner

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

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

  height, p := getI(), getI()
  flip := map[rune]rune{ 'L': 'R', 'R': 'L' }
  expect := 'L'
  span := int64(1 << uint64(height-1))
  result := int64(0)
  for span != 0 {
    actual := 'L'
    if p > span {
      actual = 'R'
      p -= span
    }
    if expect == actual {
      result += 1
    } else {
      result += 2*span
    }
    //writer.WriteString(fmt.Sprintf("p %d, span %d, expect %c, actual %c\n",
    //    p, span, expect, actual))
    span /= 2
    expect = flip[actual]
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

import (
	"fmt"
)

func main() {
	var h uint
	var n uint64
	fmt.Scan(&h, &n)
	n--
	n += (1 << h)
	z := uint64(0)
	for k := h; k > 0; k-- {
		x := uint64(1 << k)
		y := uint64(x >> 1)
		switch ((n & x) >> k) ^ ((n & y) >> (k - 1)) {
		case 1:
			z++
		case 0:
			z += x
		}
	}
	fmt.Println(z)
}


package main

import "fmt"

func getCnt(n int64) int64 {
  var sum int64
  for k:= int64(2); k*k*k <= n; k++ {
    sum += n/(k*k*k)
  }
  return sum
}

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

  var lo, hi int64
  lo = 1
  hi = 9223372036854775807
  for lo+1 < hi {
    mid := (lo+hi)/2
    sum := int64(0)
    for k:= int64(2); k*k*k <= mid; k++ {
      sum += mid/(k*k*k)
    }
    if sum >= m {
      hi = mid
    } else {
      lo = mid
    }
  }
  hiCnt := getCnt(hi)
  if hiCnt == m {
    fmt.Println(hi)
  } else {
    fmt.Println(-1)
  }
}


package main

import "fmt"

func pointCount(i int64) int64 {
	var sum int64
	for j:=int64(2); j*j*j < i + 1; j++ {
		sum += i / (j*j*j)
	}
	return sum
}

func solve(m int64) int64 {
	var lo, hi, mid int64
    lo = int64(0)
	hi = int64(5000000000000000)
	for lo + 1 < hi {
		mid = (lo + hi) / 2
		if pointCount(mid) < m {
			lo = mid
		} else {
			hi = mid
		}
	}
	if pointCount(hi) == m {
		return hi
	} else {
		return -1
	}
}

func main()  {
	var m int64
  	fmt.Scan(&m)
	fmt.Println(solve(m))
}


package main

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

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

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

func getCount(x int64) int64 {
  count := int64(0)
  limit := int64(math.Floor(math.Pow(float64(x), 0.34)))
  for k := int64(2); k <= limit; k++ {
    count += x / (k * k * k)
  }
  return count
}

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

  m := getI64()
  low, high := int64(1), int64(8000000000000000)
  for low < high {
    x := (low + high) / 2
    y := getCount(x)
    if y > m {
      high = x - 1
    } else if y < m {
      low = x + 1
    } else {
      high = x
    }
  }
  x := low
  y := getCount(x)
  if y != m {
    x = -1
  }
  writer.WriteString(fmt.Sprintf("%d\n", x))
}


package main

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

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

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

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

	maxline, line, pos, a := 0, 0, 0, 0

	for i := 0; i < n; i++ {
		a = nextInt()

		line = a / m

		if a % m > 0 {
			line++
		}

		if line >= maxline {
			maxline = line
			pos = i
		}
	}

	println(pos + 1)
}

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

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

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

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

func print(a ...interface{}) {
	fmt.Fprint(writer, a...)
}

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


package main

import (
    "fmt"
    )

type child struct {
    index   int
    left    int
}

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

    an := make([]child, 2*n, 2*n)
    for i := 0; i < n; i++ {
        var a int
        fmt.Scan(&a)
        an[i].left = a
        an[i].index = i+1
    }

    left := n
    ans := n
    for left > 0 {
        tmp := left
        left = 0
        for i := 0; i < tmp; i++ {
            if an[i].left > m {
                an[n+left].index, an[n+left].left = an[i].index, an[i].left-m
                left++
            }
        }
        if left == 0 {
            ans = an[tmp-1].index
            break
        }
        for i := n; i < left+n; i++ {
            an[i-n].index, an[i-n].left = an[i].index, an[i].left
        }
    }

    fmt.Println(ans)
}


package main

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

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

	n, m := 0, 0
	if scanner.Scan() {
		line := scanner.Text()
		fmt.Sscanf(line, "%d %d", &n, &m)
	}

	if scanner.Scan() {
		line := scanner.Text()
		tokens := strings.Fields(line)
		childRequirement := make([]int, n)

		for i := 0; i < n; i++ {
			childRequirement[i], _ = strconv.Atoi(tokens[i])
		}

		childGet := make([]int, n)

		lastChild := 0
		for {
			finishes := true
			for i := 0; i < n; i++ {
				if childGet[i] < childRequirement[i] {
					childGet[i] = childGet[i] + m
					lastChild = i
				}

				if childGet[i] < childRequirement[i] {
					finishes = false
				}
			}
			if finishes {
				break
			}
		}
		fmt.Println(lastChild + 1)
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF101C(in io.Reader, out io.Writer) {
	var x, y [3]int64
	for i := 0; i < 3; i++ {
		Fscan(in, &x[i], &y[i])
	}
	d := x[2]*x[2] + y[2]*y[2]
	for i := 0; i < 4; i++ {
		x[0], y[0] = y[0], -x[0]
		dx, dy := x[1]-x[0], y[1]-y[0]
		d1, d2 := dx*x[2]+dy*y[2], dx*y[2]-dy*x[2]
		if d == 0 && dx == 0 && dy == 0 || d > 0 && d1%d == 0 && d2%d == 0 {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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


package main

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

// github.com/EndlessCheng/codeforces-go
func CF101C(in io.Reader, out io.Writer) {
	var x, y [3]int64
	for i := 0; i < 3; i++ {
		Fscan(in, &x[i], &y[i])
	}
	d := x[2]*x[2] + y[2]*y[2]
	for i := 0; i < 4; i++ {
		x[0], y[0] = y[0], x[0]
		y[0] = -y[0]
		dx, dy := x[1]-x[0], y[1]-y[0]
		d1, d2 := dx*x[2]+dy*y[2], dx*y[2]-dy*x[2]
		if d == 0 && dx == 0 && dy == 0 || d > 0 && d1%d == 0 && d2%d == 0 {
			Fprint(out, "YES")
			return
		}
	}
	Fprint(out, "NO")
}

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


package main

import "fmt"

type byteSet map[byte]bool

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

	sets := make([]byteSet, 0)
	curSet := byteSet{}

	for i := 0; i < n; i++ {
		if s[i] >= 'a' && s[i] <= 'z' {
			curSet[s[i]] = true
			if i != n-1 {
				continue
			}
		}
		sets = append(sets, curSet)
		curSet = byteSet{}
	}

	maxSet := byteSet{}

	for _, set := range sets {
		if len(set) > len(maxSet) {
			maxSet = set
		}
	}

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


package main

import (
	"fmt"
)

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

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

	set := make(map[byte]bool)

	ans := 0

	for i := 0; i < N; i++ {

		if s[i] >= 'a' && s[i] <= 'z' {
			if _, ok := set[s[i]]; !ok {
				set[s[i]] = true
				count := len(set)
				if ans < count {
					ans = count
				}
			}
		} else {
			set = make(map[byte]bool)
		}
	}

	fmt.Println(ans)
}


package main

import (
        "fmt"
)

var num int
var str string

func main() {
        fmt.Scan(&num)
        fmt.Scan(&str)
        max := 0
        pre := make(map[byte]bool)
        for i := 0; i < num; i++ {
                if str[i] >= 'a' && str[i] <= 'z' {
                        pre[str[i]] = true
                } else {
                        if len(pre) > max {
                                max = len(pre)
                        }
                        pre = make(map[byte]bool)
                }
        }
        if len(pre) > max {
                max = len(pre)
        }
        fmt.Println(max)
}


// 172B
package main

import (
	"fmt"
)

func main() {
	var x [100005]int
	var a, b, m, r int
	fmt.Scan(&a, &b, &m, &r)
	for i := 1; ; i++ {
		r = (a*r + b) % m
		if x[r] > 0 {
			fmt.Println(i - x[r])
			break
		}
		x[r] = i
	}
}


package main

import (
    "fmt"
)

var (
    a, b, x, y int
    s          string
)

var xx = []int{0}
var yy = []int{0}

func make2(a, b, delta int) int {
    if delta == 0 {
        if a == b {
            return -1
        }
        return -2
    }
    if (b-a)%delta != 0 || (b-a)/delta < 0 {
        return -2
    }
    return (b - a) / delta
}

func main() {
    fmt.Scan(&a, &b, &s)
    for _, i := range s {
        switch i {
        case 'U':
            y += 1
        case 'D':
            y -= 1
        case 'L':
            x -= 1
        case 'R':
            x += 1
        }
        xx = append(xx,x)
        yy = append(yy,y)
    }
    for i, _ := range xx {
        aa := make2(xx[i], a, x)
        bb := make2(yy[i], b, y)
        if aa == -2 || bb == -2 {
            continue
        }
        if (aa == -1) || (bb == -1) || (aa == bb) {
            fmt.Println("Yes")
            return
        }
    }
    fmt.Println("No")
}


package main

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

var sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
var w *bufio.Writer = bufio.NewWriter(os.Stdout)

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

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

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

func pri(n int)    { w.WriteString(strconv.Itoa(n)) }
func prll(n int64) { w.WriteString(strconv.FormatInt(n, 10)) }
func sp()          { w.WriteByte(' ') }
func endl()        { w.WriteByte('\n') }

func main() {
  sc.Split(bufio.ScanWords)
  a, b := nll(), nll()
  s := next()
  x, y := []int64{0}, []int64{0}
  xx, yy := int64(0), int64(0)
  for i := 0; i < len(s); i++ {
    switch s[i] {
    case 'U':
      yy++
    case 'D':
      yy--
    case 'L':
      xx--
    case 'R':
      xx++
    }
    x = append(x, xx)
    y = append(y, yy)
  }
  dx, dy := x[len(x)-1], y[len(y)-1]
  if dx != 0 && dy != 0 {
    for i := 0; i < len(s); i++ {
      if (a-x[i])%dx == 0 && (b-y[i])%dy == 0 && ((a-x[i])/dx == (b-y[i])/dy) && (a-x[i])/dx >= 0 {
        w.WriteString("Yes\n")
        w.Flush()
        return
      }
    }
  } else if dy != 0 {
    for i := 0; i < len(s); i++ {
      if (b-y[i])%dy == 0 && a == x[i] && (b-y[i])/dy >= 0 {
        w.WriteString("Yes\n")
        w.Flush()
        return
      }
    }
  } else if dx != 0 {
    for i := 0; i < len(s); i++ {
      if (a-x[i])%dx == 0 && b == y[i] && (a-x[i])/dx >= 0 {
        w.WriteString("Yes\n")
        w.Flush()
        return
      }
    }
  } else {
    for i := 0; i < len(s); i++ {
      if a == x[i] && b == y[i] {
        w.WriteString("Yes\n")
        w.Flush()
        return
      }
    }
  }
  w.WriteString("No\n")
  w.Flush()
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	reader.ReadString('\n')
	years_str, _ := reader.ReadString('\n')
	years_str = strings.Trim(years_str, "\n")

	years := strings.Split(years_str, " ")
	sort.Strings(years)

	index := len(years) / 2
	fmt.Println(years[index])
}


package main

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

func solve(n int, a []int) int {
	sort.Ints(a)
	return a[n/2]
}

func main() {
	cin := NewParser(bufio.NewReaderSize(os.Stdin, 1<<16))
	n := cin.nextInt()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = cin.nextInt()
	}
	fmt.Printf("%d\n", solve(n, a))
}

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

func main() {
	var (
		length int
		str   string
	)

	fmt.Scanf("%d\n", &length)
	fmt.Scan(&str)
	pokemons := []string {"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"}

	sameLength := make([]string, 0)
	for i := 0; i < len(pokemons); i++ {
		if len(pokemons[i]) == length {
			sameLength = append(sameLength, pokemons[i])

		}
	}

	for j := 0; j < len(sameLength); j++ {
		for i :=  0; i < len(str); i++ {
			if (str[i] == sameLength[j][i] || str[i] == '.') && (i == (len(str) - 1)) {
				fmt.Println(sameLength[j])
				return
			} else if (str[i] != sameLength[j][i]) && (str[i] != '.') {
				break
			}
		}
	}
}


package main

import "fmt"

func main() {
	var (
		length int
		str    string
	)

	fmt.Scanf("%d\n", &length)
	fmt.Scan(&str)
	pokemons := []string{"vaporeon", "jolteon", "flareon", "espeon", "umbreon", "leafeon", "glaceon", "sylveon"}

	for j := 0; j < len(pokemons); j++ {
		if len(pokemons[j]) != length {
			continue
		}
		for i := 0; i < length; i++ {

			if str[i] == pokemons[j][i] || str[i] == '.' {
				if i == (length - 1) {
					fmt.Println(pokemons[j])
					return
				}
			} else {
				break
			}
		}
	}
}


package main

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

var _, _, _ = main, rw, do

func main() {
	r, w := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer w.Flush()
	rw(r, w)
}

func rw(r io.Reader, w io.Writer) {
	var t int
	var n, k int
	fmt.Fscan(r, &t)
	for ti := 0; ti < t; ti++ {
		fmt.Fscan(r, &n, &k)
		w1 := do(n, k)
		fmt.Fprint(w, w1)
		fmt.Fprintln(w)
	}
}

func do(n, k int) int64 {
	if k == 0 {
		return 1
	}
	tk := getTk(n, k)
	gr, eq := getGrEq(n)
	r := gr + eq
	for i := 2; i <= k; i++ {
		r = (((eq * r) % mod) + ((gr * tk[i-1]) % mod)) % mod
	}
	return r
}

const mod = 1e9 + 7

func getTn(n int) []int64 {
	tn := make([]int64, n+1)
	tn[0] = 1
	for i := 1; i <= n; i++ {
		tn[i] = (tn[i-1] * 2) % mod
	}
	return tn
}

func getTk(n, k int) []int64 {
	tk := make([]int64, k+1)
	tk[0] = 1
	tn := getTn(n)
	for i := 1; i <= k; i++ {
		tk[i] = (tk[i-1] * tn[n]) % mod
	}
	return tk
}

func getGrEq(n int) (int64, int64) {
	if n == 1 {
		return 0, 2
	}
	if n == 2 {
		return 1, 1
	}
	tn := getTn(n)
	var gr, eq int64 = 0, tn[n-1]
	if n%2 == 0 {
		gr = 1
		eq = (eq + mod - 1) % mod
	} else {
		eq = (eq + 1) % mod
	}
	return gr, eq
}


package main
import (
"fmt"
"bufio"
"os"
)

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

const mod int = 1000000007
const Mod = int64(mod)

func pw(n, k int) int {
	ret := 1
	pv := n % mod
	for ; k > 0; k >>= 1 {
		if (k & 1) > 0 {
			ret = int(int64(ret) * int64(pv) % Mod)
		}
		pv = int(int64(pv) * int64(pv) % Mod)
	}
	return ret
}

func main(){
	// your code goes here
	defer writer.Flush()
	var (
		t, n, k int
	)
	fmt.Fscan(reader, &t)
	for id := 0; id < t; id++ {
		fmt.Fscan(reader, &n, &k)
		if n % 2 == 1 {
			fmt.Fprintln(writer, pw(pw(2,n-1) + 1, k))
		} else {
			ans := pw(pw(2, n-1) - 1, k)
			for j := 1; j <= k; j++ {
				v := int64(n) * int64(j-1) % (Mod - int64(1))
				ans += int( int64(pw(pw(2, n-1) - 1, k-j)) * int64(pw(2, int(v))) % Mod)
				ans %= mod
			}
			fmt.Fprintln(writer, ans)
		}
	}
}


package main

import "fmt"

func main() {
	var n, a, b, cnt uint
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}
		if a > b {
			a, b = b, a
		}
		if (b & 1) > 0 {
			b++
		}
		res := b - a
		cnt = 1
		for res > 1 {
			a = (a + 1) >> 1
			b = (b + 1) >> 1
			if (b & 1) > 0 {
				b++
			}
			res = b - a
			cnt++
		}
		if n == (1 << cnt) {
			fmt.Println("Final!")
		} else {
			fmt.Println(cnt)
		}
	}
}


package main

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

func Init() {
}

func Solve(io *FastIO) {
  N := io.NextInt()
	A := io.NextInt()
	B := io.NextInt()

	rounds := 0
	rem := N
	for rem > 1 {
	  rounds++
	  rem >>= 1
	}

	teams := make([]int, 0)
	for i := 1; i <= N; i++ {
	  teams = append(teams, i)
	}

	which := -1
	for r := 1; which < 0; r++ {
	  next := make([]int, 0)
	  for i := 0; i < len(teams); i += 2 {
	    if isOr(A, teams[i], teams[i + 1]) && isOr(B, teams[i], teams[i + 1]) {
	      which = r
	      break
	    }
	    if isOr(A, teams[i], teams[i + 1]) {
	      next = append(next, A)
	    } else if isOr(B, teams[i], teams[i + 1]) {
	      next = append(next, B)
	    } else {
	      next = append(next, teams[i])
	    }
	  }
	  teams = next
	}

	if which == rounds {
	  io.Println("Final!")
	} else {
	  io.Println(which)
	}
}

func isOr(x, a, b int) bool {
  return x == a || x == b
}

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

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

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

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

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

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

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

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

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

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

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

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

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

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

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

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


package main

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

var scanner *bufio.Scanner

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

func getNext(x int64) int64 {
  //fmt.Fprintf(os.Stderr, "in: %d\n", x)
  digits := []int64{}
  for x != 0 {
    digits = append(digits, x%10)
    x /= 10
  }
  carry := int64(0)
  resetIndex := -1
  for i, digit := range digits {
    if carry == 1 {
      digit++
      carry = 0
    }
    if digit <= 4 {
      if digit < 4 {
        resetIndex = i-1
      }
      digits[i] = 4
    } else if digit <= 7 {
      if digit < 7 {
        resetIndex = i-1
      }
      digits[i] = 7
    } else {
      digits[i] = 4
      resetIndex = i
      carry = 1
    }
  }
  if carry == 1 {
    digits = append(digits, 4)
  }
  for i := 0; i <= resetIndex; i++ {
    digits[i] = 4
  }
  base := int64(1)
  for _, digit := range digits {
    x += base*digit
    base *= 10
  }
  //fmt.Fprintf(os.Stderr, " -> %d\n", x)
  return x
}

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

  left, right := getI64(), getI64()
  total := int64(0)
  max := getNext(right)
  current := left-1
  for {
    next := getNext(current+1)
    if next == max {
      total += (right-current)*next
      break
    }
    total += (next-current)*next
    current = next
  }
  writer.WriteString(fmt.Sprintf("%d\n", total))
}


// 121A
package main

import (
	"fmt"
)

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

func main() {
	var a [15]int64
	var i, l, r, x, j, n1, n2 int64
	x, j = 0, 1
	fmt.Scan(&l, &r)
	for i = 0; i <= 10; i++ {
		a[i] = 0
	}
	for j <= r {
		i = 10
		a[i]++
		for a[i] > 2 {
			a[i] = 0
			i--
			a[i]++
		}
		j = 0
		for i = 1; i <= 10; i++ {
			if j > 0 && a[i] == 0 {
				break
			}
			if a[i] == 1 {
				n1 = 4
			} else {
				n1 = 0
			}
			if a[i] == 2 {
				n2 = 7
			} else {
				n2 = 0
			}
			j = j*10 + n1 + n2
		}
		if x == 0 && j >= l {
			x += j
		}
		if i <= 10 {
			continue
		}
		if j >= l {
			x += (min(j, r) - l) * j
			l = j
		}
	}
	fmt.Print(x)
}


package main

import (
  "fmt"
)

var n int32
var a int32
var b int32

func ReadData() {
  fmt.Scan(&n);
  fmt.Scan(&a);
  fmt.Scan(&b);
}

func Solve(na int32, nb int32, current int32, dbg bool) int {
  if na == 0 && nb == 0 {
    return 0;
  }

  var r0 int = 10000;
  var r1 int = 10000;
  var r2 int = 10000;
  var mode int = 4;

  if 0 < na && a <= current {
    r0 = Solve(na - 1, nb, current - a, false);
  }
  if 0 < nb && b <= current {
    r1 = Solve(na, nb - 1, current - b, false);
  }
  if current != n {
    r2 = 1 + Solve(na, nb, n, false);
  }

  result := r0
  mode = 0
  if r1 < result {
    result = r1
    mode = 1
  }
  if r2 < result {
    result = r2
    mode = 2
  }

  if dbg {
    if mode == 0 {
      Solve(na - 1, nb, current - a, true);
    } else if mode == 1 {
      Solve(na, nb - 1, current - b, true);
    } else if mode == 2 {
    r2 = 1 + Solve(na, nb, n, true);
    }
    fmt.Println("na: ", na, " nb: ", nb, " current: ", current, " result: ", result, " mode: ", mode)
  }
  return result
}

func main() {
  ReadData();
  fmt.Println(Solve(4, 2, 0, false));
}


//80B
package main
import "fmt"

func main() {
	var mm, k, l, m, n, o float32
	var hh, jam int
	fmt.Scanf("%d:%f", &hh, &mm)
	jam=hh%12
	if jam!=12 {
		k=360*float32(jam)/12
	} else {
		k=0
	}
	if n!=60 {
		o=30*mm/60
		l=360*mm/60
	} else {
		k=0
		l=0
	}
	m=k+o
	if m==0 && l==0 {
		fmt.Printf("%.0f %.0f\n", m, l)
	} else {
		fmt.Printf("%.1f %.1f\n", m, l)
	}
}


package main

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

var scanner *bufio.Scanner

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

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

  n := getI64()
  d2 := n*n

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

  result := 0
  if n > 0 {
    result += 4
  }
  if n > 1 {
    x := int64(float64(n)/math.Sqrt(2))
    if (x+1)*(x+1) + x*x > d2 {
      result += 4
    }
  }

  x, y := n, int64(0)
  for true {
    y++
    for x*x + y*y > d2 {
      x--
    }
    if x <= y {
      break
    }
    result += 8
  }

  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

import "fmt"

func main() {
	var x, h, m int
	fmt.Scanf("%d\n", &x)
	fmt.Scanf("%d %d\n", &h, &m)

	y := 0
	for m%10 != 7 && m != 7 && h != 7 && h !=17 {
		if m < x {
			m += 60
			h--
		}
		if h<0 {
			h += 24
		}
		m -= x
		y++
	}
	fmt.Println(y)
}


package main
import "bufio"
import "os"
import "strings"
import "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 PrintInts(ints ...int) {
    for _, value := range ints {
        writer.WriteString(strconv.Itoa(value))
        writer.WriteByte(' ')
	}
}

func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	var x, h, m, result int = ReadInt32(), ReadInt32(), ReadInt32(), 0
	for !strings.Contains(strings.Join([]string {strconv.Itoa(h), strconv.Itoa(m)}, ""), "7") {
		result++
		m -= x
		if m < 0 {
			m += 60
			h -= 1
			if (h < 0) {
				h += 24
			}
		}
	}
	PrintInts(result)
	writer.WriteByte('\n')
}


package main

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

var scanner *bufio.Scanner

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

var notes = []string{ "C", "C#", "D", "D#", "E", "F", "F#", "G", "G#",
                      "A", "B", "H" }

func position(a string) int {
  for i := 0; i < 12; i++ {
    if notes[i] == a {
      return i
    }
  }
  return -1
}

func distance(a, b string) int {
  i, j := position(a), position(b)
  if i <= j {
    return j-i
  } else {
    return 12+j-i
  }
  return -1
}

func kind(a, b, c string) string {
  x, y := distance(a, b), distance(b, c)
  if x == 4 && y == 3 {
    return "major"
  } else if x == 3 && y == 4 {
    return "minor"
  }
  return "strange"
}

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

  x, y, z := getS(), getS(), getS()
  permutations := [][]string{
      []string{ x, y, z },
      []string{ x, z, y },
      []string{ y, x, z },
      []string{ y, z, x },
      []string{ z, x, y },
      []string{ z, y, x },
    }
  for _, p := range permutations {
    s := kind(p[0], p[1], p[2])
    if s != "strange" {
      writer.WriteString(fmt.Sprintf("%s\n", s))
      return
    }
  }
  writer.WriteString("strange\n")
}


package main

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

var scanner *bufio.Scanner

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

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

  n, m := getI(), getI()
  x, y := 2 * n, 3 * m
  d := 0
  if x < y {
    d = x / 6
  } else {
    d = y / 6
  }

  for d > 0 {
    d--
    if x <= y {
      x += 2
      if x % 3 == 0 && x <= y {
        x += 2
      }
    } else {
      y += 3
      if y % 2 == 1 {
        continue
      }
      if y > x {
        continue
      }
      if y == x {
        y -= 3
        x += 2
        continue
      }
      y += 3
    }
  }

  result := x
  if y > x {
    result = y
  }

  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

import "fmt"

func main(){
	var n,m,t int64
	t = 0
	fmt.Scanf("%d %d\n",&n,&m)
	for ;;t++ {
		if n<=t/2 && m<=t/3 && n+m<=t/2+t/3-t/6{
			fmt.Println(t)
			break
		}
	}
}


package main

import (
	"fmt"
)

func main() {
	//input := bufio.NewScanner(os.Stdin)
	var a, b, c, n int
	fmt.Scanf("%d%d%d%d", &a, &b, &c, &n)

	if n-a-b+c < 1 || c > a || c > b || a > n || b > n {
		fmt.Printf("-1\n")
	} else {
		fmt.Printf("%d\n", n-a-b+c)
	}

}


package main

import "fmt"

func main() {
	var A, B, C, D int
	fmt.Scan(&A, &B, &C, &D)
	A -= C
	B -= C
	D -= C
	D -= (A + B)
	// fmt.Printf("A:%d B:%d C:%d D:%d\n", A, B, C, D)
	if A < 0 || B < 0 || D < 1 {
		D = -1
	}
	fmt.Println(D)
}


package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d\n%d\n", &n, &m)
	a := make([]int, 0, n)
	var ai int
	maxAi := 0
	for i := 0; i < n; i++ {
		fmt.Scanf("%d\n", &ai)
		a = append(a, ai)
		if maxAi < ai {
			maxAi = ai
		}
	}
	complement := 0
	for _, ai = range a {
		complement += maxAi - ai
	}

	if m > complement {
		rest := m - complement
		avg := rest / n
		remainder := rest % n
		if remainder == 0 {
			fmt.Println(maxAi+avg, maxAi+m)
			return
		}
		fmt.Println(maxAi+avg+1, maxAi+m)
		return
	}
	fmt.Println(maxAi, maxAi+m)
}


package main

import "fmt"
import "math"

func main() {
	var n int
	var k int
	var a int

	fmt.Scanln(&n)
	fmt.Scanln(&k)

	mini := k
	maxi := 0
	for i := 0; i < n; i++ {
		fmt.Scanln(&a)
		mini = mini + a
		maxi = int(math.Max(float64(maxi), float64(a)))
	}

	mini = int(math.Max(math.Ceil(float64(mini) / float64(n)), float64(maxi)))
	maxi = maxi + k

	fmt.Println(mini, maxi)
}


package main

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

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

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

func ceilDiv(i, div int64) int64 {
    if div == 0 {
        return 0 // should not happen
    }
    if i % div == 0 {
        return i / div
    }
    return (i / div) + 1
}

func max(i, j int64) int64 {
    if i > j {
        return i
    }
    return j
}

func main() {
    defer writer.Flush()
    var n, m int64
    scanf("%d\n", &n)
    scanf("%d\n", &m)
    total := m
    maxSoFar := int64(0)
    for i := int64(0); i < n; i++ {
        var i int64
        scanf("%d\n", &i)
        total += i
        maxSoFar = max(maxSoFar, i)
    }
    minK := max(ceilDiv(total, n), maxSoFar)
    maxK := maxSoFar + m
    printf("%d %d", minK, maxK)
}


package main

import "fmt"
import "math"

func main() {
	n, k := 0, 0
	fmt.Scanf("%d %d\n", &n, &k)
	v := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &v[i])
	}
	ans := 0
	for i := 0; i < k; i++ {
		ones, twos := 0, 0
		for j := i; j < n; j += k {
			if v[j] == 1 {
				ones++
			} else {
				twos++
			}
		}
		ans += int(math.Min(float64(ones), float64(twos)))
	}
	fmt.Println(ans)
}


package main
import (
	"fmt"
	//"sort"
	//"unicode/utf8"
)
func main() {
	var n,k,x int
	fmt.Scan(&n,&k)
	var c [334][7]int
	for i:=0;i<n;i++ {
		fmt.Scan(&x)
		c[i%k][x]++
	}
	a:=0
	for i:=0;i<k;i++ {
		//fmt.Println("masuk",i)
		if c[i][1]<c[i][2] {
			a+=c[i][1]
		} else {
			a+=c[i][2]
		}
	}
	fmt.Println(a)
}


package main

import "fmt"

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

func main() {
    var n,k int
    fmt.Scan(&n,&k)
    a := make([]int,n)
    for i := 0; i < n; i++ { fmt.Scan(&a[i]) }
    ans := 0
    for i := 0; i < k; i++ {
        one, two := 0, 0
        for j := 0; j < n/k; j++ {
            if a[i+(j*k)] == 1 { one++ } else { two++ }
        }
        ans += min(one,two)
    }
    fmt.Println(ans)
}


package main

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

func main() {
	X := int64(0)
	Y := int64(0)

	var n, bx, m, by int
	var err error

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

	scanner.Scan()
	n, err = strconv.Atoi(scanner.Text())
	if err != nil {
		return
	}

	scanner.Scan()
	bx, err = strconv.Atoi(scanner.Text())
	if err != nil {
		return
	}

	for i := 0; i < n; i++ {
		scanner.Scan()
		a, e := strconv.Atoi(scanner.Text())
		if e != nil {
			return
		}
		X += int64(math.Pow(float64(bx), float64(n-i-1))) * int64(a)
	}

	scanner.Scan()
	m, err = strconv.Atoi(scanner.Text())
	if err != nil {
		return
	}

	scanner.Scan()
	by, err = strconv.Atoi(scanner.Text())
	if err != nil {
		return
	}

	for i := 0; i < m; i++ {
		scanner.Scan()
		a, e := strconv.Atoi(scanner.Text())
		if e != nil {
			return
		}
		Y += int64(math.Pow(float64(by), float64(m-i-1))) * int64(a)
	}

	if X == Y {
		fmt.Println("=")
	} else if X > Y {
		fmt.Println(">")
	} else {
		fmt.Println("<")
	}
}


package main

import "fmt"

func intPow(x int64, y int64) (res int64) {
	res = 1
	for i := int64(0); i < y; i++ {
		res *= x
	}
	return
}

func main() {
	var n, x, y, numx, numy, t int64
	fmt.Scan(&n, &x)
	numx = 0
	for i := int64(1); i <= n; i++ {
		fmt.Scan(&t)
		numx += t * intPow(x, (n-i))
	}
	fmt.Scan(&n, &y)
	numy = 0
	for i := int64(1); i <= n; i++ {
		fmt.Scan(&t)
		numy += t * intPow(y, (n-i))
	}

	if numx == numy {
		fmt.Println("=")
	} else if numx < numy {
		fmt.Println("<")
	} else {
		fmt.Println(">")
	}
}


package main

import (
	"fmt"
)

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

	var x, dx uint64
	for i := 0; i < n; i++ {
		fmt.Scan(&dx)
		x = x*uint64(bx) + dx
	}

	var m, by int
	fmt.Scan(&m, &by)

	var y, dy uint64
	for i := 0; i < m; i++ {
		fmt.Scan(&dy)
		y = y*uint64(by) + dy
	}

	if x < y {
		fmt.Println("<")
	} else if x > y {
		fmt.Println(">")
	} else {
		fmt.Println("=")
	}
}


package main

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

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

func pow(x, p int64) int64 {
	var ret int64 = 1
	for p > 0 {
		if p % 2 == 1 {
			ret = ret * x % MOD
		}
		x = x * x % MOD
		p >>= 1
	}
	return ret
}

func powM(a [][]int64, p int64) [][]int64 {
	ret := make([][]int64, 2)
	for i := 0; i < 2; i++ {
		ret[i] = make([]int64, 2)
		ret[i][i] = 1
	}
	for p > 0 {
		if p % 2 == 1 {
			ret = mult(ret, a)
		}
		a = mult(a, a)
		p >>= 1
	}
	return ret
}

func mult(a, b [][]int64) [][]int64 {
	c := make([][]int64, 2)
	for i := 0; i < 2; i++ {
		c[i] = make([]int64, 2)
	}
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			for k := 0; k < 2; k++ {
				c[i][j] += a[i][k] * b[k][j] % MOD
			}
		}
	}
	return c
}

func main() {

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

	var n, k int64 = NextInt64(), NextInt64()
	var l int = NextInt()
	MOD = NextInt64()

	if l < 63 && 1 << uint(l) <= k {
		fmt.Fprintln(out, 0)
		return
	}

	if l == 0 {
		if k == 0 {
			fmt.Fprintln(out, 1 % MOD)
		}else {
			fmt.Fprintln(out, 0)
		}
		return
	}

	a := make([][]int64, 2)
	for i := 0; i < 2; i++ {
		a[i] = make([]int64, 2)
	}
	a[0][1], a[1][0], a[1][1] = 1, 1, 1
	a = powM(a, n - 2)
	var dp int64 = (2 * a[0][1] + 3 * a[1][1]) % MOD
	var two int64 = pow(int64(2), n)
	var ret int64 = 1
	for i := 0; i < l; i++ {
		if ((k >> uint(i)) & 1) == 0 {
			ret = ret * dp % MOD
		}else {
			ret = ret * (two - dp + MOD) % MOD
		}
	}

	fmt.Fprintln(out, ret)
}

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

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

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


package main
import (
	"fmt"
	"bufio"
	"os"
	"strconv"
)
func main() {
	var k,l,x int
	var s string
	input := bufio.NewScanner(os.Stdin)
	input.Split(bufio.ScanWords)
	input.Scan()
	s=input.Text()
	input.Scan()
	bb,_:=strconv.Atoi(input.Text())
	k=bb
	r:=make([]rune,len(s))
	var swap rune
	for i,v:=range s {
		r[i]=v
	}
	l= len(s)
	for i:=0;i<l;i++ {
		x=i
		for j:=i+1;j<l;j++ {
			if r[j]>r[x] && j-i<=k {
				x=j
			}
		}
		for j:=x;j>i;j-- {
			swap = r[j]
			r[j]=r[j-1]
			r[j-1]=swap
		}
		k-=x-i
	}
	fmt.Println(string(r))
}


// INCOMPLETE

package main

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextLong()
	K := io.NextLong()

	if K >= 1024 {
	  io.Println("No")
	  return
	}

	for i := int64(1); i <= K; i++ {
	  if (N + 1) % i != 0 {
	    io.Println("No")
	    return
	  }
	}
	io.Println("Yes")
}

func smallestDivisor(n int64) int64 {
  if n % 2 == 0 {
    return 2
  }
  for d := int64(3); d * d <= n; d += 2 {
    if n % d == 0 {
      return d
    }
  }
  return n
}

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

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

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

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

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

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

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

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

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

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

func (io *FastIO) Println(args ...interface{}) {
	io.writer.WriteString(fmt.Sprintln(args...))
}

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

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

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

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

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


package main

import . "fmt"

type vec struct {
	x, y int64
}

func (a vec) less(b vec) bool                 { return a.x < b.x || a.x == b.x && a.y < b.y }
func (a vec) sub(b vec) vec                   { return vec{a.x - b.x, a.y - b.y} }
func (a vec) dot(b vec) int64                 { return a.x*b.x + a.y*b.y }
func isOrthogonal(a, b, c vec) bool           { return a.sub(b).dot(c.sub(b)) == 0 }
func isRectangle(a, b, c, d vec) bool         { return isOrthogonal(a, b, c) && isOrthogonal(b, c, d) && isOrthogonal(c, d, a) }
func isRectangleAnyOrder(a, b, c, d vec) bool { return isRectangle(a, b, c, d) || isRectangle(a, b, d, c) || isRectangle(a, c, b, d) }

// github.com/EndlessCheng/codeforces-go
func main() {
	mp := map[vec]int{}
	shown := map[vec]int{}
	for i := 0; i < 4; i++ {
		var x, y int64
		Scan(&x, &y)
		p0 := vec{x, y}
		Scan(&x, &y)
		p1 := vec{x, y}
		if v := p1.sub(p0); v.x != 0 && v.y != 0 {
			Print("NO")
			return
		}
		mp[p0]++
		mp[p1]++
		if p1.less(p0) {
			p0, p1 = p1, p0
		}
		shown[p1.sub(p0)]++
	}
	for _, v := range shown {
		if v != 2 {
			Print("NO")
			return
		}
	}
	arr := []vec{}
	for vec, v := range mp {
		if v != 2 {
			Print("NO")
			return
		}
		arr = append(arr, vec)
	}
	if isRectangleAnyOrder(arr[0], arr[1], arr[2], arr[3]) {
		Print("YES")
	} else {
		Print("NO")
	}
}


package main

import "fmt"

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

	ans := 2 * (n / 3)
	if n%3 != 0 {
		ans++
	}

	fmt.Println(ans)
}


package main

import (
    "fmt"
)

func main() {
    var i int
    fmt.Scan(&i)
    switch  {
      case i <= 2:
        fmt.Println(1)
      case i % 3 == 0:
        fmt.Println(i / 3 * 2)
      case i % 3 != 0:
        fmt.Println(i / 3 * 2 + 1)
    }
}


package main

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

func main() {
    in := bufio.NewReader(os.Stdin)
    out := bufio.NewWriter(os.Stdout)
    defer out.Flush()
    tot := 0
    fmt.Fscan(in, &tot)
    times := (tot/3)*2
    if tot % 3 > 0 {times++}
    fmt.Fprint(out, times)
}


package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var s string
	fmt.Fscanf(reader, "%s", &s)
	count, ans := 1, 0
	for i := 1; i < len(s); i++ {
		if s[i] == s[i-1] {
			count++
		} else {
			count, ans = 1, ans+1-(count%2)
		}
	}
	ans = ans + 1 - (count % 2)
	fmt.Printf("%d", ans)

}


//http://codeforces.com/problemset/problem/391/A
//A. Genetic Engineering
// az osszes futamot figyelni kell

package main

import (
	"fmt"
)

func main() {
	var (
		nd, i, run, ans int32
		d               string
		prev, akt       byte
	)

	fmt.Scan(&d)
	nd = int32(len(d))

	//	fmt.Println(d, nd)

	prev, run = d[0], 1

	for i = 1; i < nd; i++ {
		akt = d[i]
		if prev == akt {
			run++
		} else {
			if 0 == (run % 2) {
				ans++
			}
			prev = akt
			run = 1
		}
	}
	if 0 == (run % 2) {
		ans++
	}

	fmt.Println(ans)

}


package main

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

func main() {
	// defer func(start time.Time) {
	// 	fmt.Println(time.Since(start))
	// }(time.Now())

	reader := bufio.NewReader(os.Stdin)

	var s string
	fmt.Fscan(reader, &s)
	var c uint8
	var index, count int

	// fmt.Println(s)
	for i:=0; i<len(s); i++ {
		c = s[i]
		index = 0
		for i++; i<len(s) && c==s[i]; i++ {
			index++
			// fmt.Printf("%c %d\n", s[i], i)
		}
		if index%2==1 {
			// fmt.Printf("count++ %c %d\n", c, index)
			count++
		}
		i--
	}

	fmt.Println(count)
}


package main

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

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

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

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

	strs := make(chan *string, 100)

	go inputter(rs, strs)

	str := strings.Split(*<-strs, ":")
	a , _ := strconv.ParseInt(str[0], 10, 64)
	b , _ := strconv.ParseInt(str[1], 10, 64)
	c , _ := strconv.ParseInt(*<-strs, 10, 64)

	b += c

	a += b/60
	b %= 60
	a %= 24

	ws.WriteString(fmt.Sprintf("%02d:%02d", a, b))
	ws.Flush()
}


package main

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

type vec struct{ x, y int64 }

func (a vec) sub(b vec) vec   { return vec{a.x - b.x, a.y - b.y} }
func (a vec) dot(b vec) int64 { return a.x*b.x + a.y*b.y }
func (a vec) det(b vec) int64 { return a.x*b.y - a.y*b.x }

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

	f := func(a, b, c vec) bool {
		a, b = b.sub(a), c.sub(a)
		return (a.x == 0 || a.y == 0 || b.x == 0 || b.y == 0) && a.dot(b) <= 0
	}
	var a, b, c vec
	Fscan(in, &a.x, &a.y, &b.x, &b.y, &c.x, &c.y)
	if d := b.sub(a); (d.x == 0 || d.y == 0) && d.det(c.sub(b)) == 0 {
		Fprint(out, 1)
	} else if f(a, b, c) || f(b, a, c) || f(c, a, b) {
		Fprint(out, 2)
	} else {
		Fprint(out, 3)
	}
}

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


package main

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

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	fr := func() string {
		var k, l string = readStr(), readStr()
		l = string(l[1]) + string(l[0])
		var s string = k + l
		var r string
		for _, v := range s {
			if string(v) != "X" {
				r += string(v)
			}
		}
		return r
	}
	fk := func(s string) string {
		for string(s[0]) != "A" {
			s = string(s[1:]) + string(s[0])
			// fmt.Println("..", s)
		}
		return s
	}
	var a, b string = fk(fr()), fk(fr())
	// fmt.Println("a", a)
	// fmt.Println("b", b)
	if a == b {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

var (
	sc *bufio.Scanner = bufio.NewScanner(os.Stdin)
	wr *bufio.Writer  = bufio.NewWriter(os.Stdout)
)

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

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

func printInts(ints ...int) {
	for _, v := range ints {
		wr.WriteString(strconv.Itoa(v))
		wr.WriteByte(' ')
	}
}
func printInt64s(ints ...int64) {
	for _, v := range ints {
		wr.WriteString(strconv.FormatInt(v, 10))
		wr.WriteByte(' ')
	}
}

func readStr() string {
	sc.Scan()
	return sc.Text()
}

func println() {
	wr.WriteByte('\n')
}


package main

import (
	"bufio"
	"os"
)

func main() {
	var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
	var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	scanner.Split(bufio.ScanWords) // заставляет scanner считать отдельными токенами слова, разделенные пробелами

	scanner.Scan()
	s1 := scanner.Text()
	scanner.Scan()
	s11 := scanner.Text()
	scanner.Scan()
	s2 := scanner.Text()
	scanner.Scan()
	s22 := scanner.Text()

	se := make([]byte, 0, 3)
	sb := make([]byte, 0, 3)
	for i := 0; i < 2; i++ {
		if s1[i] != 'X' {
			se = append(se, s1[i])
		}
		if s2[i] != 'X' {
			sb = append(sb, s2[i])
		}
	}
	for i := 1; i >= 0; i-- {
		if s11[i] != 'X' {
			se = append(se, s11[i])
		}
		if s22[i] != 'X' {
			sb = append(sb, s22[i])
		}
	}
	ec := 0
	eb := 0
	gse := string(se)
	gsb := string(sb)

	if gse == "ABC" || gse == "CAB" || gse == "BCA" {
		ec = 1
	}
	if gsb == "ABC" || gsb == "CAB" || gsb == "BCA" {
		eb = 1
	}
	if ec == eb {
		writer.WriteString("YES")
	} else {
		writer.WriteString("NO")
	}
}


package main

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

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

func ReadString(scanner *bufio.Scanner) string {
  scanner.Scan()
  ans := scanner.Text()
  return ans
}

func PrintInt(writer *bufio.Writer, value int) {
  writer.WriteString(strconv.Itoa(value))
  writer.WriteByte(' ')
}

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

func ReadPazzle(scanner *bufio.Scanner) string {
  r1 := ReadString(scanner)
  r2 := ReadString(scanner)

  return r1 + r2[1:] + r2[0:1]
}

func Compare(p1, p2 string) bool {
  if p1 == p2 {
    return true
  }
  p1 = p1 + p1 + p1 + p1
  return strings.Contains(p1, p2)
}

func Shift(p string) string {
  l := len(p)

  p = p[l-2:l-1] + p[0:l-1]
  return p
}

func main() {
  var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
  var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()
  scanner.Split(bufio.ScanWords)

  pz1 := ReadPazzle(scanner)
  pz2 := ReadPazzle(scanner)

  pz1 = strings.Replace(pz1, "X", "", 1)
  pz2 = strings.Replace(pz2, "X", "", 1)

  if Compare(pz1, pz2) {
    writer.WriteString("YES")
  } else {
    writer.WriteString("NO")
  }
  writer.WriteByte('\n')
  // writer.WriteByte('\n')
}


// A. Fingerprints
/*
You are locked in a room with a door that has a keypad with 10 keys corresponding to digits from 0 to 9. To escape from the room, you need to enter a correct code. You also have a sequence of digits.

Some keys on the keypad have fingerprints. You believe the correct code is the longest not necessarily contiguous subsequence of the sequence you have that only contains digits with fingerprints on the corresponding keys. Find such code.

Input
The first line contains two integers 𝑛 and 𝑚 (1≤𝑛,𝑚≤10) representing the number of digits in the sequence you have and the number of keys on the keypad that have fingerprints.

The next line contains 𝑛 distinct space-separated integers 𝑥1,𝑥2,…,𝑥𝑛 (0≤𝑥𝑖≤9) representing the sequence.

The next line contains 𝑚 distinct space-separated integers 𝑦1,𝑦2,…,𝑦𝑚 (0≤𝑦𝑖≤9) — the keys with fingerprints.

Output
In a single line print a space-separated sequence of integers representing the code. If the resulting sequence is empty, both printing nothing and printing a single line break is acceptable.

Examples
Input
7 3
3 5 7 1 6 2 8
1 2 7

Output
7 1 2

Input
4 4
3 4 1 0
0 1 7 9

Output
1 0

Note
In the first example, the only digits with fingerprints are 1, 2 and 7. All three of them appear in the sequence you know, 7 first, then 1 and then 2. Therefore the output is 7 1 2. Note that the order is important, and shall be the same as the order in the original sequence.

In the second example digits 0, 1, 7 and 9 have fingerprints, however only 0 and 1 appear in the original sequence. 1 appears earlier, so the output is 1 0. Again, the order is important.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input1, _ := reader.ReadString('\n')
	arr1 := strings.Split(strings.TrimSpace(input1), " ")

	_, _ = strconv.Atoi(arr1[0])
	_, _ = strconv.Atoi(arr1[1])

	input2, _ := reader.ReadString('\n')
	nArr := strings.Split(strings.TrimSpace(input2), " ")

	input3, _ := reader.ReadString('\n')
	mArr := strings.Split(strings.TrimSpace(input3), " ")

	for _, i := range nArr {
		for _, j := range mArr {
			if i == j {
				fmt.Printf("%v ", i)
			}
		}
	}
}


package main

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

func main() {
	sc := NewScanner()
	N, _ := sc.NextInt(), sc.NextInt()
	x := sc.NextIntArray()
	y := sc.NextMap()
	p := 0
	var ans []int
	for i := 0; i < N; i++ {
		if _, ok := y[x[i]]; ok {
			ans = append(ans, x[i])
			p++
		}
	}
	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), " "))
}

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

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

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

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

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

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

		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


package main

import "fmt"

func solve(x, y []int) (res []int) {
	n := make(map[int]bool)
	for _, v := range y {
		n[v] = true
	}

	for _, v := range x {
		_, ok := n[v]
		if ok {
			res = append(res, v)
		}
	}

	return
}

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

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

	y := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&y[i])
	}

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

	// {
	// 	x := []int{3, 5, 7, 1, 6, 2, 8}
	// 	y := []int{1, 2, 7}
	// 	fmt.Println(solve(x, y))
	// }

	// {
	// 	x := []int{3, 4, 1, 0}
	// 	y := []int{0, 1, 7, 9}
	// 	fmt.Println(solve(x, y))
	// }
}


package main

import "fmt"

func main() {
	var w, h, k int

	fmt.Scanf("%d %d %d", &w, &h, &k)

	r := 0
	for i := 0; i < k; i++ {
		c := 2*(w+h) - 4
		r += c
		h -= 4
		w -= 4
	}

	fmt.Println(r)
}


package main

import "fmt"

func main() {
	var w, h, k int
	fmt.Scanln(&w, &h, &k)

	var result int

	for i:= 1; i <= k; i++ {
		wx := w - 4 * (i - 1)
		hx := h - 4 * (i - 1)

		result += calculateGoldForSquare(wx, hx)
	}

	fmt.Println(result)
}

func calculateGoldForSquare(w, h int) int{
	return  2 * w + 2 * (h - 2)
}


package main

import "fmt"

func main() {
	var n, m, k int
	fmt.Scanf("%d %d %d", &n, &m, &k)
	ans := 2 * (n + m - 2) * k - 16 * k * (k - 1) / 2
	fmt.Println(ans)
}


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 "os"
import "bufio"
import "strconv"

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

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

	if a < 1 || b < 1 || c < 1 || d < 1 || a > 9 || b > 9 || c > 9 || d > 9 || a + b != r1 || c + d != r2 || a + c != c1 || b + d != c2 || a + d != d1 || b + c != d2 || a == b || a == c || a == d || b == c || b == d || c == d {
		w.WriteString("-1\n")
		w.Flush()
	} else {
		w.WriteString(strconv.Itoa(a)+" "+strconv.Itoa(b)+"\n")
		w.Flush()
		w.WriteString(strconv.Itoa(c)+" "+strconv.Itoa(d)+"\n")
		w.Flush()
	}
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	for i := 1; ; i++ {
		if i*i >= n {
			fmt.Println(4 * i)
			return
		}
		if i*(i+1) >= n {
			fmt.Println(4*i + 2)
			return
		}
	}
}


package main

import "fmt"

var (
    n, a, b int
)

func main() {
    fmt.Scan(&n)
    a , b = 1, 1
    for a * b < n {
        a++
        if a > b {
            a, b = b, a
        }
    }
    fmt.Println(2*(a+b))
}


package main

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

var bufin *bufio.Reader
var bufout *bufio.Writer

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()
	var n, m, k int
	fmt.Fscanf(bufin, "%d %d %d\n", &n, &m, &k)
	p := 2 * m
	lane := (k + p - 1) / p
	k -= p * (lane - 1)
	desk := (k + 1) / 2
	pos := 'L'
	if k%2 == 0 {
		pos = 'R'
	}
	fmt.Fprintf(bufout, "%d %d %c\n", lane, desk, pos)
}


package main

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

func solve() {
	readInt()
	m := readInt()
	k := readInt() - 1

	column := (k) / (m * 2)
	row := (k % (m * 2)) / 2
	row1 := (k % (m * 2)) % 2
	fmt.Printf("%d ", column+1)
	fmt.Printf("%d ", row+1)
	if row1 == 0 {
		fmt.Println("L")
	} else {
		fmt.Println("R")
	}
}

func getStats(str string) map[byte]int {
	stat := map[byte]int{}
	for _, v := range str {
		stat[byte(v)]++
	}
	return stat
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

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

func solve() {
	a := readUint64() * uint64(10000000000000)
	b := readUint64()
	c := readUint()

	base := 0
	for base < 1000 {
		d := a / b
		for i, ch := range fmt.Sprintf("%013v", d) {
			v := ch - '0'
			if uint(v) == c {
				fmt.Println(base + i + 1)
				return
			}
		}
		a = (a % b) * uint64(10000000000000)
		base += 13
	}
	fmt.Println("-1")
}

var scanner *bufio.Scanner

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

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

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

func readUint() uint {
	val, _ := strconv.ParseUint(readString(), 10, 32)
	return uint(val)
}

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

func readUint64() uint64 {
	val, _ := strconv.ParseUint(readString(), 10, 64)
	return val
}


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

package main

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

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

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

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

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

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

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

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

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

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

var (
	a, b, c int
)

func main() {
	a, b, c = ReadInt3()
	a *= 10
	for i := 1; i <= 100000; i++ {
		q := a / b
		if q == c {
			fmt.Println(i)
			return
		}

		a -= b * q
		a *= 10
	}
	fmt.Println(-1)
}

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

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

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

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

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

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

func main() {
	init_scanner()
	a, b, c := readInt(), readInt(), readInt()
	for i := 0; ; i++ {
		a *= 10
		d := a/b
		if d == c {
			fmt.Println(i+1)
			return
		}
		if t[a] {
			break
		}
		t[a] = true
		a %= b
	}
	fmt.Println(-1)
}


/*********************************************************************************
*     File Name           :     D.go
*     Created By          :     YIMMON, yimmon.zhuang@gmail.com
*     Creation Date       :     [2014-03-11 10:57]
*     Last Modified       :     [2014-03-11 11:20]
*     Description         :
**********************************************************************************/

package main

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

type Num []int

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

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

    var dp [1 << 18][100]int64
    var num []int = make([]int, 0)

    n, m := scanner.NextInt64(), int(scanner.NextInt64())
    for n > 0 {
        num = append(num, int(n%10))
        n /= 10
    }
    sort.Sort(Num(num))
    dp[0][0] = 1
    for mask := 0; mask < (1 << uint(len(num))); mask++ {
        for k := 0; k < m; k++ {
            if dp[mask][k] > 0 {
                pre := -1
                for i := 0; i < len(num); i++ {
                    if mask&(1<<uint(i)) > 0 || num[i] == pre || (mask == 0 && num[i] == 0) {
                        continue
                    }
                    dp[mask|(1<<uint(i))][(k*10+num[i])%m] += dp[mask][k]
                    pre = num[i]
                }
            }
        }
    }
    fmt.Println(dp[(1<<uint(len(num)))-1][0])
}

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) NextInt64() int64 {
    x, err := strconv.ParseInt(self.Next(), 10, 64)
    if err != nil {
        panic(err)
    }
    return x
}


package main

import (
	"fmt"
)

var count [10]int
var numbers []int

func initCount(n int64) int {
	var cnt int
	for ; n > 0; {
		count[n%10]++
		numbers = append(numbers, int(n%int64(10)))
		n /= 10
		cnt ++
	}
	return cnt
}

var dp [1<<18][100]int64

func main() {
	var n, m int64
	fmt.Scanf("%d %d", &n, &m)
	cnt := initCount(n)
	dp[0][0] = 1
	var mask int = int(uint(1)<<uint(cnt))
	for i := 1; i < mask; i++ {
		for j, mm := 0, 1; j < cnt; j, mm = j+1, mm<<uint(1) {
			if (i&mm) == 0 {
				continue
			}
			if i == mm && numbers[j] == 0 {
				continue
			}
			for k := int64(0); k < m; k++ {
				dp[i][(k*int64(10) + int64(numbers[j]))%m] += dp[i^mm][k]
			}
		}
	}

	//fmt.Println(dp[mask-1][0])

	for i := 0; i <= 9; i++ {
		for j := 2; j <= count[i]; j++ {
			dp[mask-1][0] /= int64(j)
		}
	}

	fmt.Println(dp[mask-1][0])
}


package main

import "fmt"

var s string
func main(){
    fmt.Scanf("%s", &s)
    at := false
    dot := false
    result := string(s[0])
    sz := len(s)
    for i:=1; i<sz-1; i++{
        if s[i]=='d' && i+2 != sz-1{
            dot = search(i+1, "ot")
            if dot{
                result += "."
                i+=2
                continue
            }
        }
        if s[i]=='a' && !at && i+1!= sz-1{
            at = search(i+1, "t")
            if at {
                i+=1
                result += "@"
                continue
            }
        }
        result += string(s[i])
    }
    result += string(s[sz-1])
    fmt.Println(result)
 }

 func search(i int, match string) bool{
     for j:=0; j<len(match); j++{
        if i >= len(s){
            return false
        }
        if s[i] != match[j]{
            return false
        }
        i++
     }
     return true
 }


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var a []int
	for i := 1; i <= n; i++ {
		if (1<<uint(i-1))&n > 0 {
			a = append(a, i)
		}
	}
	for i := range a {
		fmt.Print(a[len(a)-1-i])
		if i+1 == len(a) {
			fmt.Println()
		} else {
			fmt.Print(" ")
		}
	}
}


package main

import "fmt"

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

    ones := make([]int, 0, 50)
    for b := 1; n > 0; b++ {
        if n%2 == 1 {
            ones = append(ones, b)
        }
        n /= 2
    }
    for i := len(ones)-1; i >= 0; i-- {
        fmt.Print(" ", ones[i])
    }
    fmt.Println()
}


// GoIntoGo project main.go
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	for i := 16; i > -1; i-- {
		if ((n >> uint(i)) & 1) > 0 {
			fmt.Printf("%d ", i+1)
		}
	}
	fmt.Println("")
}


package main

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

func Abs(x int) int {
	switch {
	case x < 0:
		return -x
	case x == 0:
		return 0
	}
	return x
}

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

func Scan(args ...interface{}) (e error)             { _, e = fmt.Fscan(in, args...); return }
func Scanf(ft string, args ...interface{}) (e error) { _, e = fmt.Fscanf(in, ft, args...); return }
func Scanln(args ...interface{}) (e error)           { _, e = fmt.Fscanln(in, args...); return }
func Print(args ...interface{})                      { out.WriteString(fmt.Sprint(args...)) }
func Printf(ft string, args ...interface{})          { out.WriteString(fmt.Sprintf(ft, args...)) }
func Println(args ...interface{})                    { out.WriteString(fmt.Sprintln(args...)) }

var (
	dataIn = "data.in"
	in     = bufio.NewReader(os.Stdin)
	//in, _ = os.Open(dataIn)
	out = bufio.NewWriter(os.Stdout)
)

var n int64

func bis(num int64) int64 {
	l := int64(1)
	r := int64(14142136)
	for l <= r {
		mid := (l + r) >> 1
		if mid*(mid+1)/2 > num {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return r
}

func solve() {
	m := bis(n)
	if n == m*(m+1)/2 {
		Println(m)
	} else {
		Println(n - m*(m+1)/2)
	}
}

func main() {
	defer out.Flush()
	for Scan(&n) != io.EOF {
		solve()
		out.Flush()
	}
	return
}


package main

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

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

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

func tester(a int64) int64 {
	chTest := make(chan int64)
	go func(){
		for i:=int64(1) ; ;i++{
			for j := int64(1); j<=i; j++{
				chTest <- j
			}
		}
	}()
	var x int64
	for i := int64(0); i < a; i++{
		x = <-chTest
	}
	return x
}

func calculator(a int64) int64{
	x := math.Sqrt(float64(2*a))
	y := int64(x)

	for (y*(y+1))/2 >=a {
		y--
	}
	return a - (y*(y+1))/2
}

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

	strs := make(chan *string, 100)

	go inputter(rs, strs)

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

	// ws.WriteString(fmt.Sprint(tester(x1)) + "\n")
	ws.WriteString(fmt.Sprint(calculator(x1)) + "\n")

	ws.Flush()
	return
}


package main

import (
	"fmt"
	"math"
)

func valueAtPos(n int64) int64 {
	k := int64((math.Sqrt(float64(1+8*n)) - 1.) / 2.)
	n -= (k * (k + 1)) / 2
	if n == 0 {
		return k
	} else {
		return n
	}
	return -1
}

func main() {
	var n int64

	fmt.Scanf("%d", &n)
	fmt.Println(valueAtPos(n))
}