package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	n := 0
	Scan(&n)

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


package main

import (
	"fmt"
	"strings"
)

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


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n, k := 0, 0
	s := ""
	fmt.Fscanf(in, "%d %d\n", &n, &k)
	fmt.Fscanf(in, "%s\n", &s)
	//	fmt.Println(s)
	a := make([]int, 26)
	for i := 0; i < len(s); i++ {
		a[s[i]-'a'] = 1
	}
	ans := 0
	cnt := 0
	for i := 0; i < k; i++ {
		for j := 0; j < 26; j++ {
			if a[j] == 1 {
				ans += j + 1
				cnt++
				a[j] = 0
				if j+1 < 26 {
					a[j+1] = 0
				}
				break
			}
		}
	}
	//fmt.Println(ans, cnt)
	if cnt < k {
		fmt.Fprintf(out, "%d\n", -1)
	} else {
		fmt.Fprintf(out, "%d\n", ans)
	}
	return
}


package main

import "fmt"

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

func abs(num int) int {
	return max(num, -num)
}

func main() {
	var r1, c1, r2, c2 int
	fmt.Scan(&r1, &c1, &r2, &c2)
	var rook, bishop, king int
	if r1 == r2 || c1 == c2 {
		rook = 1
	} else {
		rook = 2
	}
	if (r1+c1)%2 != (r2+c2)%2 {
		bishop = 0
	} else if r1+c1 == r2+c2 || r1-c1 == r2-c2 {
		bishop = 1
	} else {
		bishop = 2
	}
	king = max(abs(r1-r2), abs(c1-c2))
	fmt.Println(rook, bishop, king)
}


package main

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

type SA []int

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

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


package main

import "fmt"

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

	ans := 0
	m := make(map[byte]bool)
	for i := 0 ; i < len(s) ; i++ {
		if s[i] >= 'a' && s[i] <= 'z' {
			m[s[i]] = true
			if len(m) > ans {
				ans = len(m)
			}
		} else {
			m = make(map[byte]bool)
		}
	}
	fmt.Println(ans)
}


package main

import "fmt"

func main() {
    var cd string
    fmt.Scan(&cd)
    if cd == "a1" || cd == "a8" || cd == "h1" || cd == "h8" {
        fmt.Print(3)
        return
    }
    if cd[0] == 'a' || cd[0] == 'h' || cd[1] == '1' || cd[1] == '8' {
        fmt.Print(5)
        return
    }
    fmt.Print(8)
}


package main

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

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

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

	_, ta, b, tb := nextInt(), nextInt(), nextInt(), nextInt()
	times := strings.Split(next(), ":")
	h, _ := strconv.Atoi(times[0])
	m, _ := strconv.Atoi(times[1])
	begin := 60*h + m
	ret := 0
	for i := 300; i < 24*60; i += b {
		// println(i, i+tb)
		if i+tb > begin && i < begin+ta {
			ret++
		}
	}

	println(ret)
	// println(begin, begin+ta)
}

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

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

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

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

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


package main
import (
	"fmt"
	"math"
)

func main() {
	var aa, xx, yy, k, l, s int
	fmt.Scan(&aa, &xx, &yy)
	if yy==0 {
		fmt.Println("-1")
		return
	}
	if yy<aa {
		if float64(aa)<2*math.Abs(float64(xx)) {
			fmt.Println("-1")
			return
		} else if float64(aa)==2*math.Abs(float64(xx)) {
			fmt.Println("-1")
			return
		} else if xx==0 && yy==0 {
			fmt.Println("-1")
		} else if xx==0 && yy>0 {
			fmt.Println("1")
		} else {
			fmt.Println("1")
		}
	} else if yy>=aa {
		k=yy-aa
		if k%aa==0 {
			fmt.Println("-1")
			return
		} else {
			s=0
			l=k/aa
			if l%2==0 {
				s=1+3*(l/2)
				if float64(aa)>2*math.Abs(float64(xx)) {
					s+=1
					fmt.Println(s)
					return
				} else {
					fmt.Println("-1")
					return
				}
			} else {
				if l>1 {
					s=2+3*(l-1)/2
				} else {
					s=2
				}
				if float64(aa)<=math.Abs(float64(xx)) {
					fmt.Println("-1")
					return
				} else {
					if xx==0 {
						fmt.Println("-1")
					} else if xx<0 {
						s+=1
						fmt.Println(s)
					} else if xx>0 {
						s+=2
						fmt.Println(s)
					}
				}
			}
		}
	}
}


package main

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

type a struct {
	days, index int
}

type aSlice []a

func (as aSlice) Len() int {
	return len(as)
}

func (as aSlice) Less(i, j int) bool {
	if as[i].days < as[j].days {
		return true
	} else {
		return false
	}
}

func (as aSlice) Swap(i, j int) {
	as[i], as[j] = as[j], as[i]
}

var readWriter = bufio.NewReadWriter(
	bufio.NewReader(os.Stdin),
	bufio.NewWriter(os.Stdout))

func main() {
	defer readWriter.Flush()

	var n, k, m int

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

	as := make(aSlice, n)

	for i := 0; i < n; i++ {
		fmt.Fscan(readWriter, &(as[i].days))
		as[i].index = i + 1
	}

	sort.Sort(as)

	for _, a := range as {
		if k-a.days < 0 {
			break
		}

		k = k - a.days
		m++
	}

	fmt.Fprintln(readWriter, m)

	for i := 0; i < m; i++ {
		fmt.Fprint(readWriter, as[i].index)
		fmt.Fprint(readWriter, " ")
	}

	if m > 0 {
		fmt.Fprintln(readWriter)
	}
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var n, m float64
	fmt.Scanf("%f %f", &n, &m)

	if m == 0 {
		fmt.Print(1)
		return
	}
	fmt.Print(int(math.Min(m, n-m)))
}


// 437A-mic_rizal
package main

import (
    "fmt"
)

var jwbncumanboleh1 int
var an string

func solve(A, B, C, D string) {
    a := len(A) - 2
    b := len(B) - 2
    c := len(C) - 2
    d := len(D) - 2
    if (2*a <= b && 2*a <= c && 2*a <= d) || (a >= 2*b && a >= 2*c && a >= 2*d) {
        an = string(A[0])
        jwbncumanboleh1++
    }
}

func main() {
    var a, b, c, d string
    fmt.Scan(&a, &b, &c, &d)
    solve(a, b, c, d)
    solve(b, a, c, d)
    solve(c, a, b, d)
    solve(d, a, b, c)

    if jwbncumanboleh1 != 1 {
        an = "C"
        fmt.Println(an)
    } else {
        fmt.Println(an)
    }
}


package main

import (
        "fmt"
)

var a int
var b int
var f int
var k int

func main() {
        fmt.Scan(&a, &b, &f, &k)
        now := b
        ans := 0
        if f > b {
                fmt.Println(-1)
        } else {
                now -= f
                d := f
                for i := 1; i < k; i++ {
                        if i&1 != 0 {
                                d = a - f
                        } else {
                                d = f
                        }
                        d <<= 1
                        if d > now {
                                ans += 1
                                now = b
                        }
                        if d > now {
                                fmt.Println(-1)
                                return
                        }
                        now -= d
                }
                if k&1 != 0 {
                        d = a - f
                } else {
                        d = f
                }
                if d > now {
                        ans += 1
                        now = b
                }
                if d > now {
                        fmt.Println(-1)
                } else {
                        fmt.Println(ans)
                }
        }
}


