package main

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

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

var a, b, c int64

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

	read(&a, &b, &c)
	write(a, b, c)
	a, b, c = sort(a, b, c)

	if a >= int64(2)*(b+c) {
		write(b + c)
	} else {
		write((a + b + c) / int64(3))
	}
}

func sort(a, b, c int64) (int64, int64, int64) {
	x := max(c, max(a, b))
	z := min(c, min(a, b))
	y := a + b + c - x - z
	return x, y, z
}

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

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

func write(num ...int64) {
	for _, value := range num {
		str := strconv.FormatInt(value, 10) + " "
		out.WriteString(str)
	}
	out.WriteString("\n")
}

func read(num ...*int64) {
	for _, value := range num {
		in.Scan()
		*value, _ = strconv.ParseInt(in.Text(), 10, 64)
	}
}


package main

import (
	"fmt"
	"math"
)

func main () {
	var r [3]float64
	_, _ = fmt.Scan(&r[0], &r[1], &r[2])
	fmt.Println(
		math.Min(
			float64(int64(r[0]+r[1]+r[2]) / 3),
			math.Min(
				r[0]+r[1],
				math.Min(r[1]+r[2], r[2]+r[0]))))
}


package main

import (
	"fmt"
)

func main() {
	var r, g, b int64
	fmt.Scan(&r, &g, &b)
	z := int64(0)
	for r+g+b >= 3 && (r*g > 0 || g*b > 0 || r*b > 0) {
		if r == g && g == b {
			z += r
			break
		}
		switch {
		case r >= g && r >= b:
			r -= 2
			if g > b {
				g--
			} else {
				b--
			}
		case g >= r && g >= b:
			g -= 2
			if r > b {
				r--
			} else {
				b--
			}
		case b >= g && b >= r:
			b -= 2
			if g > r {
				g--
			} else {
				r--
			}
		default:
			panic("do not reach here")
		}
		z++
	}
	fmt.Println(z)
}


package main

import "fmt"

// 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 min2(a int64, b int64) int64 {
	var res int64
	if a < b {
		res = a
	} else {
		res = b
	}
	return res
}
func min3(a int64, b int64, c int64) int64 {
	var res int64
	res = min2(a, min2(b, c))
	return res
}

func max2(a int64, b int64) int64 {
	var res int64
	if a > b {
		res = a
	} else {
		res = b
	}
	return res
}
func max3(a int64, b int64, c int64) int64 {
	var res int64
	res = max2(a, max2(b, c))
	return res
}

func main() {
	var (
		r int64
		g int64
		b int64
	)

	fmt.Scanf("%d %d %d", &r, &g, &b)
	if 2*max3(r, g, b) > (r + g + b - max3(r, g, b)) {
		fmt.Printf("%d\n", (r+g+b)/3)
	} else {
		fmt.Printf("%d\n", r+g+b-max3(r, g, b))
	}
}


package main

import (
	"fmt"
)

func main() {
	var n,x,y int64
	a,b,c:=0,0,0
	fmt.Scan(&n)
	for i:=0;i<n;i++ {
		fmt.Scan(&x,&y)
		a+=x
		b+=y
	}
	if x%2!=y%2 {
		c++
	}
	if a%2==0 && b%2==0 {
		fmt.Print("0")
	} else if c%2==0 && c>0 {
		fmt.Print("1")
	} else {
		fmt.Print("-1")
	}
}


package main

import (
	"fmt"
)

func main() {
	var n,x,y int
	a,b,c:=0,0,0
	fmt.Scan(&n)
	for i:=0;i<n;i++ {
		fmt.Scan(&x,&y)
		a+=x
		b+=y
	}
	if x%2!=y%2 {
		c++
	}
	if a%2==0 && b%2==0 {
		fmt.Print("0")
	} else if c%2==0 && c>0 {
		fmt.Print("1")
	} else {
		fmt.Print("-1")
	}
}


package main

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

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 main() {
  var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
  var writer *bufio.Writer = bufio.NewWriter(os.Stdout)
  defer writer.Flush()
  scanner.Split(bufio.ScanWords)

  n, k := ReadInt32(scanner), ReadInt32(scanner)
  hn := n / 2
  total := n * (n - 1) / 2

  if k >= hn {
    k = hn
    PrintInt(writer, total)
    return
  }
  PrintInts(writer, n, k, hn)

  total -= (n - k) * (n - k - 1) / 2
  total += k * (n - 2 * k)
  total += k * (k - 1) / 2

  PrintInt(writer, total)
  writer.WriteByte('\n')
}


package main

import . "fmt"

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 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{}
	for i := 0; i < 4; i++ {
		var x, y int64
		Scan(&x, &y)
		p0 := vec{x, y}
		Scan(&x, &y)
		p1 := vec{x, y}
		v := p1.sub(p0)
		if v.x != 0 && v.y != 0 {
			Print("NO")
			return
		}
		mp[p0]++
		mp[p1]++
	}
	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"
)

/*Simulating the problem of mashmokh and the lights
lights array will contain the current state of the light -1 / -2
0 -> ON
if any other number is present, then the light is switched off with that swtich*/
func main() {
    var n,m,b int
    fmt.Scanf("%d %d", &n, &m)
    var light []int = make([]int, n)
    for i := 0; i < n; i++ {
        light[i] = -1
    }

    for l := 0; l < m; l++ {
        retN, _ := fmt.Scanf("%d", &b)
        if retN == 0 {
            continue
        }

        b = b - 1
        for i := b; (i < n ) && (light[i] == -1); i++ {
            light[i] = b + 1
        }
    }

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

    return
}


package main

import "fmt"

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

	r1 := (a + b) * c
	r2 := a + b*c
	r3 := a*b + c
	r4 := a * (b + c)
	r5 := a * b * c

	max := r1
	if r2 > max {
		max = r2
	}
	if r3 > max {
		max = r3
	}
	if r4 > max {
		max = r4
	}
	if r5 > max {
		max = r5
	}

	fmt.Print(max)

}


package main

import (
	"fmt"
	"os"
)

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

func main() {
	var a, b, c int
	if _, err := fmt.Scanf("%d %d %d", &a, &b, &c); err != nil {
		os.Exit(1) // very unlikely...
	}

	var best = 0
	best = max(best, (a+b)+c)
	best = max(best, (a+b)*c)
	best = max(best, (a*b)+c)
	best = max(best, (a*b)*c)

	best = max(best, a+(b*c))
	best = max(best, a*(b+c))
	fmt.Println(best)
	os.Exit(0)
}


package main

import (
	"fmt"
)

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)
	if a == 1 && b == 1 && c == 1 {
		fmt.Println(a + b + c)
	} else if a == 1 && b == 1 {
		fmt.Println((a + b) * c)
	} else if b == 1 && c == 1 {
		fmt.Println((c + b) * a)
	} else if a == 1 && c == 1 {
		fmt.Println(a + b + c)
	} else if a == 1 {
		fmt.Println((a + b) * c)
	} else if b == 1 {
		if a > c {
			fmt.Println((a + b) * c)
		} else {
			fmt.Println(a * (b + c))
		}
	} else if c == 1 {
		fmt.Println((c + b) * a)
	} else {
		fmt.Println(a * b * c)
	}
}


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 i*3 + j > 4 {
				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")
	}

}


// 12A
package main

import (
	"fmt"
)

func main() {
	var a, b, c [4]string
	m := 0
	fmt.Scan(&a, &b, &c)
	if a[0] == c[2] || a[1] == c[1] || a[2] == c[0] || b[0] == b[2] {
		m = 1
	}
	if m == 1 {
		fmt.Print("YES")
	}
	if m == 0 {
		fmt.Print("NO")
	}
}