package main

import "fmt"

func main() {

	// get input
	var n, S int
	fmt.Scanf("%d %d", &n, &S)

	// solve
	count := 0
	for s := S; s > 0; s -= n {
		count++
	}

	// print out solution
	fmt.Println(count)
}


package main

import (
	"fmt"
	"sort"
)

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

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


package main

import "fmt"

func main() {
	var n, k, lo, hi int64
	fmt.Scan(&n, &k)
	if k != 0 && k != n {
		lo = 1
	}
	if n < k*3 {
		hi = n - k
	} else {
		hi = k * 2
	}
	fmt.Println(lo, hi)
}


// 84A-mic
package main

import (
	"fmt"
)

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


package main

import (
	"fmt"
	"io/ioutil"
	"os"
	"strconv"
	"strings"
	"text/scanner"
)

func check(e error) {
	if e != nil {
		panic(e)
	}
}

func main() {
	var w, y int // first inputs to the problem

	dat, err := ioutil.ReadAll(os.Stdin)
	check(err)
	var str_data string = string(dat);

	reader := strings.NewReader(str_data)

	var scn scanner.Scanner
	scn.Init(reader)

    scn.Scan()
	var text string = scn.TokenText();

	w, err = strconv.Atoi(text)
	check(err)

	scn.Scan()
	text = scn.TokenText();

	y, err = strconv.Atoi(text)
	check(err)

	var max int
	if w > y {
		max = w
	} else {
		max = y
	}

	// if max is 6, numerator is 1
	// if max is 1, numerator is 6
	var numerator int = 6 - max + 1

	// now let's reduce if we can
	if numerator == 6 {
		fmt.Print("1/1");
	} else if numerator == 4 {
		fmt.Print("2/3")
	} else if numerator == 3 {
		fmt.Print("1/2")
	} else if numerator == 2 {
		fmt.Print("1/3")
	} else if numerator == 1 {
		fmt.Print("1/6")
	} else {
		fmt.Print("5/6")
	}
}


package main

import (
	"fmt"
)

func main() {
	var a [3][2]int
	for i := 0; i < 3; i++ {
		if _, err := fmt.Scanf("%d %d\n", &a[i][0], &a[i][1]); err != nil {
			return
		}
	}

	m := a[0][0]
	n := a[0][1]
	for j := 0; j < 2; j++ {
		s := a[1][j]
		t := a[1][(j+1)%2]
		for k := 0; k < 2; k++ {
			u := a[2][k]
			v := a[2][(k+1)%2]

			if (s+u <= m && max(t, v) <= n) || (t+v <= n && max(s, u) <= m) {
				fmt.Println("YES")
				return
			}
		}
	}

	fmt.Println("NO")
}

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


package main

import "fmt"

func main() {
    var yc, bc uint64
    var y,g,b uint64
    var yn, bn uint64
    fmt.Scan(&yc, &bc, &y, &g, &b)
    yn = 2*y + 1*g
    bn = 1*g + 3*b
    var total uint64
    if yn > yc {
        total += yn - yc
    }
    if bn > bc {
        total += bn - bc
    }
    fmt.Print(total)
}


package main

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

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

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

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

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

	// println(n)
}

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

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

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

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

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


package main

import (
	"fmt"
	"sort"
)

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

func main() {
	n, m := 0, 0
	fmt.Scan(&n, &m)
	a := make([]int, n)
	var cuts []int
	for i := range a {
		fmt.Scan(&a[i])
	}
	odd, even := 0, 0
	for i := 0; i < n-1; i++ {
		switch a[i] % 2 {
		case 0:
			even++
		case 1:
			odd++
		}
		if odd == even {
			cuts = append(cuts, abs(a[i+1]-a[i]))
		}
	}
	sort.Ints(cuts)
	cnt := 0
	for _, v := range cuts {
		if v <= m {
			cnt++
			m -= v
		} else {
			break
		}
	}
	fmt.Println(cnt)
}


package main

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

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

func main() {
	defer out.Flush()
	in.Split(bufio.ScanWords)
	in.Scan()
	in.Scan()
	set := make(map[byte]bool)
	for _, i := range []byte(strings.ToLower(in.Text())) {
		set[i] = true
	}

	if len(set) == 26 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import "fmt"

func main(){
	for {
		t:=""
		f:="NO"
		n,_:=fmt.Scan(&t)
		if n==0{
			break
		}
		for i := 5 ;i>0;i--{
			h:=""
			n,_:=fmt.Scan(&h)
			if n==0{
				break
			}

			if h[0] == t[0]{
				f="YES"
			}else if h[1] == t[1]{
				f="YES"
			}

		}
		fmt.Println(f)

	}
}


package main

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

var scanner = bufio.NewScanner(os.Stdin)

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 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)
	s := next()
	nineteens := make([]int, 4)

	for i := range s {
		switch s[i] {
		case 'e':
			nineteens[0]++
		case 'i':
			nineteens[1]++
		case 'n':
			nineteens[2]++
		case 't':
			nineteens[3]++
		}
	}

	mins := []int{nineteens[0]/3, nineteens[1], (nineteens[2]-1)/2, nineteens[3]}
	result := mins[0]

	for i:=1; i<len(mins); i++ {
		if mins[i] < result {
			result = mins[i]
		}
	}

	fmt.Println(result)
}


package main

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

func main() {
	sc := NewScanner()
	N := sc.NextInt()
	if N == 0 {
		fmt.Println(1)
		return
	}

	ans := 0
	N--
	switch N % 4 {
	case 0:
		ans = 8
	case 1:
		ans = 4
	case 2:
		ans = 2
	case 3:
		ans = 6
	}
	fmt.Println(ans)

}

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

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

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

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

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

	return mp
}

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


package main

import (
	"fmt"
)

func main() {
	var x,y string
	fmt.Scanf("%s %s", &x, &y)
	if x == y {
		fmt.Printf(x)
	} else {
		fmt.Printf("1")
	}
}


package main

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

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

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

// Helpers

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

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

// Math

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

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

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

// IO

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

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

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

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

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

// Sort

type Ints64 []int64

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

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


package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

// Read next line as []byte.  Trailing '\n' will not be included.
// See also comments on readb()
func readbln() []byte {
	b, err := nextLine()
	if err != nil {
		panic(err)
	}
	return b[:len(b):len(b)]
}

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

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

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

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

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

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

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

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

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

// Utilities

func sumSlice(a []int) int {
	var res int
	for _, v := range a {
		res += v
	}
	return res
}

func sumSlicell(a []int64) int64 {
	var res int64
	for _, v := range a {
		res += v
	}
	return res
}

func readInts(N int) (int, []int) {
	if N == 0 {
		N = readi()
	}
	a := make([]int, N)
	for i := range a {
		a[i] = readi()
	}
	return N, a
}

func readIntsll(N int) (int, []int64) {
	if N == 0 {
		N = readi()
	}
	a := make([]int64, N)
	for i := range a {
		a[i] = readll()
	}
	return N, a
}

// reverse slice in place
func reverse(a []int) {
	for i, j := 0, len(a)-1; i < j; i, j = i+1, j-1 {
		a[i], a[j] = a[j], a[i]
	}
}

// areverse: allocating reverse
func areverse(a []int) []int {
	b := make([]int, len(a))
	for i := range a {
		b[i] = a[len(a)-i-1]
	}
	return b
}

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	n, a := readInts(0)
	_ = n
	p := make([]bool, 3)
	p[0] = true
	p[1] = true
	for _, v := range a {
		win := v - 1
		var lose, spect int
		if !p[win] {
			println("NO")
			return
		}
		for i := range p {
			if i == win {
				continue
			}
			if !p[i] {
				spect = i
				continue
			}
			lose = i
		}
		p[win] = true
		p[spect] = true
		p[lose] = false
	}
	println("YES")
}


package main

import "fmt"

func main() {
    var n,a int
    fmt.Scan(&n)
    total := 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        total += a
    }
    total--
    n++
    ans := 0
    for i := 1; i <= 5; i++ {
        if (total+i)%n != 0 {
            ans++
        }
    }
    fmt.Println(ans)
}


package main

import (
	"fmt"
	"math"
	"strconv"
)

func main() {
	var nFloors int
	var sResident string
	var as []int
	_, _ = fmt.Scanln(&nFloors)

	for i := 0; i < nFloors; i++ {
		_, _ = fmt.Scan(&sResident)
		resident, _ := strconv.Atoi(sResident)
		as = append(as, resident)
	}

	bestX := math.MaxInt32
	for x := 0; x < len(as); x++ {
		if sum := sumForXA(x, as); sum < bestX {
			bestX = sum
		}
	}
	fmt.Println(bestX)
}

func sumForXA(x int, a []int) int {
	units := 0
	for i := 0; i < len(a); i++ {
		if a[i] > 0 {
			sum := 0
			// move from x to i
			sum += int(math.Abs(float64(i - x)))
			// move from i to 0
			sum += i
			// move from 0 to x
			sum += x
			// twice (elevator down, up)
			sum *= 2
			// multiply with a
			sum *= a[i]
			units += sum
		}
	}
	return units
}


package main

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

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

	a      int64
	b      int64
	result int64
)

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

	a = readInt64()
	b = readInt64()
}

func out() {
	writer = bufio.NewWriter(os.Stdout)
	defer writer.Flush()

	if result >= 0 {
		printInt64(result)
	} else {
		printString("infinity")
	}
	printLine()
}

func run() {
	if b > a {
		result = 0
	} else if b == a {
		result = -1
	} else {
		result = 0
		m := a - b
		for i := int64(1); i*i <= m; i++ {
			if i*i == m && i > b {
				result++
			} else {
				if m%i == 0 {
					if i > b {
						result++
					}
					if m/i > b {
						result++
					}
				}
			}
		}
	}
}

func main() {
	in()
	run()
	out()
}

// Read.

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

func readLine() string {
	scanner.Split(bufio.ScanLines)
	defer scanner.Split(bufio.ScanWords)
	return readString()
}

func readInt() int {
	ans, _ := strconv.ParseInt(readString(), 10, 0)
	return int(ans)
}

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

func readFloat64() float64 {
	ans, _ := strconv.ParseFloat(readString(), 64)
	return ans
}

// Write.

func printString(value string) {
	writer.WriteString(value)
}

func printLine() {
	printString("\n")
}

func printSpace() {
	printString(" ")
}

func printInt(value int) {
	printString(strconv.FormatInt(int64(value), 10))
}

func printInt64(value int64) {
	printString(strconv.FormatInt(value, 10))
}

func printFloat64(value float64) {
	printString(strconv.FormatFloat(value, 'f', 10, 64))
}


package main

import "fmt"

func main(){
	panel := make([][]int,3)
	t := true
	for i := range panel{
		var s string
		fmt.Scanf("%s\n",&s)
		//fmt.Printf("%s", s)
		panel[i] = make([]int, 3)
		for j := range panel[i]{
			if s[j] == 'X'{
				panel[i][j] = 1
			}

		}
	}
	for i := range panel{
		for j := range panel[i] {
			if panel[i][j]==1{
				if panel[i][j] != panel[2 - i][2 - j]{
						t = false
				}

			}

		}
	}

	if t{
		fmt.Printf("YES")
	}else{
		fmt.Printf("NO")
	}

}


package main

import (
	"fmt"
	"sort"
)

func main()  {
	var n int
	fmt.Scan(&n)
	weight := make([]int,2*n)
	for i := 0; i < 2*n; i++ {
		fmt.Scan(&weight[i])
	}
	sort.Ints(weight)
	res := 50000
	for i := 0; i < 2*n-1; i++ { //enumerate the two elements
		for j := i + 1; j < 2*n; j++ {
			tot := 0
			for k := 0; k < 2*n-1; k++ { //left weight
				if k==i || k==j{continue} //skip it
				r := k+1
				for r==i || r==j {r++} //right weight
				tot += weight[r] - weight[k]
				k = r //update left
			}
			if tot < res { res = tot} //update the result
		}
	}
	fmt.Println(res)

}


package main

import "fmt"

func main() {
    var s string
    var a,b,c,d bool
    fmt.Scan(&s)
    if len(s) >= 5 { a = true }
    for _, v := range s {
        if (v >= 'A') && (v <= 'Z') { b = true }
        if (v >= 'a') && (v <= 'z') { c = true }
        if (v >= '0') && (v <= '9') { d = true }
    }
    if a && b && c && d {
        fmt.Println("Correct")
    } else {
        fmt.Println("Too weak")
    }
}


package main

import (
	"fmt"
	"math/big"
)

func main() {
	var nString string
	n, res := big.NewInt(0), big.NewInt(0)

	fmt.Scan(&nString)
	n, _ = n.SetString(nString, 10)

	res.Div(n, big.NewInt(2))
	_, m := new(big.Int).DivMod(n, big.NewInt(2), big.NewInt(0))

	if m.Cmp(big.NewInt(0)) > 0 {
		res.Add(res, n.Neg(n))
	}

	fmt.Println(res)
}


package main

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

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

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

	n := nextInt()
	min1, max1 := nextInt(), nextInt()
	min2, max2 := nextInt(), nextInt()
	min3, max3 := nextInt(), nextInt()

	n -= min1 + min2 + min3

	n, min1 = add(n, min1, max1)
	n, min2 = add(n, min2, max2)
	n, min3 = add(n, min3, max3)

	println(min1, min2, min3)
}

func add(n, min, max int) (int, int) {
	if n > 0 {
		if min+n <= max {
			min += n
			n = 0
		} else {
			n -= max - min
			min = max
		}
	}

	return n, min
}

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

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

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

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

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

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


package main

import (
	"fmt"
)

func main() {
	var (
		str   string
	)

	fmt.Scan(&str)

	runes := []rune(str)
	strMap := make(map[string]int)
	strMap[str]++
	for i := 0; i < len(str); i++ {
		curRune := runes[len(str) - 1]
		for j := len(str) - 1; j > 0 ; j-- {
			runes[j] = runes[j - 1]
		}
		runes[0] = curRune
		strMap[string(runes)]++
	}

	fmt.Println(len(strMap))
}


package main

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

func calc(x, n int64) int64 {
	sum := int64((x + 1) * n * (n - 1) / 2)

	sum += n * (x) * (x + 1) / 2
	//for i := x; i >= 0; i-- {
	//	sum += n * i
	//}
	return sum
}