// A. Nauuo and Votes
/*
Nauuo is a girl who loves writing comments.

One day, she posted a comment on Codeforces, wondering whether she would get upvotes or downvotes.

It's known that there were 𝑥 persons who would upvote, 𝑦 persons who would downvote, and there were also another 𝑧 persons who would vote, but you don't know whether they would upvote or downvote. Note that each of the 𝑥+𝑦+𝑧 people would vote exactly one time.

There are three different results: if there are more people upvote than downvote, the result will be "+"; if there are more people downvote than upvote, the result will be "-"; otherwise the result will be "0".

Because of the 𝑧 unknown persons, the result may be uncertain (i.e. there are more than one possible results). More formally, the result is uncertain if and only if there exist two different situations of how the 𝑧 persons vote, that the results are different in the two situations.

Tell Nauuo the result or report that the result is uncertain.

Input
The only line contains three integers 𝑥, 𝑦, 𝑧 (0≤𝑥,𝑦,𝑧≤100), corresponding to the number of persons who would upvote, downvote or unknown.

Output
If there is only one possible result, print the result : "+", "-" or "0".

Otherwise, print "?" to report that the result is uncertain.

Examples
Input
3 7 0

Output
-

Input
2 0 1

Output
+

Input
1 1 0

Output
0

Input
0 0 1

Output
?

Note
In the first example, Nauuo would definitely get three upvotes and seven downvotes, so the only possible result is "-".

In the second example, no matter the person unknown downvotes or upvotes, Nauuo would get more upvotes than downvotes. So the only possible result is "+".

In the third example, Nauuo would definitely get one upvote and one downvote, so the only possible result is "0".

In the fourth example, if the only one person upvoted, the result would be "+", otherwise, the result would be "-". There are two possible results, so the result is uncertain.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _ := reader.ReadString('\n')
	arr := strings.Split(strings.TrimSpace(input), " ")
	x, _ := strconv.Atoi(arr[0])
	y, _ := strconv.Atoi(arr[1])
	z, _ := strconv.Atoi(arr[2])

	if z != 0 && x+z == y+z {
		fmt.Print("?")
	} else if x+z > y+z {
		fmt.Print("+")
	} else if x+z < y+z {
		fmt.Print("-")
	} else if x+z == y+z {
		fmt.Print("0")
	}
}


package main

import (
	"fmt"
)

func main() {
	var x, y, z int
	_, _ = fmt.Scanf("%d %d %d", &x, &y, &z)
	if x - y > z {
		fmt.Println("+")
	} else if x - y < z {
		fmt.Println("-")
	} else if z == 0 {
		fmt.Println("0")
	} else {
		fmt.Println("?")
	}
}


package main

import (
	"fmt"
)

func main() {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	r := x - y
	if r == 0 {
		if z == 0 {
			fmt.Print("0")
		} else {
			fmt.Print("?")
		}
	} else if r > z {
		if r > 0 {
			fmt.Print("+")
		} else {
			fmt.Print("-")
		}
	} else {
		fmt.Print("?")
	}
}


package main

import (
	"fmt"
)

func main() {

	//reader := bufio.NewReader(os.Stdin)
	var n, m, a, b int
	//fmt.Println("meta algo")
	fmt.Scanf("%d %d %d %d", &n, &m, &a, &b)

	num1, num2 := (n%m)*b, (m-n%m)*a
	fmt.Println(num1, num2)
	fmt.Println(min(num1, num2))

}

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


package main

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

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

	if b < 0 {
		return a
	}

	if a < b {
		return a
	}
	return b
}

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

	scanner.Scan()
	data := strings.Split(scanner.Text(), " ")

	//fmt.Println(data, len(data))

	cabs, _ := strconv.Atoi(data[0])
	dils, _ := strconv.Atoi(data[1])
	pBuild, _ := strconv.Atoi(data[2])
	pDestroy, _ := strconv.Atoi(data[3])

	high := dils
	low := dils
	for high = dils; cabs > high; high = high + dils {
		low = high
	}

	if high == cabs {
		fmt.Print(0)
		return
	}

	pLow := pDestroy * (cabs - low)
	pHigh := pBuild * (high - cabs)
	pDestroyAll := pDestroy * cabs

	//fmt.Println(high, low, cabs, pLow, pHigh, pDestroyAll)

	fmt.Println(min0(min0(pLow, pHigh), pDestroyAll))
}


package main

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

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

	if b < 0 {
		return a
	}

	if a < b {
		return a
	}
	return b
}

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

	scanner.Scan()
	data := strings.Split(scanner.Text(), " ")

	cabs, _ := strconv.ParseInt(data[0], 10, 64)
	dils, _ := strconv.ParseInt(data[1], 10, 64)

	pBuild, _ := strconv.ParseInt(data[2], 10, 64)
	pDestroy, _ := strconv.ParseInt(data[3], 10, 64)

	high := dils
	low := dils
	for high = dils; cabs > high; high = high + dils {
		low = high
	}

	if high == cabs {
		fmt.Print(0)
		return
	}

	pLow := pDestroy * (cabs - low)
	pHigh := pBuild * (high - cabs)
	pDestroyAll := pDestroy * cabs

	//fmt.Println(high, low, cabs, pLow, pHigh, pDestroyAll)

	fmt.Println(min0(min0(pLow, pHigh), pDestroyAll))
}


package main

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

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

type Team struct {
	name string
	pts, x, y, played int
}

type Sorter []Team

func (s Sorter) Len() int { return len(s) }
func (s Sorter) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
func (s Sorter) Less(i, j int) bool {
	if s[i].pts > s[j].pts {
		return true
	}
	if s[i].pts < s[j].pts {
		return false
	}
	if s[i].x - s[i].y > s[j].x - s[j].y {
		return true
	}
	if s[i].x - s[i].y < s[j].x - s[j].y {
		return false
	}
	if s[i].x > s[j].x {
		return true
	}
	if s[i].x < s[j].x {
		return false
	}
	return s[i].name < s[j].name
}

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

	s2m := make(map[string]*Team)
	for i := 0; i < 5; i++ {
		name1, name2, score := Next(), Next(), Next()
		if _, exists := s2m[name1]; !exists {
			s2m[name1] = &Team{name: name1}
		}

		if _, exists:= s2m[name2]; !exists {
			s2m[name2] = &Team{name: name2}
		}

		t1, _ := s2m[name1]
		t2, _ := s2m[name2]

		s := strings.Split(score, ":")
		s1, _ := strconv.Atoi(s[0])
		s2, _ := strconv.Atoi(s[1])

		t1.played += 1
		t2.played += 1
		t1.x += s1
		t1.y += s2
		t2.x += s2
		t2.y += s1

		if s1 > s2 {
			t1.pts += 3
		}else if s1 < s2 {
			t2.pts += 3
		}else {
			t1.pts += 1
			t2.pts += 1
		}
	}

	var berland, other Team
	var teams [4]*Team
	var at int = 0
	for _, value := range s2m {
		teams[at] = value
		at += 1

		if value.played == 2 {
			if value.name == "BERLAND" {
				berland = *value
			}else {
				other = *value
			}
		}
	}

	berland.pts += 3
	berland.played += 1

	other.played += 1

	// fmt.Fprintln(out, berland)

	var score1, score2 int = -1, -1
	for x := 0; x < 1000; x++ {
		for y := 0; y < x; y++ {
			b := make([]Team, 0)
			for i := 0; i < 4; i++ {
				if teams[i].name == berland.name || teams[i].name == other.name {
					continue
				}
				b = append(b, *teams[i])
			}

			// fmt.Fprintln(out, b)

			brld, othr := berland, other
			brld.x += x
			brld.y += y
			othr.x += y
			othr.y += x
			b = append(b, brld)
			b = append(b, othr)
			sort.Sort(Sorter(b))

			// fmt.Fprintln(out, b)

			if b[0].name == berland.name || b[1].name == berland.name {
				if score1 == -1 || score1 - score2 > x - y || (score1 - score2 == x - y && score2 > y){
					score1, score2 = x, y
				}
			}
		}
	}

	if score1 == -1 {
		fmt.Fprintln(out, "IMPOSSIBLE")
	}else {
		fmt.Fprintln(out, score1, score2)
	}
}

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

	return in.Text()
}

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


package main

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

func main() {
	var n int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &n)
	i := 0
	for i = 1; (i * (i + 1)) < n; i++ {
	}
	fmt.Println(i - 1)
}


package main
import (
	"fmt"
)
func main() {
	var cubes, height, sum, i int = 0, 0, 0, 1
	fmt.Scan(&cubes)
	for sum <= cubes {
		sum = sum + i
		cubes = cubes - sum
		i = i + 1
		height = height + 1
	}
	fmt.Println(height)
}


package main

import ("fmt")

// func calculate(s string, carry int, t int) int {

// 	carry = 1
// 	count := 0
// 	for i:=0;i<t;i++{
// 		if carry==1 && s[i]=='1'{
// 			count++
// 			carry = 1
// 		}
// 		if carry==1 && s[i]=='0'{
// 			count++
// 			carry =0
// 		}
// 	}
// 	return count
// }

func main(){
	var t int
	fmt.Scanln(&t)
	var ans int
	var temp int = 0
	for i:=1;i<10001;i++{
		dummy := ((i)*(i+1))/2
		temp += dummy
		if temp>=t{
			ans = i-1
			break
		}
	}
	if t==1{
		fmt.Println(1)
	}else{
		fmt.Println(ans)
	}
}


package main

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

var reader *bufio.Reader

func init() {
	stdin := os.Stdin
	// stdin, _ = os.Open("1.in")
	reader = bufio.NewReaderSize(stdin, 1<<20)
}

var n int

func main() {
	fmt.Fscan(reader, &n)
	for i := 1; i < n; i++ {
		if i*(i+1) > n {
			fmt.Println(i - 1)
			return
		}
	}
}


package main

import (
	"fmt"
	"math"
)

type Point struct {
	X, Y float64
}

type Square struct {
	Points [4]Point
}

func rotateAxis(p Point, angle float64) (res Point) {
	res = Point{}
	angle = (angle * math.Pi) / 180
	res.X = p.X*math.Cos(angle) + p.Y*math.Sin(angle)
	res.Y = -1*p.X*math.Sin(angle) + p.Y*math.Cos(angle)
	return
}

func isInSquare(sq Square, p Point) (b bool) {
	var minHoz float64 = 101
	for _, v := range sq.Points {
		minHoz = math.Min(minHoz, v.Y)
	}

	var maxHoz float64 = -101
	for _, v := range sq.Points {
		maxHoz = math.Max(maxHoz, v.Y)
	}

	var minVer float64 = 101
	for _, v := range sq.Points {
		minVer = math.Min(minVer, v.X)
	}

	var maxVer float64 = -101
	for _, v := range sq.Points {
		maxVer = math.Max(maxVer, v.X)
	}

	return (p.X >= minVer && p.X <= maxVer) && (p.Y >= minHoz && p.Y <= maxHoz)
}

func solve(sq, sq45 Square) bool {
	for _, v := range sq45.Points {
		if isInSquare(sq, v) {
			return true
		}
	}

	rotatedSquare := Square{}
	for i := range rotatedSquare.Points {
		rotatedSquare.Points[i] = rotateAxis(sq45.Points[i], 45)
	}

	for _, v := range sq.Points {
		rotatedPoint := rotateAxis(v, 45)
		if isInSquare(rotatedSquare, rotatedPoint) {
			return true
		}
	}

	return false
}

func consoleInput() {
	var x, y float64
	sq := Square{}
	for i := 0; i < 4; i++ {
		fmt.Scan(&x, &y)
		sq.Points[i] = Point{
			X: x,
			Y: y,
		}
	}

	sq45 := Square{}
	for i := 0; i < 4; i++ {
		fmt.Scan(&x, &y)
		sq45.Points[i] = Point{
			X: x,
			Y: y,
		}
	}

	if solve(sq, sq45) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func mustEqual(expected, actual bool) {
	if expected == actual {
		fmt.Println("OK")
	} else {
		fmt.Println("FAILED")
	}
}

func test() {
	{
		sq := Square{
			Points: [4]Point{
				Point{0, 0},
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{1, 3},
				Point{3, 5},
				Point{5, 3},
				Point{3, 1},
			},
		}

		mustEqual(true, solve(sq, sq45))
	}

	{
		sq := Square{
			Points: [4]Point{
				Point{0, 0},
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{7, 3},
				Point{9, 5},
				Point{11, 3},
				Point{9, 1},
			},
		}

		mustEqual(false, solve(sq, sq45))
	}

	{
		sq := Square{
			Points: [4]Point{
				Point{6, 0},
				Point{6, 6},
				Point{0, 6},
				Point{0, 0},
			},
		}

		sq45 := Square{
			Points: [4]Point{
				Point{7, 4},
				Point{4, 7},
				Point{7, 10},
				Point{10, 7},
			},
		}

		mustEqual(true, solve(sq, sq45))
	}
}

func main() {
	consoleInput()
	// test()
}


package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,k int
    fmt.Scan(&n,&k)
    a := make([]int,n+1)
    ok := true
    for i := 1; i <= n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
        if (i > k) && (a[i] != a[k]) {
            ok = false
        }
    }
    if ok {
        ans := k
        for a[ans-1] == a[k] { ans-- }
        fmt.Println(ans-1)
    } else {
        fmt.Println(-1)
    }
}


package main

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

type contestIn struct {
	reader io.Reader
}

type contestOut struct {
	writer io.Writer
}

type Contest struct {
	In contestIn
	Out contestOut
}

func NewSubmitContest() Contest {
	return Contest{contestIn{os.Stdin}, contestOut{os.Stdout}}
}

func NewTestContest(testIn string, testOut *bytes.Buffer) Contest  {
	return Contest{contestIn{strings.NewReader(testIn)}, contestOut{testOut}}
}

func (in contestIn) Var(a interface{}) {
	fmt.Fscan(in.reader, a)
}

func (in contestIn) Vars(a interface{}) {
	fmt.Fscanln(in.reader, a)
}

func (in contestIn) Str() string {
	var s string
	in.Var(&s)

	return s
}

func (in contestIn) Int() int {
	var i int
	in.Var(&i)

	return i
}

func (in contestIn) Ints(len int) []int {
	arr := make([]int, 0, len)
	for ; len > 0; len-- {
		var i int
		in.Var(&i)
		arr = append(arr, i)
	}

	return arr
}

func (out contestOut) F(format string, a ...interface{}) contestOut {
	fmt.Fprintf(out.writer, format, a...)
	return out
}

func (out contestOut) Str(s string) contestOut {
	fmt.Fprint(out.writer, s)
	return out
}

func (out contestOut) Int(i int) contestOut {
	out.F("%d", i)
	return out
}

func (out contestOut) N() contestOut {
	fmt.Fprintln(out.writer)
	return out
}

// https://codeforces.com/contest/981/problem/A
func problem(c Contest)  {
	s := c.In.Str()
	l := len(s)
	e := true // same chars

	for i := 0; i < len(s) / 2; i++ {
		if i > 0 {
			e = e && (s[i] == s[i-1])
		}

		if s[i] != s[l - i - 1] {
			// Not palindrome
			c.Out.Int(l).N()
			return
		}
	}

	// Palindrome
	if e {
		c.Out.Int(0).N()
	} else {
		c.Out.Int(l - 1).N()
	}
}

func main() {
	c := NewSubmitContest()
	problem(c)
}


package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	str, _, _ := r.ReadLine()
	fmt.Print(getLongestLen(string(str)))
}

func getLongestLen(str string) int {
	if !isPalindrome(str) {
		return len(str)
	}
	if isOneLetter(str) {
		return 0
	}
	return len(str)-1
}

func isPalindrome(str string) bool {
	for i := 0; i < (len(str)-1) / 2; i++ {
		if str[i] != str[len(str)-1-i] {
			return false
		}
	}
	return true
}

func isOneLetter(str string) bool {
	for i := 1; i < len(str); i++ {
		if str[0] != str[i] {
			return false
		}
	}
	return true
}


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)){
			str = removeLast(str)
		}
		fmt.Print(len(str))
	}
}


package main

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

func solve() {
	n := readInt64()
	k := readString()
	values := make([]int, 0)
	for len(k) > 0 {
		var maxValue int
		var maxIndex int
		for i := len(k) - 1; i >= 0; i-- {
			value, err := strconv.ParseInt(k[i:], 10, 32)
			if err == nil {
				if value <= n {
					maxValue = int(value)
					maxIndex = i
				}
			} else {
				panic(err)
			}
		}
		if maxIndex+1 < len(k) {
			for maxIndex < len(k) && k[maxIndex] == '0' {
				maxIndex++
			}
		}
		k = k[:maxIndex]
		values = append(values, maxValue)
	}
	var res int64
	for i := len(values) - 1; i >= 0; i-- {
		res *= n
		res += int64(values[i])
	}
	fmt.Println(res)
}

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

// 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() {
	n := readInt64()
	k := readString()
	values := make([]int, 0)
	for len(k) > 0 {
		var maxValue int
		var maxIndex int
		for i := len(k) - 1; i >= 0; i-- {
			value, err := strconv.ParseInt(k[i:], 10, 64)
			if err == nil {
				if value < n {
					maxValue = int(value)
					maxIndex = i
				} else {
					break
				}
			} else {
				panic(err)
			}
		}
		if maxIndex+1 < len(k) {
			if maxValue != 0 {
				for maxIndex < len(k) && k[maxIndex] == '0' {
					maxIndex++
				}
			} else if maxValue == 0 {
				maxIndex = len(k) - 1
			}
		}
		k = k[:maxIndex]
		values = append(values, maxValue)
	}
	var res int64
	for i := len(values) - 1; i >= 0; i-- {
		res *= n
		res += int64(values[i])
	}
	fmt.Println(res)
}

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

// 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 := readInt64()
	b := readInt64()

	res := int64(1)
	cnt := 0
	for i := a + 1; i <= b; i++ {
		m := int64(1)
		if i != 0 {
			m = i
		}
		m %= 10
		res %= 10
		res *= m
		if cnt > 10 {
			break
		}
	}
	fmt.Println(res % 10)
}

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

func max(a, b int64) int64 {
	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()
}

// 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"
	_ "math"
	"os"
	_ "sort"
)

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()

	var a,b int64
	scanf("%d %d\n", &a, &b)

	var ans = (a+1) % int64(10)

	for i:=a+2;i<=b && ans != 0; i++ {
		ans = (ans * (i % int64(10)) % int64(10) )
	}

	printf("%d\n", ans)
}


package main
import "fmt"

func main() {
    var a, b, x int64
    x = 1

    fmt.Scan(&a, &b);

    for i := a + 1; i <= b; i++ {
        x = (x * i % 10) % 10
    }

    fmt.Println(x);
}


package main

import (
	"fmt"
)

func main() {
	var exams, total int
	fmt.Scanf("%d", &exams)
	fmt.Scanf("%d", &total)
  var minscores=exams*2
  var diff = total - minscores
  switch {
    case diff < 0: panic("")
    case diff==0: fmt.Println(0)
    default:
      var diffdiff int = exams-diff
      switch {
        case diffdiff<=0: fmt.Println(0)
        default: fmt.Println(diffdiff)
      }
  }
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)
	ll := len(s) - 1
	if strings.Count(s, "0") == ll {
		ll--
	}
	fmt.Println(ll/2 + 1)
}


package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var (
		t string
	)
	_, _ = fmt.Fscan(input, &t)

	dk := len(t) - 1
	k := dk / 2
	more := false
	for i, n := range t {
		if i == 0{
			continue
		}
		if n == '1' {
			more = true
			break
		}

	}
	if more{
		fmt.Println(k + 1)
	}else {
		fmt.Println(k)
	}
}


package main

import "fmt"

func main() {
	var s string
	fmt.Scanf("%s", &s)
	N := len(s)
	res := (N - 1) / 2
	deg := s[0] == '1' && (N != 2)
	for i := 1; i < N; i++ {
		if s[i] == '1' {
			deg = false
			break
		}
	}
	if !deg && s != "0" {
		res++
	}
	fmt.Print(res)
}


package main

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

func main() {
	input := bufio.NewReader(os.Stdin)
	var s string

	_, err := fmt.Fscan(input, &s)
	if err != nil {
	}

	n := len(s)
	result := (n + 1) / 2
	k := s[1:]
	if t, _ := strconv.Atoi(k); t == 0 {
		result--
	}
	fmt.Println(result)
}


package main

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

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

func solve(s string) {
	a := "AEIOUY"
	p, m := 0, 0
	for i, c := range s {
		p++
		if strings.ContainsRune(a, rune(c)) || i == len(s)-1 {
			if m < p {
				m = p
			}


package main

import "fmt"

func main() {
    var s string
    fmt.Scan(&s)
    min, cur := 0, 0
    for _, c := range s {
        if c == "A" || c == "E" || c == "I" || c == "O" || c == "U" || c == "Y" {
            if min < cur+1 {
                min = cur+1
            }
            cur = 0
        } else {
            cur++
        }
    }
    if min < cur+1 {
        min = cur+1
    }
    fmt.Print(min)
}


package main

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

func main() {
	var n1, n2,k1, k2 int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscanf(in, "%d %d %d %d\n", &n1, &n2, &k1, &k2)
	if n1 / k2 >= n2 / k1 {
		fmt.Println("First")
	}else{
		fmt.Println("Second")
	}
}


package main

import (
    "strconv"
    "bufio"
    "os"
    "fmt"
)
// var file, _ = os.Open("input.txt")
// var outfile, _ = os.Create("output.txt")
// var in = bufio.NewScanner(file)
// var out = bufio.NewWriter(outfile)
var in = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

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

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n1 := nextInt()
    n2 := nextInt()
    k1 := nextInt()
    k2 := nextInt()
    if n1 > n2 {
        fmt.Fprintln(out, "First");
    } else {
        fmt.Fprintln(out, "Second");
    }
}


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

func main() {
	defer writer.Flush()
	var n, a, b, p1, p2 int

	arr := [22]int{}
	scanf("%d %d %d\n", &n, &a, &b)
	for i := 0; i < n; i = i + 1 {
		scanf("%d ", &arr[i])
	}
	p2 = n - 1
	ans := 0
	for p1 <= p2 {

		if p1 == p2 {
			if arr[p1] == 2 {
				ans += min(a, b)
			}
			break
		}

		if arr[p1] == arr[p2] && arr[p1] == 2 {
			ans = ans + min(a, b)
		}
		if arr[p1]^arr[p2] == 1 {
			ans = -1
			break
		}
		if arr[p1] == 2 && arr[p2] == 1 {
			ans = ans + b
		}
		if arr[p2] == 2 && arr[p1] == 1 {
			ans = ans + b
		}
		if arr[p1] == 2 && arr[p2] == 0 {
			ans = ans + a
		}
		if arr[p2] == 2 && arr[p1] == 0 {
			ans = ans + a
		}
		p1++
		p2--
	}
	printf("%d", ans)

}


package main

import (
	"fmt"
)

func main() {
	var Arr [105] int
	var N,w,b int
	fmt.Scanf("%d %d %d \n",&N,&w,&b)
	for i:=1; i<N; i++ {
		fmt.Scanf("%d ",&Arr[i])
	}
	min := b
	if w < b {
		min = w
	}
	sum := 0
	i := 1
	j := N
	for ; i<=j ;{
	    if i == j {
	        if Arr[i] == 2 {
	            sum += min
	        }
		} else if Arr[i] == Arr[j] {
			if Arr[i] == 2 {
				sum += (min * 2)
			}
		} else {
			if Arr[i] + Arr[j] < 2 {
				fmt.Printf("-1")
				return
			} else {
				if Arr[i] == 2 {
					if Arr[j] == 0 {
						sum += w
					} else {
						sum += b
					}
				} else {
					if Arr[i] == 0 {
						sum += w
					} else {
						sum += b
					}
				}
			}
		}
		i++
		j--
	}
	fmt.Printf("%d",sum)
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var word string
	fmt.Scan(&word)
	fmt.Println(replace(word))
}

func replace(word string) string {
	ans := ""
	for i := 0; i < len(word); i++ {
		if word[i] == 'o' {
			last := findLast(word, i)
			if last > i {
				ans += "***"
				i = last
			} else {
				ans += string(word[i])
			}
		} else {
			ans += string(word[i])
		}
	}
	return string(ans)
}

func findLast(word string, pos int) int {
	for i := pos; i < len(word); i++ {
		expected := byte('o')
		if (i-pos)&1 == 1 {
			expected = 'g'
		}
		if word[i] != expected {
			if word[i-1] == 'o' {
				return i - 1
			} else {
				return i - 2
			}
		}
	}
	return len(word) - 1
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF894B(in io.Reader, out io.Writer) {
	const mod int64 = 1e9 + 7
	pow := func(x, n int64) int64 {
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	var n, m int64
	Fscan(in, &n, &m)
	if n&1 != m&1 {
		Fprint(out, 0)
	} else {
		Fprint(out, pow(pow(2, n-1), m-1))
	}
}

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


func main() {
	var (
		n, m, a int
	)
	fmt.Scanln(&n, &m, &a)
	if n % a != 0 {
		n = ((n / a) + 1)
	}
	if m % a != 0 {
		m = ((m / a) + 1)
	}
	fmt.Println(n*m)
}


package main

import (
  "fmt"
  "strconv"
  "math"
  "math/big"
)

func main() {
    var w1, w2, w3 string
    fmt.Scanln(&w1, &w2, &w3)
    n := big.NewInt(strconv.ParseFloat(w1, 64))
    m := big.NewInt(strconv.ParseFloat(w2, 64))
    a := big.NewInt(strconv.ParseFloat(w3, 64))
    fmt.Println(math.Ceil(n/a) * math.Ceil(m/a))
}


package main

import "fmt"

func main() {
	var n, m, a uint64
	fmt.Scanf("%d %d %d", &n, &m, &a)
	rem := 0
	if n % a != 0 {
		rem = 1
	}
	cols := (n / a) + rem
	rem = 0
	if m % a != 0 {
		rem = 1
	}
	rows := (m / a) + rem
	fmt.Print(cols * rows)
}


package main
import "fmt"

func main (){
    var m,n,a int
    fmt.scanf("%d",&m,&n,&a)
    fmt.println(((m+a-1)/a)*((n+a-1)/a))
}


package main

import (
	"fmt"
	"sort"
)

const (
	MaxN = 128
)

type exam struct {
	s, d, c, index int
}

var n, m int
var e [MaxN]exam
var s [MaxN]int

func main() {
	fmt.Scanf("%d %d\n", &n, &m)
	for i := 0; i < m; i++ {
		fmt.Scanf("%d %d %d\n", &e[i].s, &e[i].d, &e[i].c)
		e[i].index = i + 1
	}
	sort.Slice(e[:m], func(i, j int) bool {
		return e[i].d < e[j].d
	})
	for i := 0; i < m; i++ {
		s[e[i].d] = m + 1
	}
	for i := 0; i < m; i++ {
		start := e[i].s
		for ;start <= n; start++ {
			if s[start] == 0 {
				break
			}
		}
		if start == n+1 {
			fmt.Println(-1)
			return
		}
		for counter := 0; counter < e[i].c; {
			if s[start + counter] != 0  {
				if start + counter == e[i].d {
					fmt.Println(-1)
					return
				}
				start++
				continue
			}
			s[start + counter] = e[i].index
			counter++
		}
	}
	for i := 1; i <= n; i++ {
		fmt.Printf("%d ", s[i])
	}
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n int
	var m int

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

	s := make([]int, m)
	d := make([]int, m)
	c := make([]int, m)
	sched := make([]int, n)
	for i := 0; i < n; i++ {
		sched[i] = 0
	}

	for i := 0; i < m; i++ {
		fmt.Fscan(in, &s[i], &d[i], &c[i])
		s[i]--
		d[i]--
		sched[d[i]] = m + 1
	}

	fail := false

	for i := 0; i < n; i++ {
		bestt := n + 10
		bestj := -1
		for j := 0; j < m; j++ {
			if s[j] <= i && i < d[j] && c[j] > 0 {
				t := 0

				for k := i; k < d[j]; k++ {
					if sched[k] == 0 {
						t++
					}
				}

				t -= c[j]

				if t < bestt {
					bestt = t
					bestj = j
				}
			}
		}

		if bestt < 0 {
			fail = true
			break
		}

		if bestj != -1 {
			sched[i] = bestj + 1
			c[bestj]--
		}
	}

	for i := 0; i < m; i++ {
		if c[i] > 0 {
			fail = true
			break
		}
	}

	if !fail {
		for i := 0; i < n; i++ {
			fmt.Fprint(out, sched[i], " ")
		}

		fmt.Fprintln(out)
	} else {
		fmt.Fprintln(out, -1)
	}

}


package main

import "fmt"
import "sort"

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	var maxP int
	ls := []int{a, b, c}
	sort.Sort(sort.Reverse(sort.IntSlice(ls)))
	var i, j, k int
	for i = 0; i <= n/ls[0]; i++ {
		for j = 0; j <= n/ls[1]; j++ {
			for k = 0; k <= n/ls[2]; k++ {
				if n == i*ls[0]+j*ls[1]+k*ls[2] {
					if maxP < i+j+k {
						maxP = i + j + k
					}
				}
			}
		}
	}
	fmt.Print(maxP)
}


package main

import "fmt"
import "sort"

func main() {
	var n, a, b, c int
	fmt.Scan(&n, &a, &b, &c)
	//maxP := bruteForce(n, a, b, c)
	maxP := dp(n, a, b, c)
	fmt.Print(maxP)
}

func dp(n, a, b, c int) int {
	dp := make([]int, n+1)
	dp[a] = 1
	dp[b] = 1
	dp[c] = 1
	for i := 1; i <= n; i++ {
		dp[i] = max(dp, i, i-a, i-b, i-c)
	}
	return dp[n]
}

func max(dp []int, nrs ...int) int {
	m := dp[nrs[0]]
	for _, nr := range nrs[1:] {
		if nr < 0 || dp[nr] == 0 {
			continue
		}
		if dp[nr]+1 > m {
			m = dp[nr] + 1
		}
	}
	return m
}

func bruteForce(n, a, b, c int) int {
	var maxP int
	ls := []int{a, b, c}
	sort.Sort(sort.Reverse(sort.IntSlice(ls)))
	for i := 0; i <= n/ls[0]; i++ {
		for j := 0; j <= n/ls[1]; j++ {
			d := n - i*ls[0] - j*ls[1]
			if d%ls[2] == 0 {
				k := d / ls[2]
				if maxP < i+j+k {
					maxP = i + j + k
				}
			}
		}
	}
	return maxP
}


package main

import (
	"fmt"
)

const maxN = 4000

func resolver(a, b, c, n int) int {
	// 최고로 많이 얻을 수 있는 조각의 수를 구한다
	// 0조각: 모든 계수를 0으로 맞추면 얻을 수 있다
	// 1조각: n == any of coeff
	var maximum int

	for i := 0; i <= n; i++ {
		for j := 0; j <= n; j++ {
			for k := 0; k <= n; k++ {
				if sum := a*i + b*j + c*k; sum == n {
					if maximum < i+j+k {
						maximum = i+j+k
					}
				}
			}
		}
	}

	return maximum // STUB
}

func main() {
	var n, a, b, c int
	fmt.Scanln(&n, &a, &b, &c)

	fmt.Println(resolver(a, b, c, n))
}


package main

import (
	"math"
	"fmt"
)

const maxN = 4000

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

	return a
}

func resolver(a, b, c, n int) int {
	if n > maxN {
		panic("Limit exceeded")
	}

	memo := make([]int, n+1)
	units := make([]int, 3)

	units[0], units[1], units[2] = a, b, c
	memo[0] = 0
	memo[a] = 1
	memo[b] = 1
	memo[c] = 1

	for i := 1; i <= n; i++ {
		var localMax int = math.MinInt32

		for _, v := range(units) {
			if delta := i - v; delta >= 0 {
				var localMaxCand int = intMax(localMax, memo[delta] + 1)

				if localMaxCand > localMax {
					localMax = localMaxCand
					memo[i] = localMax
				}
			}
		}

		memo[i] = localMax
	}

	return memo[n]
}

func main() {
	var n, a, b, c int
	fmt.Scanln(&n, &a, &b, &c)

	fmt.Println(resolver(a, b, c, n))
}


package main

import "fmt"

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

	n1 := n / a
	n2 := n / b
	n3 := n / c

	max := 0
	for i := 0; i <= n1; i++ {
		for j := 0; j <= n2; j++ {
			for k := 0; k <= n3; k++ {
				v := i*a + j*b + k*c
				if v >= n {
					if v == n && i+j+k > max {
						max = i + j + k
					}
					break
				}
			}
		}
	}

	fmt.Println(max)
}


package main

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

func MaxOf(vars ...int) int {
	max := vars[0]

	for _, i := range vars {
		if max < i {
			max = i
		}
	}

	return max
}

func main() {
	var reader io.Reader
	var writer io.Writer

	reader = os.Stdin
	writer = os.Stdout

	//file, _ := os.Open("input.txt")
	//reader = file

	var n, a, b, c int

	fmt.Fscanf(reader, "%d %d %d %d", &n, &a, &b, &c)

	f := make([]int, n+1)
	f[a] = 1
	f[b] = 1
	f[c] = 1

	for i := 0; i <= n; i++ {
		if i >= a && f[i-a] != 0 {
			f[i] = MaxOf(f[i-a]+1, f[i])
		}
		if i >= b && f[i-b] != 0 {
			f[i] = MaxOf(f[i-b]+1, f[i])
		}
		if i >= c && f[i-c] != 0 {
			f[i] = MaxOf(f[i-c]+1, f[i])
		}
	}

	fmt.Fprintln(writer, f[n])

}


package main

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

func Readln(r *bufio.Reader) (string, error) {
	var (
		isPrefix bool  = true
		err      error = nil
		line, ln []byte
	)
	for isPrefix && err == nil {
		line, isPrefix, err = r.ReadLine()
		ln = append(ln, line...)
	}
	return string(ln), err
}

func readIntArray(line string) []int {

	numStrings := strings.Split(strings.TrimSpace(string(line)), " ")

	numbers := make([]int, 0)

	for _, v := range numStrings {
		var converted int

		fmt.Sscanf(v, "%d", &converted)
		numbers = append(numbers, converted)
	}

	return numbers
}

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

	line, _ := Readln(reader)
	numbers := readIntArray(line)

	length := numbers[0]
	lengths := numbers[1:]

	cache := make(map[int]int, 0)
	fmt.Println(Cut(length, lengths, 0, cache))
}

func Cut(length int, lengths []int, pieces int, cache map[int]int) int {

	if cached, ok := cache[length]; ok {
		return cached
	}

	maxPieces := pieces
	isCut := false
	for _, ln := range lengths {
		if (length - ln) >= 0 {
			newPieces := Cut(length - ln, lengths, pieces + 1, cache)
			if maxPieces < newPieces {
				isCut = true
				maxPieces = newPieces
			}
		}
	}

	if (!isCut) && length > 0 {
		maxPieces = -1
		cache[length] = maxPieces
	} else if isCut && length == 0 {
		cache[length] = maxPieces
	}

	return maxPieces
}


package main

import "fmt"

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

func main() {

var n int

var a [3]int

fmt.Scan(&n,&a[0],&a[1],&a[2])

dp := make([]int,n+1)

dp[0] = 0

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

dp[i] = -999999999

for k := 0; k < 3; k++ {

if (i-a[k]) >= 0 {

dp[i] = max(dp[i],1+dp[i-a[k]])

}

}

}

fmt.Println(dp[n])

}


package main

import "fmt"

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

// https://codeforces.com/problemset/problem/189/A
// комментарии к решению
// Задача решается перебором. Для сокращения кол-ва комбинаций
// пытаемся сначала разрезать ленту на максимальное кол-во мелких кусочков,
// уменьшая их кол-во с каждой итерацией пробуем разрезать оставшуюся часть
// на ленты среднего размера, проводя аналогичный критерий выбора для
// среднего/крупного размера.
func taskSolution(n, a, b, c int) int {
	a, b, c = sortThree(a, b, c)
	max := 0
	for i := n / a; i >= 0; i -= 1 {
		for j := (n - i*a) / b; j >= 0; j -= 1 {
			for k := (n - i*a - j*b) / c; k >= 0; k -= 1 {
				if n == i*a+j*b+k*c && max < i+j+k {
					max = i + j + k
				}
			}
		}
	}
	return max
}

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

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


package main

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

func solve() {
	n := readInt()
	k := readInt()
	a := make([]int, k)
	n4 := n
	n2 := n * 2
	for i := 0; i < k; i++ {
		a[i] = readInt()
		cnt := min(n4, a[i]/4)
		n4 -= cnt
		a[i] -= cnt * 4
		cnt = min(n2, a[i]/2)
		n2 -= cnt
		a[i] -= cnt * 2
	}
	f := make([]int, 1)
	f[0] = -1
	for i := 0; i < n4; i++ {
		for j := 0; j < 4; j++ {
			f = append(f, 0)
		}
	}
	f = append(f, -1)
	for i := 0; i < n2; i++ {
		for j := 0; j < 2; j++ {
			f = append(f, 0)
		}
		f = append(f, -1)
	}
	for i := 1; i <= k; i++ {
		a := a[i-1]
		for j := 0; j < len(f) && a > 0; j++ {
			if f[j] == 0 && (f[j-1] == i || f[j-1] == 0 || f[j-1] == -1) && (f[j+1] == 0 || f[j+1] == -1) {
				f[j] = i
				a--
			}
		}
		if a > 0 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")
}

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

var sto [1005]int

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

func main() {
	var n, k int
	fmt.Scanf("%d %d\n", &n, &k)
	for index := 0; index < k; index++ {
		fmt.Scanf("%d\n", &sto[index])
	}
	sum, ans := n, 2*n
	for index := 0; index < k; index++ {
		minn := min(sum, sto[index]/4)
		sum -= minn
		sto[index] -= minn * 4
	}
	ans += sum
	for index := 0; index < k; index++ {
		minn := min(ans, sto[index]/2)
		ans -= minn
		sto[index] -= minn * 2
	}
	ans += sum
	for index := 0; index < k; index++ {
		ans -= sto[index]
	}
	if ans >= 0 {
		fmt.Printf("YES")
	} else {
		fmt.Printf("NO")
	}
}


package main

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

func main() {
	sc := NewScanner()
	N, K := sc.NextInt(), sc.NextInt()
	a := sc.NextIntArray()

	double := N * 2
	forth := make([][]int, N)
	for i := 0; i < N; i++ {
		forth[i] = make([]int, 2)
	}
	forth_pointer := 0
	for i := 0; i < K; i++ {
		q := a[i] / 4
		for k := 0; k < q; k++ {
			if forth_pointer < 2*N {
				forth[forth_pointer/2][forth_pointer%2] = i + 1
				forth_pointer++

				forth[forth_pointer/2][forth_pointer%2] = i + 1
				forth_pointer++
				a[i] -= 4
			}
		}
	}
	for i := 0; i < K; i++ {

		q := a[i] / 2

		diff := min(double, q)
		a[i] -= diff * 2
		double -= diff
	}
	for num := 2; num >= 1; num-- {

		for i := 0; i < K; i++ {
			q := a[i] / num
			e := forth_pointer
			for k := 0; k < q; k++ {
				if double > 0 {
					double--
					a[i] -= num
					continue
				}
				for ; e < 2*N; e++ {
					if num == 2 && e%2 == 1 {
						o := e - 1
						if forth[o/2][0] == i+1 {
							forth_pointer += 2
						} else {
							continue
						}
					}
					forth[e/2][e%2] = i + 1
					a[i] -= num
					e++
					break
				}
			}
		}
	}

	for i := 0; i < K; i++ {
		if a[i] > 0 {
			fmt.Println("NO")
			return
		}
	}
	fmt.Println("YES")

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


/*
URL:
https://codeforces.com/problemset/problem/937/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 (
	p, y int
)

func main() {
	p, y = ReadInt2()

	for i := y; i > p; i-- {
		if IsPrime(i) {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}

// IsPrime judges whether an argument integer is a prime number or not.
func IsPrime(n int) bool {
	var i int

	if n == 1 {
		return false
	}

	for i = 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}

	return true
}

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

/*********** 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 (
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"os"
)

func main() {
	var p, y int
	r := RapidReader()
	fmt.Fscan(r, &p, &y)
	for i := y; i >= 2 && i >= y-1000; i-- {
		ok := true
		for k := 2; k <= p && k < 31623; k++ {
			if i%k == 0 {
				ok = false
				break
			}
		}
		if ok {
			fmt.Println(i)
			return
		}
	}
	fmt.Println(-1)
}

func RapidReader() io.Reader {
	b, _ := ioutil.ReadAll(os.Stdin)
	return bytes.NewReader(b)
}


package main

import (
	"fmt"
)

func distance(n,a,b,c int) int  {
	if(n==1) {
		return 0
	} else {
		if(a<b) {
			return a+distance(n-1,b,c,a)
		} else {
			return b+distance(n-1,b,c,a)
		}
	}
}

func main() {
	var n,a,b,c int
	fmt.Scanf("%d\n%d\n%d\n%d",&n,&a,&b,&c)
	total_distance:=distance(n,a,b,c)
	fmt.Print(total_distance)
}


package main

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

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

	seq := make([]int, 3)
	if a < b {
		seq[0] = a
		seq[1] = c
		seq[2] = b
	} else {
		seq[0] = b
		seq[1] = c
		seq[2] = a
	}
	ans := 0
	for i := 0; i < N-1; i++ {
		ans += seq[i]
	}
	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 (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

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

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

	if a < b {
		if a < c {
			fmt.Println(a * (N - 1))
		} else {
			fmt.Println(a + c*(N-1))
		}
	}else {
		if b < c {
			fmt.Println(b * (N - 1))
		} else {
			fmt.Println(b + c*(N-2))
		}
	}

}

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

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

func (s *Scanner) 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"
	"strconv"
	"strings"
)

func main() {
	reader := bufio.NewReader(os.Stdin)
	integerWord, _ := reader.ReadString('\n')
	integerSufx := strings.TrimSuffix(integerWord, "\n")
	intV, _ := strconv.Atoi(integerSufx)
	stones, _ := reader.ReadString('\n')
	stones = strings.TrimSuffix(stones, "\r\n")
	ttl := 0
	for _, v := range stones {
		count := strings.Count(stones, string(v))
		if count > 1 {
			count--
			stones = strings.ReplaceAll(stones, string(v), "")
			ttl += count
		}
	}
	fmt.Print(ttl)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint8
	var c uint8
	var s string
	fmt.Fscanf(in, "%d\n", &n)
	fmt.Fscanf(in, "%s\n", &s)
	if n%2 != 0 {
		for i := 1; i < len(s)-1; {
			if s[i-1] == s[i] {
				c++
			}
			if s[i+1] == s[i] {
				c++
			}
			i += 2
		}
		fmt.Println(c)
	} else {
		for i := 1; i < len(s); {
			if s[i-1] == s[i] {
				c++
			}
			if s[i+1] == s[i] {
				c++
			}
			i += 2
		}
		fmt.Println(c)
	}
}


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

func main() {
	var n int
	var str string

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

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

	var i, j, move int = 0, 1, 0
	for {
		if str[i] == str[j] {
			move++
			j++
		} else {
			i = j
			j++
		}
		if j == n {
			break
		}
	}

	fmt.Println(move)
}


package main

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

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

	var n, m int
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	if m%n != 0 {
		fmt.Printf("-1\n")
		return
	}
	ans := 0
	m /= n
	for m > 1{
		if m%2==0{
			m/=2
			ans++
		}else if m%3==0{
			m/=3
			ans++
		}else{
			fmt.Printf("-1\n")
		}
	}
	fmt.Printf("%d\n",ans)

}


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

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

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

    splitted := strings.Split(input, " ")

    n, _ := strconv.Atoi(splitted[0])
    m, _ := strconv.Atoi(splitted[1])

    if n == m {
        fmt.Println("0")
        os.Exit(0)
    } else if m % n != 0 {
        fmt.Println("-1")
        os.Exit(0)
    }

    div := m / n
    if div % 2 != 0 && div % 3 != 0 {
        fmt.Println("-1")
        os.Exit(0)
    }

    divisors := [3] int {6, 3, 2}
    ans := 0

    for i := 0; i < 3; i++ {
        for div % divisors[i] == 0 {
            if i == 0 {
                ans += 2
            } else {
                ans++
            }
            div /= divisors[i]
        }
    }

    if div == 1 {
        fmt.Println(ans)
    } else {
        fmt.Println("-1")
    }
}


package main

import (
	"fmt"
)

func main() {
	var n,m int
	d:=0
	fmt.Scan(&n)
	fmt.Scan(&m)
	if m%n!=0{
	    fmt.Printf("%d", -1)
	}
	if m%n==0{
	    x:=m/n
	    for (x%2==0||x%3==0||x>1){
	        if x%2==0{
	            x=x/2
	            d+=1
	        }
	        if x%3==0{
	            x=x/3
	            d+=1
	        }
	    }
	    if x==1{
	        fmt.Printf("%d", d)
	    }
	    if x!=1{
	        fmt.Printf("%d", -1)
	    }
	}

}


package main

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

type Cin struct {
	scanner *bufio.Scanner
}

func (c *Cin) NextInt() int {
	c.scanner.Scan()
	line := c.scanner.Text()
	return c.convertInt(line)
}

func (c *Cin) NextIntSlice() []int {
	c.scanner.Scan()
	line := strings.Split(c.scanner.Text(), " ")
	var ret []int
	for _, s := range line {
		ret = append(ret, c.convertInt(s))
	}
	return ret
}

func (c *Cin) NextTwoInt() (int, int) {
	line := c.NextIntSlice()
	return line[0], line[1]
}

func (c *Cin) convertInt(data string) int {
	i, _ := strconv.Atoi(data)
	return i
}

var cin = &Cin{
	scanner: bufio.NewScanner(os.Stdin),
}

type element struct {
	value int
	step  int
	next  *element
	last  *element
}

func newElement(value, step int) *element {
	return &element{value: value, step: step}
}

type queue struct {
	head *element
	tail *element
}

func (q *queue) push(value, step int) {
	item := newElement(value, step)
	if q.isEmpty() {
		q.head = item
		q.tail = q.head
		return
	}
	item.last = q.tail
	q.tail.next = item
	q.tail = item
}

func (q *queue) isEmpty() bool {
	return q.head == nil
}

func (q *queue) pop() *element {
	if q.isEmpty() {
		panic("pop from empty queue")
	}
	item := q.head
	q.head = q.head.next
	return item
}

func newQueue() *queue {
	return &queue{}
}

func handle(n, m int) int {
	q := newQueue()
	q.push(n, 0)
	set := map[int]int{n: 0}
	for !q.isEmpty() {
		ele := q.pop()
		if ele.value == m {
			return ele.step
		}
		if _, ok := set[ele.value*2]; !ok {
			set[ele.value*2] = ele.step + 1
			// fmt.Printf("val=[%v],step=[%v]\n", ele.value*2, ele.step+1)
			q.push(ele.value*2, ele.step+1)
		}
		if _, ok := set[ele.value*3]; !ok {
			set[ele.value*3] = ele.step + 1
			// fmt.Printf("val=[%v],step=[%v]\n", ele.value*3, ele.step+1)
			q.push(ele.value*3, ele.step+1)
		}
	}
	return -1
}

func main() {
	n, m := cin.NextTwoInt()
	fmt.Printf("%d\n", handle(n, m))
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)
var scanner *bufio.Scanner = bufio.NewScanner(os.Stdin)
func ReadStr() string{
	scanner.Scan()
	return scanner.Text()
}

func ReadInt() int  {
	scanner.Scan()
	n,err := strconv.Atoi(scanner.Text())
	if err != nil{
		panic(err)
	}
	return n
}
func main()  {
	// 1 2 3 4 5 6 7 8
	// 0 2 0 4 0 6 0 8
	n := ReadInt()
	m := ReadInt()
	if(m == 0){
		fmt.Println(1);
	}else if(m < (n + 1) / 2){
			fmt.Println(m)
	} else{
		fmt.Println(n - m)
	}

}


package main

import (
  "fmt"
)

func main() {
  var n, m int
  fmt.Scanf("%d%d", &n, &m)
  if m < n / 2 {
    if m == 0 {
      m = 1
    }
    fmt.Printf("%d", m)
  } else {
    fmt.Printf("%d", n - m)
  }
}


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

  a, b := getI(), getI()
  for {
    a++
    x, y := a, b
    for x != 0 {
      d := x%10
      x /= 10
      if d == 4 || d == 7 {
        if d == y%10 {
          y /= 10
        } else {
          x = 0
        }
      }
    }
    if y == 0 {
      break
    }
  }
  writer.WriteString(fmt.Sprintf("%d\n", a))
}


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

package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	// fmt.Println("Hello, world!")
	in := gsls(reader)[0]

	if strings.Count(in[strings.Index(in, "1"):], "0") >= 6 {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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


package main

import "fmt"
import "os"
import "bufio"

var s string
func main() {
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &s)
	zero := 0
	one := 0
	for i := 0; i < len(s); i++ {
		if s[i] == '0' {
			zero++
		} else {
			one++
		}
	}

	if one > 1 && zero >= 6 {
		fmt.Printf("yes")
	} else {
		fmt.Printf("no")
	}
}


package main

import "fmt"
import "os"
import "bufio"

var s string
func main() {
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &s)
	i : = 0
	zero := 0

	for i < len(s) {
		if  s[i] == '1' { break }
	}

	for i < len(s) {
		if s[i] == '0' {
			zero++
		}
	}
}


package main

import "fmt"
import "os"
import "bufio"

var s string
func main() {
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &s)
	i := 0
	zero := 0

	for i < len(s) {
		if  s[i] == '1' { break }
	}

	for i < len(s) {
		if s[i] == '0' {
			zero++
		}
	}

	if zero > 5 {
		fmt.Printf("yes")
		os.Exit(0)
	}
	fmt.Printf("no")
}


package main

import(
	"fmt"
)

func abs(a int) int{

	if(a > 0){
		return a
	}else{
		return a * (-1)
	}

}

func main(){

	var n int
	var ans int

	fmt.Scanln(&n)

	skills := make([]int, n)
	ans = 0

	for i := 0; i < n; i++{
		fmt.Scanln(&skills[i])
	}

	for i := 0; i < n; i++{
		for j := n - 1; j > i; j--{
			if skills[j] < skills[j-1]{
				tmp := skills[j]
				skills[j] = skills[j-1]
				skills[j-1] = tmp
			}
		}
	}

	for i := 0; i < n; i += 2{
		ans += abs(skills[i]-skills[i+1])
	}

	fmt.Print(ans)
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanln(&n)
	lev := make([]int, n)
	for i := range lev {
		fmt.Scan(&lev[i])
	}
	sort.Sort(sort.IntSlice(lev))

	b := 0
	for i := 0; i < n/2; i++ {
		if lev[i*2] >= lev[i*2+1] {
			b += lev[i*2] - lev[i*2+1]
		} else {
			b += lev[i*2] - lev[i*2]
		}
	}
	fmt.Println(b)
}


package main

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

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 max(a,b int) int { if a > b { return a } else { return b } }

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

const alphabets = "abcdefghijklmnopqrstuvwxyz"

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

	Problem1092B()
}

func Problem1092B() {
	n := getI()
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = getI()
	}
	sort.Ints(arr)
	max := 0
	for i := 0; i < n; i+=2 {
		if arr[i] != arr[i+1] {
			max += arr[i+1] - arr[i]
		}
	}
	println(max)
}


package main

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

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 max(a,b int) int { if a > b { return a } else { return b } }

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

const alphabets = "abcdefghijklmnopqrstuvwxyz"

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

	Problem1092B()
}

func Problem1092B() {
	n := getI()
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = getI()
	}
	sort.Ints(arr)
	max := 0
	for i := 0; i < n; i+=2 {
		if arr[i] != arr[i+1] {
			max += arr[i+1] - arr[i]
		}
	}
	println(max)
}


package main

import (
	"fmt"
	"strings"
)
//bg менять на gb
func checking(s string) {
	flag := strings.ReplaceAll(s, "BG", "GB")
	return flag
}

func main() {
	var itog string
    var x, y int
	fmt.Scan(&itog)
    fmt.Scan(&x, &y)

	for i := 0; i < y; i++ {
		itog = checking(itog)
	}
	fmt.Println(itog)
}


package main

import (
	"fmt"
)

func main() {
	var n, t uint
	var s string
	//in := bufio.NewReader(os.Stdin)
	fmt.Scan(&n, &t)
	fmt.Scan(&s)
	for j := uint(0); j < t; j++ {
		for i := uint(0); i < uint(len(s)-1); {
			if string(s[i]) == "B" && string(s[i+1]) == "G" {
				r := []rune(s)
				t := r[i]
				r[i] = r[i+1]
				r[i+1] = t
				s = string(r)
				i += 2
			}
			i++
		}
	}

	fmt.Println(s)
	//BGGBG
	//GBGGB
}


package main
import (
		"fmt"
		"strings"
)
func main() {
	var n,t int
	var s string
	fmt.Scan(&n,&t,&s)
	for t > 0 {
		var ans []string
		var toggle = 0
		for i := range s{
			if s[i] == 71 && i != 0 && toggle == 0{ //G
				if ans[i-1] == "B" {
					ans[i-1] = "G"
					ans = append(ans,"B")
					toggle = 1;
				}
			} else{
				ans = append(ans,string(s[i]))
				toggle = 0;
			}
		}
		s = strings.Join(ans,"")
		t--
	}
	fmt.Println(s)
}


package main

import "fmt"

func main() {
	var (
		n, t int
		l    string
		s    []rune
	)

	fmt.Scan(&n, &t)
	fmt.Scan(&l)
	s = []rune(l)

	for i := 0; i < t; i++ {
		l = string(s)
		for j := 0; j < n; j++ {
			if l[j] == 'B' && l[j+1] == 'G' {
				s[j], s[j+1] = 'G', 'B'
				j++
			}
		}
	}

	fmt.Println(string(s))
}


package main

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

func main()  {

	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()

	var n int
	fmt.Fscan(in, &n)

	cnt := 0
	for n > 0 {
		cnt++
		n -= cnt
	}

	fmt.Fprintln(out, cnt)

}


package main

import "fmt"
import "math"
func main() {
	 var n float64
	fmt.Scanf("%f",&n);
	fmt.Println(int(math.Log(n))+1);
}


package main

import "fmt"

func main() {
    var p,a,b int
    min := 1001
    for i := 0; i < 4; i++ {
        fmt.Scan(&p)
        if min > p { min = p }
    }
    fmt.Scan(&a,&b)
    ans := min-a
    if ans < 0 { ans = 0 }
    fmt.Println(ans)
}


package main

import (
    "fmt"
    "strconv"
)

type pos struct{
    x int
    y int
}

func mark_rock(board *[9][9]int, pos_r pos){
    for i:=pos_r.x+1; i<=8; i++{
        if board[i][pos_r.y] < 2 {
            board[i][pos_r.y] = 1
        }else{
            break
        }
    }
    for i:=pos_r.x-1; i>=1; i--{
        if board[i][pos_r.y] < 2 {
            board[i][pos_r.y] = 1
        }else{
            break
        }
    }
    for j:=pos_r.y+1; j<=8; j++{
        if board[pos_r.x][j] < 2 {
            board[pos_r.x][j] = 1
        }else{
            break
        }
    }
    for j:=pos_r.y-1; j>=1; j--{
        if board[pos_r.x][j] < 2 {
            board[pos_r.x][j] = 1
        }else{
            break
        }
    }
}

func is_valid(x int, y int) bool{
    if x>=1 && x<=8{
        return y>=1 && y<=8
    }
    return false
}

var move_x = [3]int{-1, 0, 1}
var move_y  = [3]int{-1, 0, 1}

func mark_king(board *[9][9]int, pos_k pos){
    for i:=0; i<3; i++{
        for j:=0; j<3; j++{
            x:= pos_k.x+move_x[i]
            y:= pos_k.y+move_y[j]
            if !is_valid(x,y){
                continue
            }
            if board[x][y] >=2{
                continue
            }
            board[x][y] = 1
        }
    }
}

func Result(bk pos, board [9][9]int) string{
    for i:= 0; i<3; i++{
        for j:=0; j<3; j++{
            x:= bk.x + move_x[i]
            y:= bk.y + move_y[j]
            if x==0 && y==0{
                continue
            }
            if !is_valid(x,y){
                continue
            }
            if board[x][y] == 2{
                return "OTHER"
            }
            if board[x][y] == 0{
                return "OTHER"
            }
        }
    }
    return "CHECKMATE"
}

func main(){
    chess := map[string]pos{}
    toi := [9]byte{'a','b', 'c', 'd', 'e', 'f', 'g', 'h'}
    for k, letter := range toi{
        for j:=1; j<=8; j++{
            chess[string(letter) + strconv.Itoa(j)] = pos{k+1, j}
        }
    }
    board := [9][9]int{}
    var wr, wr2, wk, bk string
    fmt.Scanf("%s %s %s %s", &wr, &wr2, &wk, &bk)
    pos_wr, _ := chess[wr]
    board[pos_wr.x][pos_wr.y] = 2 //rock
    pos_wr2, _ := chess[wr2]
    board[pos_wr2.x][pos_wr2.y] = 2 //rock
    pos_wking, _ := chess[wk]
    board[pos_wking.x][pos_wking.y] = 3 //white king
    pos_bking, _ := chess[bk]
    mark_rock(&board, pos_wr)
    mark_rock(&board, pos_wr2)
    mark_king(&board, pos_wking)
    //show(board)
    fmt.Println(Result(pos_bking, board))
}

func show(board [9][9]int){
    for i:=1; i<=8; i++{
        for j:=1; j<=8; j++{
            fmt.Printf("%d,%d:%v ", i, j, board[i][j])
        }
        fmt.Printf("\n")
    }
    fmt.Println("---------------")
}


package main

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

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

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

func main() {
	defer writer.Flush()
	var n, m int64

	scanf("%d %d", &n, &m)

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

	mp := make(map[int64]int64)

	r := n / m
	c := n % m

	for i := int64(1); i <= m; i++ {
		mp[i*i%m] += r
	}

	for i := int64(1); i <= c; i++ {
		mp[i*i%m] += 1
	}
	ans := int64(0)
	for k, v := range mp {

		ans += v * mp[m-k]

	}

	ans += mp[int64(0)]

	fmt.Println(ans)

}


package main

import (
	"fmt"
)

var mod int64 = 1000000007

func main() {
	var a, b int64
	fmt.Scanf("%d %d", &a, &b)
	sum1 := (b - 1) * b / 2
	sum1 = sum1 % mod
	sum2 := a * (a + 1)
	sum2 = sum2 % mod
	sum2 = sum2 * b / 2
	sum2 = sum2 % mod
	sum := sum1 * (a + sum2)
	sum = sum % mod
	fmt.Println(sum)
}


package main
import "fmt"

var s75 = "What are you doing at the end of the world? Are you busy? Will you save us?"
var s34 = "What are you doing while sending \""
var s32 = "\"? Are you busy? Will you send \""
var s2 = "\"?"

var f = make([]int64, 100001)

func printChar(n int, k int64) {
	if k > f[n] {
		fmt.Print(".")
		return
	}

	if n == 0 {
		fmt.Print(string(s75[k-1]))
		return
	}

	if k <= 34 {
		fmt.Print(string(s34[k-1]))
		return
	}

	k -= 34
	if k <= f[n-1] {
		printChar(n-1, k)
		return
	}

	k -= f[n-1]
	if k <= 32 {
		fmt.Print(string(s32[k-1]))
		return
	}

	k -= 32
	if k <= f[n-1] {
		printChar(n-1, k)
		return
	}

	k -= f[n-1]
	fmt.Print(string(s2[k-1]))
}

// calc len(fi)
func main() {
	// 75
	//f0 := "What are you doing at the end of the world? Are you busy? Will you save us?"
	// 34 + 75(f0) + 32 + 75(f0) + 2 = 68
	//f1 := "What are you doing while sending \"" + f0 + "\"? Are you busy? Will you send \"" + f0 + "\"?"
	//nLen := len(f0)
	//fmt.Println(nLen)
	//fmt.Println(f1)

	f[0] = 75
	// range ptr/ref
	for i := 1; i < 100001; i++ {
		f[i] = 34 + f[i-1] + 32 + f[i-1] + 2
	}

	var q int
	fmt.Scan(&q)
	for i := 0; i < q; i++ {
		var n int
		var k int64
		fmt.Scan(&n, &k)
		printChar(n, k)
	}
	fmt.Println()
}


package main

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

var f0 = "What are you doing at the end of the world? Are you busy? Will you save us?"
var a = "What are you doing while sending \""
var b = "\"? Are you busy? Will you send \""
var c = "\"?"

var cnt []int64

func recv(n, k int64) byte {
	if n == 0 {
		if k < int64(len(f0)) {
			return f0[k]
		}
		return '.'
	}
	if k < int64(len(a)) {
		return a[k]
	}
	k -= int64(len(a))

	if k < cnt[n-1] {
		return recv(n-1, k)
	}
	k -= int64(cnt[n-1])

	if k < int64(len(b)) {
		return b[k]
	}

	k -= int64(len(b))

	if k < cnt[n-1] {
		return recv(n-1, k)
	}
	k -= int64(cnt[n-1])

	if k < int64(len(c)) {
		return c[k]
	}
	return '.'

}

func main() {
	cnt = make([]int64, 100001)
	cnt[0] = int64(len(f0))
	for i := 1; i < len(cnt); i++ {
		cnt[i] = int64(len(a)) + cnt[i-1] + int64(len(b)) + cnt[i-1] + int64(len(c))
		if cnt[i] > 1e18 {
			cnt[i] = 1e18
		}
	}
	sc := NewScanner()
	q := sc.NextInt()
	for i := 0; i < q; i++ {
		a, b := sc.NextInt64(), sc.NextInt64()
		fmt.Println(recv(a, 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 (
    "fmt"
)

func main() {
    var k, n, s, p int
    fmt.Scanf("%d %d %d %d", &k, &n, &s, &p)
    fmt.Println((k * (n + s - 1) / s + p - 1) / p)
}


package main

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

func resolve() {
	var people, manAP, paperAP, sheets float64
	data := toFloat64(getRow(), &people, &manAP, &paperAP, &sheets)

	paperPerMan := math.Ceil(manAP / paperAP)
	sheetsNeeded := paperPerMan * people
	packs := math.Ceil(sheetsNeeded / sheets)

	pp(data)
	pp(paperPerMan, sheetsNeeded)
	fmt.Print(packs)
}

func pp(args... interface{}) {
	if false {
		fmt.Println(args...)
	}
}

var scanner *bufio.Scanner

func getRow(vars... *string) []string {
	if scanner == nil {
		scanner = bufio.NewScanner(os.Stdin)
	}

	scanner.Scan()
	data := strings.Split(scanner.Text(), " ")
	for k, _ := range vars {
		if len(data) > k {
			*vars[k] = data[k]
		}
	}
	return data
}

func toFloat64(s []string, vars... *float64) []float64 {
	sI := make([]float64, len(s))
	varsLen := len(vars)

	for k, i := range s {
		sI[k], _ = strconv.ParseFloat(i, 64)

		if varsLen > k {
			*vars[k] = sI[k]
		}
	}

	return sI
}

func main() {
	start := time.Now()
	resolve()
	pp(time.Since(start))
}


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 s2%p != 0 {
		ans++
	}
	println(ans)
}


package main

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

var (
	A = 1
	B = 3
	C = 2
	D = 0
)
func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	text := scanner.Text()
	num, _ := strconv.Atoi(text)
	switch num % 4 {
	case A:
		fmt.Println(0)
	case B:
		fmt.Println(2)
	case C:
		fmt.Println(1)
	case D:
		fmt.Println(1)
	default:
		fmt.Println(0)
	}
}


package main

import "fmt"

func main() {
	fmt.Println("enter text")
	var input int
	fmt.Scanln(&input)
	var remainder = input % 4
	if remainder == 0 {
		fmt.Print("1 A")
	} else if remainder == 1 {
		fmt.Print("0 A")
	} else if remainder == 2 {
		fmt.Print("1 B")
	} else if remainder == 3 {
		fmt.Print("2 A")
	}
}


package main

import "fmt"

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

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

func main(){
	var n int
	fmt.Scanln(&n)
	switch n%4{
	case 1:
		fmt.Println("0 A")
	case 2:
		fmt.Println("1 B")
	case 3:
		fmt.Println("0 B")
	case 0:
		fmt.Println("1 A")
	}
}


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

package main

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

type Solution struct {
	Moves    int
	Category string
}

func Solve(x int) Solution {
	category := map[int]string{
		1: "A",
		3: "B",
		2: "C",
		0: "D",
	}
	moves := 0
	bestMoves := 0
	bestCategory := category[x%4]
	for x+moves <= 100 {
		currentCategory := category[(x+moves)%4]
		if currentCategory < bestCategory {
			bestMoves = moves
			bestCategory = currentCategory
		}
		moves += 1
	}
	return Solution{Moves: bestMoves, Category: bestCategory}
}

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

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

	solution := Solve(x)
	fmt.Fprintf(writer, "%d %s\n", solution.Moves, solution.Category)
}


package main

import "fmt"

var mod int64 = 1000000007

func main() {
    var n, m, k int64
    fmt.Scan(&n)
    fmt.Scan(&m)
    fmt.Scan(&k)
    if k > n {
        fmt.Println(pow(m, n))
    } else if k == n {
        fmt.Println(pow(m, (n + 1) / 2))
    } else if k == 1 {
        fmt.Println(pow(m, n))
    } else if k % 2 == 0 {
        fmt.Println(m)
    } else if k % 1 == 0 {
        fmt.Println(pow(m, 2))
    }
    return
}

func pow(int64 a, int64 b) int64 {
    var ans int64 = 1
    for; b > 0; b-- {
        ans = ans * a % mod
    }
    return ans
}


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.Ceil(float64(mini) / float64(n)))
	maxi = maxi + k

	fmt.Println(mini, maxi)
}


package main

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

func main() {
	input := bufio.NewScanner(os.Stdin)
	hasInput := input.Scan()
	if hasInput == false {
		panic("Number of problems missing")
	}

	tmp := strings.Split(input.Text(), " ")
	numbers := []int{}

	for _, v := range tmp {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic("Something went wrong when processing first line")
		}

		numbers = append(numbers, n)
	}

	if len(numbers) != 2 {
		panic("It has to be exactly 2 numbers in first line!! ")
	}

	scores := []int{}

	for input.Scan() {
		s := strings.Split(input.Text(), " ")

		for _, v := range s {
			n, err := strconv.Atoi(v)

			if err != nil {
				panic("Something went wrong with number processing shutting down!! :<")
			}

			scores = append(scores, n)
		}
	}

	fmt.Println(noOfNextRoundParticipants(numbers[0], numbers[1], scores))

}

func noOfNextRoundParticipants(participantsNo, scoreNo int, scores []int) int {
	base := scores[scoreNo]

	nextParticipants := 0

	for _, v := range scores {
		if v == 0 || base > v {
			continue
		}

		nextParticipants++
	}

	return nextParticipants
}


package main

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

func covToIntSli(sli []string) []int {
	var res []int
	for _, v := range sli {
		i, _ := strconv.Atoi(v)
		res = append(res, i)
	}
	return res
}

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

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()

	scores := covToIntSli(strings.Split(scanner.Text(), " "))

	cnt := 0
	for i := 0; i < n; i++ {
		if scores[i] >= scores[k] && scores[i] > 0 {
			cnt++
		}
	}

	fmt.Println(cnt)
}


package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scanf("%d %d\n", &n, &m)
	var s int
	var scores []int
	for j := 0; j < n; j++ {
		fmt.Scanf("%d\n", &s)
		scores = append(scores, s)
	}
	num := 0
	m--
	t := scores[m]
	for j =0; j<len(scores); j++ {
		if v >= t {
			num++
		}

	}
	fmt.Println(num)
}


package main

import (
  "fmt"
)

func main(){
  var n, m int
  fmt.Scanf("%d\n", &n)
  var s int
  var scores []int
  for j := 0; j<n; j++ {
    fmt.Scanf("%d\n", &s)
    scores = append(scores, s)
  }
  num, t := 0 , scores[m-1]
  for _, v := range scores{
    if(v>=t){num++}

  }
  fmt.Println(num)
}


package main

import "fmt"

func main() {
	var n, k, s, result int
	fmt.Scanf("%d %d", &n, &k)
	scores := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d",&scores[i])
	}
	for _, v := range scores {
		if v < scores[k-1] || v < 0 {
			break
		}
		result++
	}
	fmt.Println(result)
}


package main

import (
	"fmt"
)

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

	var participants []int = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &participants[i])
	}

	var kthScore int = participants[k]

	var count int = 0

	for _, element := range participants {
		if element >= kthScore && (element != 0) {
			count++
		}
	}

	fmt.Println(count)
}


package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024 * 1024)
	var n, k int
	fmt.Sscanf(readLine(reader), "%d %d", &n, &k)
	out := strings.Split(readLine(reader), " ")
	ints := make([]int, len(out))

	for i, s := range out {
		ints[i], _ = strconv.Atoi(s)
	}
	res := 0
	for _, i := range ints {
		if i >= ints[k] && i > 0 {
			res += 1
		}
	}
	fmt.Println(res)
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

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


package main

import (
    "os"
    "bufio"
    "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 total_count, position int = ReadInt32(), ReadInt32()

    rating := []int{}
    for i:=0; i< total_count; i++ {
        rating = append(rating, ReadInt32())
    }

    if rating[position] <= 0 {
        position = 0
    } else {
        position -= 1
    }

    i:=0
    for position < total_count-1 && rating[position] == rating[position+1] && rating[position] > 0 {

        position += 1
        i += 1

    }

    if rating[0] > 0 { position += 1 }

    PrintInts(position);
}


package main

import (
	"fmt"
)

func main() {
	var n, k, summ int

	fmt.Scan(&n, &k)

	mass := make([]int, n)

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

	for i := 0; i < n; i++ {
		if mass[i] > 0 && mass[i] >= mass[k] {
			summ++
		}
	}

	fmt.Println(summ)

}


/*
   Next Round
   Tags : Implementation
   http://codeforces.com/problemset/problem/158/A
*/