func main() {
	sc := NewScanner()
	M, B := sc.NextInt64(), sc.NextInt64()

	mx := int64(0)
	for x := int64(0); x <= M*B; x++ {
		if x < 0 {
			continue
		}

		y := -((x - B*M) / M)

		if y < 0 {
			continue
		}
		n := y + 1
		q := calc(x, n)
		if mx < q {
			mx = q
		}
	}
	fmt.Println(mx)

}

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

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

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

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

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

	return mp
}

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


package main

import (
	"fmt"
)

func main() {
	var a, b int
	var ind int = 0
	fmt.Scan(&a, &b)
	for ; a <= b; ind++ {
		a *= 3
		b *= 2
	}
	fmt.Println(ind)
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	arr := [...]int{4, 7, 44, 47, 74, 77, 444, 447, 474, 477, 744, 747, 774, 777}
	luck := false
	for i := range arr {
		if n%arr[i] == 0 {
			luck = true
			break
		}
	}
	if luck {
		fmt.Print("YES")
	} else {
		fmt.Print("NO")
	}
}


package main

import (
	"fmt"
)

func main() {
	var rel int
	var a int
	var b int
	flag := false
	fmt.Scan(&rel)
	var ar [5]int
	for i := 0; i < rel; i++ {
		fmt.Scan(&a)
		fmt.Scan(&b)
		ar[a-1]++
		ar[b-1]++
	}
	for i := 0; i < 5; i++ {
		if ar[i] != 2 {
			flag = true
		}
	}
	if flag {
		fmt.Println("WIN")
	} else {
		fmt.Println("FAIL")
	}
}


package main

import (
	"fmt"
	"bufio"
	"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 max(nums ...int64) int64 {
	var m int64
	for i, v := range nums{
		if i == 0 || v > m {
			m = v
		}
	}
	return m
}

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

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

const MOD = 1000000007

func main() {
	var x, y, n int;
	scanf("%d %d\n%d", &x, &y, &n)
	n--
	seq := make([]int, 6)
	seq[0] = x
	seq[1] = y
	seq[2] = y - x
	seq[3] = -x
	seq[4] = -y
	seq[5] = x - y
	fmt.Printf("%d\n", (seq[n%6] % MOD + MOD) % MOD)
}


package main

import "fmt"

func main() {
	var in string
	fmt.Scanln(&in)

	out := ""

	for run := len(in) > 0; run; run = len(in) > 0 {
		if len(in)%2 == 0 {
			out = string(in[len(in)-1]) + out
			in = in[0 : len(in)-1]
		} else {
			out = string(in[0]) + out
			in = in[1:len(in)]
		}
	}

	fmt.Println(out)
}


package main

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

var w *bufio.Writer

var sc *bufio.Scanner

const minus, zero byte = '-', '0'

func nextInt() int {
	var ans, fst int = 0, 0
	var neg bool = false
	sc.Scan()
	if sc.Bytes()[0] == minus {
		fst = 1
		neg = true
	}
	for _, j := range sc.Bytes()[fst:] {
		ans = ans*10 + int(j-zero)
	}
	if neg == true {
		ans = -ans
	}
	return ans
}

func printInt(n int) {
	w.WriteString(strconv.Itoa(n) + " ")
}

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

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

func main() {

	w = bufio.NewWriter(os.Stdout)
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	cnt := 0

	N := nextInt()
	for m := 1; m <= N; m++ {
		for n := m; 2*m*n <= N; n++ {
			a, b, c := 2*m*n, n*n-m*m, n*n+m*m
			if a > b {
				a, b = b, a
			}
			if gcd(m, n) == 1 && (m^n)%2 == 1 && b <= N && c <= N {
				cnt += N / Max(Max(a, c), b)
			}
		}
	}
	printInt(cnt)
	w.Flush()
	//YOU FORGOT TO FLUSH!
}


package main

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

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

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

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

import (
	"fmt"
)

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

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

func main() {
	var x1, y1, x2, y2 int
	fmt.Scan(&x1, &y1, &x2, &y2)
	fmt.Println(max(abs(x1-x2), abs(y1-y2)))
}


package main

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

func main() {
    reader := bufio.NewReader(os.Stdin)
    _, _ = reader.ReadString('\n')
    input, _ := reader.ReadString('\n')

    ma := make(map[string]int)
    ar := []string{}
    for i, c := range input {
        if i == len(input) - 1 {
            break
        }

        cu := string(c) + string(input[i + 1])
        ar = append(ar, cu)

        if _, ok := ma[cu]; ok {
            ma[cu] += 1
        } else {
            ma[cu] = 1
        }
    }

    max := -999999999
    ret := ar[0]
    for _, m := range ar {
        if ma[m] > max {
            max = ma[m]
            ret = m
        }
    }

    fmt.Println(ret)
}


// B. Internet Address
/*
Vasya is an active Internet user. One day he came across an Internet resource he liked, so he wrote its address in the notebook. We know that the address of the written resource has format:
			<protocol>://<domain>.ru[/<context>]

where:

    <protocol> can equal either "http" (without the quotes) or "ftp" (without the quotes),
    <domain> is a non-empty string, consisting of lowercase English letters,
	 	the /<context> part may not be present. If it is present, then <context> is a non-empty string, consisting of lowercase English letters.

If string <context> isn't present in the address, then the additional character "/" isn't written. Thus, the address has either two characters "/" (the ones that go before the domain), or three (an extra one in front of the context).

When the boy came home, he found out that the address he wrote in his notebook had no punctuation marks. Vasya must have been in a lot of hurry and didn't write characters ":", "/", ".".

Help Vasya to restore the possible address of the recorded Internet resource.

Input
The first line contains a non-empty string that Vasya wrote out in his notebook. This line consists of lowercase English letters only.

It is guaranteed that the given string contains at most 50 letters. It is guaranteed that the given string can be obtained from some correct Internet resource address, described above.

Output
Print a single line — the address of the Internet resource that Vasya liked. If there are several addresses that meet the problem limitations, you are allowed to print any of them.

Examples
Input
httpsunrux

Output
http://sun.ru/x

Input
ftphttprururu

Output
ftp://http.ru/ruru

Note
In the second sample there are two more possible answers: "ftp://httpruru.ru" and "ftp://httpru.ru/ru".
*/
package main

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

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

	pIndex := 3
	url := "ftp://"
	if arr[0] == "h" {
		pIndex = 4
		url = "http://"
	}

	cIndex := len(arr)
	for i := pIndex + 1; i < len(arr)-1; i++ {
		if arr[i] == "r" && arr[i+1] == "u" {
			cIndex = i
			break
		}
	}
	if cIndex < len(arr)-2 {
		fmt.Printf("%v%v.ru/%v", url, strings.Join(arr[pIndex:cIndex], ""), strings.Join(arr[cIndex+2:], ""))
	} else {

		fmt.Printf("%v%v.ru", url, strings.Join(arr[pIndex:cIndex], ""))
	}
}


package main

import(
    "fmt"
    "sort"
    "strings"
)

func main() {
    var r int64
    fmt.Scan(&r)
    var x int64 = 0
    var y int64 = 0
    var i int64 = 1
    for ; i*i<=r; i++{
        if r-i*i-i-1>0 && (r-i*i-i-1)%(2*i)==0{
            x = i
            y = (r-i*i-i-1)/(2*i)
            break
        }
    }
    if x==0{
        fmt.Println("NO")
    } else {
        fmt.Println(x,y)
    }
}

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

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

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

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

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

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

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

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

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func scanTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func SortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1029F(_r io.Reader, _w io.Writer) {
	ds := func(n int64) (ds [][2]int64) {
		for d := int64(1); d*d <= n; d++ {
			if n%d == 0 {
				ds = append(ds, [2]int64{d, n / d})
			}
		}
		return
	}
	var a, b int64
	Fscan(_r, &a, &b)
	da, db := ds(a), ds(b)
	n := a + b
	for d := int64(math.Sqrt(float64(n))); ; d-- {
		if n%d == 0 {
			d2 := n / d
			i := sort.Search(len(da), func(i int) bool { return da[i][0] > d }) - 1
			j := sort.Search(len(db), func(i int) bool { return db[i][0] > d }) - 1
			if da[i][1] <= d2 || db[j][1] <= d2 {
				Fprint(_w, 2*(d+d2))
				break
			}
		}
	}
}

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


package main

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

func main(){
	var s,v1,v2,t1,t2 int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in,&s,&v1,&v2,&t1,&t2)
	a1 := 2*t1+s*v1
	a2 := 2*t2+s*v2
	if a1<a2{
		fmt.Println("First")
	}else if a2<a1{
		fmt.Println("Second")
	}else{
		fmt.Println("Friendship")
	}
}


// Author: sighduck
// URL: https://codeforces.com/problemset/problem/343/A

package main

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

func Count(a, b, steps int64) int64 {
	if b == 0 {
		return steps
	} else if b == 1 {
		return steps + a
	} else if a == b {
		return steps + 1
	} else if a > b {
		return Count(a%b, b, steps+a/b)
	} else if a < b {
		return Count(a, b%a, steps+b/a)
	}
	return -1
}

func Solve(a, b int64) int64 {
	return Count(a, b, 0)
}

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

	var a, b int64
	fmt.Fscanf(reader, "%d %d\n", &a, &b)

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


package main

/*
  The idea to solve this problem is by realizing that when we encode number
  which having last digit zero (ex. 1200) there won't be extra 0 on encoded
  string, so if we want to decode the string then we need to append exra zero
  on the result.

  As for other numbers it is same, the digit is separated by 0, so if there is
  0 on the middle of number, then there will be "00" on the encoded string.
*/

import "fmt"

func main() {
  var n int
  var encodeStr string

  fmt.Scan(&n)
  fmt.Scan(&encodeStr)

  var counter int
  var prevDigit string = "-1"

  for i := 0; i < n; i++ {
    var currentDigit string = string(encodeStr[i])
    if currentDigit == "1" {
      counter++
      if i == n-1 {
        fmt.Printf("%d", counter)
      }
    } else if currentDigit == "0" && prevDigit == "0" {
      fmt.Printf("0")
    } else if currentDigit == "0" && prevDigit != "0" {
      fmt.Printf("%d", counter)
      counter = 0
    }
    prevDigit = currentDigit
  }

  if string(encodeStr[n - 1]) == "0" {
    fmt.Printf("0")
  }
}


package main

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

//TODO, 2017.11.15
func main() {
	var sum int
	reader := bufio.NewReader(os.Stdin)
	array := make([]int, 6)
	for i := 0; i < 6; i++ {
		fmt.Fscan(reader, &array[i])
		sum += array[i]
	}
	if sum%2 == 1 {
		fmt.Println("NO")
	} else {
		flag := false
		half := sum / 2
		for i := 0; i < 6; i++ {
			add := array[i]
			if add > half {
				flag = false
				break
			}
			other := make([]int, len(array))
			copy(other, array)
			other = append(other[:i], other[i+1:]...)
			for j := 0; j < len(other)-1; j++ {
				for k := j + 1; k < len(other)-2; k++ {
					if add+other[j]+other[k] == half {
						flag = true
						break
					}
				}

			}
			if flag == true {
				break
			}
		}
		if flag == false {
			fmt.Println("NO")
		} else {
			fmt.Println("YES")
		}
	}
}


package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	fmt.Println("0","0",n)
}


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