package main

import "fmt"

func main() {
	var n, k, cant_passed int
	fmt.Scan(&n)
	fmt.Scan(&k)
	array := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&array[i])
	}
	for i := 0; i < n; i++ {
		if array[i] > 0 && array[i] >= array[k] {
			cant_passed++
		}
	}
	fmt.Println(cant_passed)
}


package main

import (
	"fmt"
)

func main() {
	var n, k, l, cnt, b int
	fmt.Scanln(&n, &k)
	//fmt.Scanln(&buf)
	buf := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&b)
		buf[i] = b
	}
	l = buf[k]
	for i := 0; i < n; i++ {
		if buf[i] < l || buf[i] == 0 {
			break
		}
		cnt += 1
	}
	fmt.Println(cnt)
}


package main

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

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

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

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

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

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

func solve(n uint64) {
	var k, o, ans uint64
	I(&k)
	for i := uint64(1); i <= n/2; i++ {
		if n%i == 0 {
			ans++
			if ans == k {
				o = i
				break
			}
		}
	}
	if ans != k {
		O(-1, "\n")
	} else {
		O(o, "\n")
	}
}


package main

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

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

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

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

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

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

func solve(n uint64) {
	var k, o, ans uint64
	I(&k)
	for i := uint64(1); i <= n/2; i++ {
		if n%i == 0 {
			ans++
			if ans == k {
				o = i
				break
			}
		}
	}
	if ans+1 == k {
		ans++
		o = n
	}
	if ans < k {
		O(-1, "\n")
	} else {
		O(o, "\n")
	}
}