func main() {
	var n int
	fmt.Scan(&n)
	a:=make([]int,n)
	for i:=0;i<n;i++ {
		fmt.Scan(&a[i])
	}
	sort.Ints(a)
	var s int
	s=a[n-1]
	a[n-1]=a[0]
	a[0]=s+a[0]-(a[0])

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


package main

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

func imin(a, b int) int {
	if a < b {
		return a
	} else {
		return b
	}
}
func main() {
	d, st := nextInt(), nextInt()
	min, max := 0, 0
	mn, mx := make([]int, 0), make([]int, 0)
	for i := 0; i < d; i++ {
		a, b := nextInt(), nextInt()
		min += a
		max += b
		mn = append(mn, a)
		mx = append(mx, b)
	}

	if st >= min && st <= max {
		printf("YES\n")
		s := st - min
		res := make([]int, 0)
		for i := 0; i < d; i++ {
			n := 0
			if s > 0 {
				n = imin(mx[i] - mn[i], s)
			}
			s -= n
			res = append(res, mn[i] + n)
		}
		r := fmt.Sprintf("%v", res)
		printf("%s\n", r[1:len(r) - 1])
	} else {
		printf("NO\n")
	}
}

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

func init() {
	lineScanner = bufio.NewScanner(os.Stdin)
	wordScanner = bufio.NewScanner(strings.NewReader(""))
	wordScanner.Split(bufio.ScanWords)
}
func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

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

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

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

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


package main
import (
    "fmt"
    )
func main(){
    var n int
    i := 1
    fmt.Scan(&n)
    for ;n>i;i++{
        n -= i
    }
    if n == i {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


package main

import "fmt"

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


package main

import "fmt"

func main() {
	var a int
	fmt.Scan(&a)
	if a == 1 {
		fmt.Println(1, 1)
		fmt.Println(1)
		return
	}
	fmt.Println(2*(a-1), 2)
	fmt.Println(1, 2)
}


package main

import "fmt"

func vk(s1 string, s2 string) string {
	var result string
	for i := 0; i < len(s1); i++ {
		if s1[i] < s2[i] {
			return "-1"
		} else if s1[i] > s2[i] {
			result = result + string(s2[i])
		} else if s1[i] == s2[i] {
			result = result + string('z')
		}
	}
	return result
}

func main() {
	var s1, s2 string
	fmt.Scanf("%s\n%s", &s1, &s2)
	fmt.Println(vk(s1, s2))
}


package main

/*
	The idea to solve this problem is basically by realizing "x" is the maximum
	threshold for cake slices in a plate. Slice in cake coming from "a" & "b". Thus
	total slices from "a" & "b" must be larger or equal than nx.

	But since slices from "a" & slices coming "b" cannot be combined in one plate,
	thus the condition would become following: (a/x + b/x >= n).

	Thus as long as x <= a && x <= b && (a/x + b/x >= n), we can always increase the
	value of "x". Then in the end we just need to print the mlargest value of "x".
*/

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

func main() {
	stdio := bufio.NewReader(os.Stdin)
	var n, a, b int
	x := 1
	fmt.Fscanf(stdio, "%d %d %d", &n, &a, &b)
	for x <= a && x <= b && (a/x+b/x >= n) {
		x++
	}
	fmt.Println(x - 1) // decrease the value of x because of excess increment
}


package main

import (
	"fmt"
	"sort"
)

func solve(cards [5]int) int {
	sort.Ints(cards[:])
	if cards[3] == cards[4] {
		if cards[2] == cards[3] {
			return cards[0] + cards[1]
		}
		sum := cards[0] + cards[1] + cards[2]
		if cards[1] == cards[2] && cards[0] == cards[1] {
			if sum > cards[3] + cards[4] {
				sum = cards[3] + cards[4]
			}
		}
		return sum
	}
	// cards[3] != cards[4]
	if cards[2] == cards[3] {
		if cards[1] == cards[2] {
			return cards[0] + cards[4]
		}
		return cards[0] + cards[1] + cards[4]
	}
	// cards[2] != cards[3]
	if cards[1] == cards[2] {
		if cards[0] == cards[1] {
			return cards[3] + cards[4]
		}
		return cards[0] + cards[3] + cards[4]
	}
	// cards[1] != cards[2]
	if cards[0] == cards[1] {
		return cards[2] + cards[3] + cards[4]
	}
	// cards[0] != cards[1]
	return cards[0] + cards[1] + cards[2] + cards[3] + cards[4]
}

func main() {
	var cards [5]int
	n, err := fmt.Scanln(&cards[0], &cards[1], &cards[2], &cards[3], &cards[4])
	if n != 5 || err != nil {
		panic(err)
	}
	sum := solve(cards)
	fmt.Println(sum)
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	arr := gsls(reader)
	rot := gsli(reader)[0]

	start := pos(arr[0])
	end := pos(arr[1])

	// fmt.Printf("arr: %#v \n rot: %#v \n start: %v \n end: %v", arr, rot, start, end)

	cwEnd := posMod(start+rot, 4)
	ccwEnd := posMod(start-rot, 4)

	diff := posMod(end-start, 4)

	if diff == 0 || diff == 2 {
		fmt.Print("undefined")
	} else if end == cwEnd {
		fmt.Print("cw")
	} else if end == ccwEnd {
		fmt.Print("ccw")
	} else {
		fmt.Printf("cwEnd = %v, ccwEnd = %v", cwEnd, ccwEnd)
	}
	return

}

func pos(x string) (pos int) {
	switch x {
	case "^":
		pos = 0
	case ">":
		pos = 1
	case "v":
		pos = 2
	case "<":
		pos = 3
	}

	return
}

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

func gsls(reader *bufio.Reader) (arr []string) {
	// Get a full line

	input, _ := reader.ReadString('\n')

	// fmt.Printf("Got %#v \n", input)

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

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

	return
}

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

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

	return
}

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

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

	return
}


package main
import (
	"fmt"
	"sort"
)

func main(){
	var in,cek,ans string
	fmt.Scan(&in,&cek)
	x:=make([]string,len(in))
	for i:=0 ;i<len(in);i++{ x[i]=string(in[i])}
	sort.Strings(x)
	if x[0] == string('0') {
		for i:=1;i<len(in) ; i++{
			if x[i] != string('0'){
				x[0] = x[i]
				x[i] = string('0')
				break
			}
		}
	}
	for i:=0; i<len(in);i++{ ans+=x[i]}
	if cek == ans{
			fmt.Println("OK")
	}else{
		fmt.Println("WRONG_ANSWER")
	}
}


package main

import (
  "fmt"
)

func main() {
  var n, m int

  _, _ = fmt.Scanln(&n, &m)

  if m == 1 {
    fmt.Println(n-1)
  } else {
    fmt.Println(n*(m-1))
  }

}


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

var n, m, mod int64
var matrix [][]int

func multiply(one, two [][]int) [][]int {
	res := make([][]int, m)
	for i := 0; i < int(m); i++ {
		res[i] = make([]int, m)
	}
	for i := 0; i < int(m); i++ {
		for j := 0; j < int(m); j++ {
			for k := 0; k < int(m); k++ {
				res[i][j] += int(int64(one[i][k]) * int64(two[k][j]) % mod)
				res[i][j] %= int(mod)
			}
		}
	}
	return res
}

func power(exp int64, base [][]int) [][]int {

	if exp == 1 {
		return base
	}

	res := power(exp/2, base)
	res = multiply(res, res)
	if exp&1 == 1 {
		res = multiply(res, base)
	}
	return res
}

func main() {
	defer writer.Flush()
	mod = 1000000007
	scanf("%d %d\n", &n, &m)
	if n < m {
		printf("1")
		return
	}
	if n == m {
		printf("2")
		return
	}
	matrix = make([][]int, m)
	for i := 0; i < int(m); i++ {
		matrix[i] = make([]int, m)
	}
	matrix[0][0] = 1
	matrix[0][m-1] = 1
	for i := 1; i < int(m); i++ {
		matrix[i][i-1] = 1
	}

	fmt.Println(power(n, matrix)[0][0])

}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	ans := int64(0)
	for i := 3; i <= n; i++ {
		ans += int64(i * (i - 1))
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

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


package main

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

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

	var n int
	Fscan(in, &n)

	ans := int64(0)
	cnts := [9]int64{}
	for i := 1; i <= n; i++ {
		cnts[i%9]++
		ans -= int64(n / i)
	}
	for i := 0; i < 9; i++ {
		for j := 0; j < 9; j++ {
			ans += cnts[i] * cnts[j] * cnts[i*j%9]
		}
	}
	Fprint(out, ans)
}

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


package main
import (
	"fmt"
)

func main() {
	var n,m int
	fmt.Scan(&n,&m)
	if n==0 && m!=0 {
		fmt.Println("Impossible")
	} else {
		if n>m {
			fmt.Print(n)
		} else {
			fmt.Print(m)
		}
		fmt.Print(" ")
		if m!=0 {
			fmt.Println(n+m-1)
		} else {
			fmt.Println(n)
		}
	}
}


package main

import "fmt"

func main() {
    var y int
    fmt.Scan(&y)
    for {
        y++
        var f [10]bool
        ty := y
        ans := true
        for ty > 0 {
            d := ty%10
            if f[d] { ans = false; break; } else { f[d] = true }
            ty /= 10
        }
        if ans { fmt.Println(y); break; }
    }
}


package main

import "fmt"

func main() {
	colors := make(map[int]struct{})
	var v int
	for i := 0; i < 4; i++ {
		fmt.Scan(&v)
		colors[v] = struct{}{}
	}

	fmt.Print(4 - len(colors))
}


package main

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

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

    var half = (int64)(math.Sqrt(float64(n)))
    var d = int64(-1)

    for i:=int64(1); i<=half; i++ {
        if n % i == 0 {
            k -= 1

            if k == 0 {
                d = i
                break
            }
        }
    }

    if k > 0 {
        if half * half == n {
            half--
        }

        for i:=half; i>0; i-- {
            if n % i == 0 {
                k -= 1

                if k == 0 {
                    d = n / i
                    break
                }
            }
        }
    }

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


package main

import (
	"fmt"
)

func isPalindrome(str string) bool {
	size := len(str)
	var rev_str string
	for i := size-1; i >= 0; i--{
		rev_str += string(str[i])
	}
	if str == rev_str{
		return true
	}else{
		return false
	}
}

func removeLast(str string)string {
	str = str[:len(str)-1]
	return str
}

func main(){
	var str string
	fmt.Scanln(&str)
	if ! isPalindrome(str){
		fmt.Print(len(str))
	}else{
		for (isPalindrome(str)){
			if str == ""{
				fmt.Print(0)
				return
			}
			str = removeLast(str)
		}
		fmt.Print(len(str))
	}
}


package main

import (
	"fmt"
	"sort"
)

func main(){
	var n, a int
	arr := make([]int, 0)
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		arr = append(arr, a)
	}
	sort.Ints(arr)
	ans := 0
	for i := 0; i < len(arr) - 1; i+=2 {
		ans += arr[i + 1] - arr[i]
	}
	fmt.Println(ans)
}


package main

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

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

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

	a, b, _, _ := nextInt(), nextInt(), nextInt(), nextInt()

	if a > b {
		fmt.Println("First")
	} else {
		fmt.Println("Second")
	}
}

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


package main

import "fmt"

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


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	a := make([]int, 3)
	d := 0
	fmt.Fscanf(in, "%d %d %d %d\n", &a[0], &a[1], &a[2], &d)
	sort.Ints(a)
	ans := 0
	if a[1]-a[0] < d {
		ans += d - (a[1] - a[0])
	}
	if a[2]-a[1] < d {
		ans += d - (a[2] - a[1])
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}
func minstep(a, b byte) int {
	return min(int(a-b+26)%26, int(b-a+26)%26)
}

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


package main
import(
    "fmt"
)
func getElement(n, k uint64) int {
    var length uint64
    length = (1 << n) - 1
    for i := n; i > 0; i-- {
        length = length / 2
        if k > length {
            k -= length + 1
        }
        if k == 0 {
            return int(i)
        }
    }
    return -1
}
func main(){
    var n, k uint64
    fmt.Scan(&n, &k)
    fmt.Println(getElement(n, k))
}


package main

import "fmt"

func main() {
	var n, k, a int
	fmt.Scan(&n, &k)
	res := 1
	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		if k%a == 0 && res < a {
			res = a
		}
	}
	fmt.Println(k / res)
}


package main

import (
	"fmt"
)

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

	for i := n % 6; i > 0; i-- {
		if i%2 == 0 {
			if x == 2 {
				x = 1
			} else if x == 1 {
				x = 2
			}
		} else {
			if x == 0 {
				x = 1
			} else if x == 1 {
				x = 0
			}
		}
	}

	fmt.Print(x)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n string
	fmt.Fscan(in, &n)
	l := len(n)
	i := 0
	bin := 0
	for i < l && n[i] < '2' {
		pow2 := 1 << (l - i - 1)
		bin += (int(n[i]-'0') * pow2)
		i++
	}
	offset := l - i
	rest := 1<<(offset) - 1
	ans := bin | rest
	fmt.Fprintln(out, ans)
}


package main

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

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

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

	n := nextInt64()

	println((n - 2) * (n - 2))
}

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

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

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

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

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

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


package main
import (
	"fmt"
)
func divisors(n int) int{
	c:= 1
	for d:=2; d<100; d++{
		if (n % d == 0){
			alpha := 0;
			for ;n % d == 0; {
				n /= d
				alpha++
			}
			c *= (alpha + 1)
		}
	}
	return c
}

func main() {
	var sum , al, bl, cl int
	sum=0
	fmt.Scan(&al,&bl,&cl)
	for a := 1; a <= al; a++{
		for b := 1; b <= bl; b++{
			for c := 1; c <= cl; c++{
				sum += divisors(a*b*c);
				sum %= 1073741824;
			}
		}
	}
	fmt.Println(sum)
}


package main

import "fmt"

func main() {
    var n int
    var s string
    fmt.Scan(&n,&s)
    ans := 0
    for i := 1; i < n; i++ {
        if (s[i] == s[i-1]) { ans++ }
    }
    fmt.Println(ans)
}


package main

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

type diameter struct {
	io *IO
}

func (d *diameter) out(deleteN int) {
	d.io.Printf("%d", deleteN)
}

func main() {
	//log.SetOutput(os.Stdout)
	log.SetOutput(ioutil.Discard)

	io := NewStdIO()
	defer io.Flush()
	d := diameter{io: io}

	l1 := d.io.NextSplitLine(" ")
	n, dmax := stoi(l1[0]), stoi(l1[1])
	log.Printf("n=%d, dmax=%d", n, dmax)

	if n <= 1 {
		d.out(0)
		return
	}

	l2 := d.io.NextSplitLine(" ")
	nset := make([]int, n)
	for i, ns := range l2 {
		nset[i] = stoi(ns)
	}
	sort.Ints(nset)

	minN := n + 1
	for i := 0; i < n; i++ {
		cnt := 0
		for j := i; j < n; j++ {
			cnt++
			log.Printf("i=%d, j=%d, minN=%d", i, j, minN)
			if (nset[j] - nset[i]) <= dmax {
				minN = min(minN, n-cnt)
			}
		}
	}
	d.out(minN)
}

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

func stoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		fmt.Println(i)
		fmt.Println(err)
	}
	return i
}

// NewStdIO return standard IO instance.
func NewStdIO() *IO {
	return &IO{
		In:  bufio.NewReader(os.Stdin),
		Out: bufio.NewWriter(os.Stdout),
	}
}

// IO supports IO processing.
type IO struct {
	In  *bufio.Reader
	Out *bufio.Writer
}

// Flush outputs buffed data.
func (io *IO) Flush() {
	if err := io.Out.Flush(); err != nil {
		panic(err)
	}
}

// Printf writes string to buffer.
func (io *IO) Printf(format string, a ...interface{}) {
	if _, err := fmt.Fprintf(io.Out, format, a...); err != nil {
		panic(err)
	}
}

// NextInt reads a next line and convert it to integer
func (io *IO) NextInt() int {
	return stoi(io.Next())
}

// NextSplitLine reads a next line and return split string
func (io *IO) NextSplitLine(d string) []string {
	return strings.Split(io.Next(), d)
}

// Next reads line and return string.
func (io *IO) Next() string {
	var b []byte
	for {
		l, pre, err := io.In.ReadLine()
		if err != nil {
			panic(err)
		}
		b = append(b, l...)
		if !pre {
			break
		}
	}
	return string(b)
}


package main

import (
	"fmt"
)

var (
	num int
	i   int
	s   [50]int

	b_count  int
	b_count1 int
	w_count  int
	w_count1 int
	ccl      int
	cclp     int
	flag     bool
)

func main() {
	b_count = 0
	w_count = 0

	fmt.Scanln(&num)

	ccl = num / 2
	for i = 0; i < ccl; i++ {
		fmt.Scanf("%d", &cclp)
		s[i] = cclp
	}

	if ccl == 1 {

		fmt.Println(0)
	} else {

		flag = true
		for flag {
			flag = false
			for i = 1; i < num/2; i++ {

				if s[i-1] > s[i] {
					flag = true
					ccl = s[i]
					s[i] = s[i-1]
					s[i-1] = ccl
				}
			}
		}

		for i = 0; i < num/2; i++ {
			ccl = s[i] - 2*i - 1
			cclp = s[i] - 2*i - 2
			b_count += Iabs(ccl)
			w_count += Iabs(cclp)

		}

		if b_count < w_count {
			fmt.Println(b_count)
		} else {
			fmt.Println(w_count)
		}
	}
	return
}
func Iabs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}


package main

import (
	"fmt"
)

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

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


package main

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

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

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()
  x := n
  result := int64(1)
  for a := int64(2); a * a <= x; a++ {
    if x % a != 0 {
      continue
    }
    result *= a
    for x % a == 0 {
      x /= a
    }
    //fmt.Printf("%d ", a)
  }
  result *= x
  //fmt.Printf("%d\n", x)
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

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

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

    fmt.Scan(&n, &k )
    reader := bufio.NewReader(os.Stdin)
    entrada, _ := reader.ReadString('\r')
    s = strings.TrimRight(entrada, "\n")

    arrs := strings.Fields(s)

    var t2[] int
    dic:= map[int] bool {}

    for pos, i := range arrs {
      j, _ := strconv.Atoi(i)
      _, ok := dic[j]
      if !ok {

        dic[j] = true
        if len(t2) == k{
            break
        }
        t2 = append(t2, pos+1)
      }

    }

    if len(dic) < k {
      fmt.Println("NO")
    } else {
      sort.Ints(t2)
      fmt.Println("YES")
      fmt.Println(strings.Trim(fmt.Sprint(t2), "[]"))
    }

}


package main

import (
	"fmt"
)

func main() {
	var n, t int
	fmt.Scanf("%d %d \n", &n, &t)
	if n == 1 && t == 10 {
		fmt.Print(-1)
		return
	}
	fmt.Print(t)
	for i := 0; i < n-1-t/10; i++ {
		fmt.Print(0)
	}
}


package main

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

func gcd(a, b int64) int64 {
//	fmt.Printf("->%d %d\n",a,b)
	if b%a == 0 {
		return a
	}
	return gcd(b%a, a)
}
func solveD(l, n, k int64) (int64) {

	gc := gcd(l, n*k)
	if gc == 1{
		return n*k
	}
	tmp := n * k/gc
	if tmp < 0{
		fmt.Printf("%d %d %d\n",l,n,k)
	}
	return tmp
}
func main() {
	buf := bufio.NewReader(os.Stdin)
	var n, k int64
	var a, b int64
	fmt.Fscanf(buf, "%d %d\n", &n, &k)
	fmt.Fscanf(buf, "%d %d\n", &a, &b)
	basic := make([]int64, 0)
	for _, v1 := range [2]int64{a, (k - a)%k} {
		for _, v2 := range [2]int64{b, (k - b)%k} {
			if v2-v1 == 0 {
				basic = append(basic, k)
			} else if v2-v1 > 0 {
				basic = append(basic, v2-v1)
			} else {
				basic = append(basic, k+v2-v1)
			}
		}
	}
	var minx int64 = -1
	var maxx int64 = -1
//	fmt.Printf("%v\n", basic)
	for _, v := range basic {
		for i := int64(0); i < n; i++ {
			tmp := solveD(v+i*k,n,k)
			if minx == -1||minx > tmp{
				minx = tmp
			}
			if maxx == -1 || maxx < tmp{
				maxx = tmp
			}
		}
	}
	fmt.Printf("%d %d\n", minx,maxx)

}

/**
01010101
0101010
 */


package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	k := readll()
	n := readll()
	s := readll()
	p := readll()

	s2 := n / s
	if n%s != 0 {
		s2++
	}
	ans := k * s2 / p
	if (k*s2)%p != 0 {
		ans++
	}
	println(ans)
}


package main

import (
	"fmt"
)

func main() {
	var b, n, p, x, y int
	fmt.Scanf("%d%d%d", &n, &b, &p)
	y = n * p
	for n > 1 {
		k := 1
		for k <= n {
			k = k << 1
		}
		k = k >> 2
		x += (2*b + 1) * k
		n = n - k
	}
	fmt.Println(x, y)
}


package main

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

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

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

	return n
}

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

  start := State{}

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

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

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

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

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

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

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

      if r1 > r2 {
        r1 = r2
      }

      r += r1
    }

    memo[s] = r

    return r
  }

  return solve(start)
}

func main() {
	var n uint32

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

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

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

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


package main
import "fmt"

func main(){
	var A[4] int
		fmt.Scan(&A[0], &A[1], &A[3], &A[2])
	for i:=0; i<2; i++{
		 if A[i]-1<=A[i+2]&&2*A[i]+2>=A[i+2] {
			fmt.Println("YES")
			return
			}
	}

	fmt.Println("NO")
	return
}


package main

import "fmt"

func main() {
	var a int
	fmt.Scanf("%d", &a)
	var ans, tmp, tot int = 0, 1, 0
	for {
		tot = tot + tmp
		ans ++
		if tot >= a {
			break
		}
		tmp = tmp + tmp
	}
	fmt.Print(ans)
}


package main

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

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

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

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

func pcheck(i bool) {
	if i {
		printf("Yes\n")
	} else {
		printf("No\n")
	}
}

var debug = true

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

func main() {
	defer writer.Flush()

	n, m := getLine2Int2()
	var x int
	if n*2 < m {
		x = n
	} else if m*2 < n {
		x = m
	} else {
		x = (m + n) / 3
	}
	printf("%d\n", x)
}


package main

import "fmt"

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

	n++
	if n % 2 == 0 {
		fmt.Printf("%d\n", n / 2);
	} else {
		if n == 1 {
			fmt.Printf("0\n");
		} else {
			fmt.Printf("%d\n", n);
		}
	}
}


// Author: sighduck
// URL: https://codeforces.com/problemset/problem/371/C

package main

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

const MaxBurgers = int64(1e13)

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

func p(burgers, cb, cs, cc, nb, ns, nc, pb, ps, pc int64) int64 {
	return max(0, cb*burgers-nb)*pb + max(0, cs*burgers-ns)*ps + max(0, cc*burgers-nc)*pc
}

func _Solve(left, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles int64) int64 {
	if !(left < right) {
		return left
	}
	m := (left + right + 1) / 2
	cost := p(m, cb, cs, cc, nb, ns, nc, pb, ps, pc)
	if cost <= rubles {
		return _Solve(m, right, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)
	}
	return _Solve(left, m-1, cb, cs, cc, nb, ns, nc, pb, ps, pc, rubles)
}

func Solve(s string, nb, ns, nc, pb, ps, pc, r int64) int64 {
	cb := int64(strings.Count(s, "B"))
	cs := int64(strings.Count(s, "S"))
	cc := int64(strings.Count(s, "C"))
	return _Solve(0, MaxBurgers, cb, cs, cc, nb, ns, nc, pb, ps, pc, r)
}

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

	var s string
	fmt.Fscanf(reader, "%s\n", &s)
	var nb, ns, nc int64
	fmt.Fscanf(reader, "%d %d %d\n", &nb, &ns, &nc)
	var pb, ps, pc int64
	fmt.Fscanf(reader, "%d %d %d\n", &pb, &ps, &pc)
	var r int64
	fmt.Fscanf(reader, "%d\n", &r)

	fmt.Fprintf(writer, "%d\n", Solve(s, nb, ns, nc, pb, ps, pc, r))
}


package main

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

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

// Helpers

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

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

// Math

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

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

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

// IO

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

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

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

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

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

// Sort

type Ints64 []int64

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

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


package main

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

func main() {
	sc := NewScanner()
	k2, k3, k5, k6 := sc.NextInt(), sc.NextInt(), sc.NextInt(), sc.NextInt()

	k := min(k2, min(k5, k6))
	k2 -= k

	ans := 256 * k + min(k2, k3) * 32

	fmt.Println(ans)

}

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