package main

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

const (
	INF = 12345
)

func Init() {
}

func Solve(io *FastIO) {
	S := io.NextLine()

	A := []rune(S)
	N := len(A)

	best := INF
	for i := 0; i < N; i++ {
		for j := i + 1; j < N; j++ {
			if (A[i] == '0' && A[j] == '0') || (A[i] == '2' && A[j] == '5') || (A[i] == '5' && A[j] == '0') || (A[i] == '7' && A[j] == '5') {
				best = Min(best, simulate(A, i, j))
			}
			if (A[i] == '5' && A[j] == '2') || (A[i] == '0' && A[j] == '5') || (A[i] == '5' && A[j] == '7') {
				best = Min(best, simulate(A, i, j))
			}
		}
	}
	if best < INF {
		io.Println(best)
	} else {
		io.Println(-1)
	}
}

func simulate(A []rune, front, back int) int {
	N := len(A)

	X := make([]rune, N)
	copy(X, A)

	if back < front {
		front--
	}

	a := swapTo(X, back, N - 1)
	b := swapTo(X, front, N - 2)
	c := fix(X)

	return a + b + c
}

func swapTo(A []rune, i, j int) int {
	cnt := 0
	for i + 1 <= j {
		A[i], A[i + 1] = A[i + 1], A[i]
		cnt++
		i++
	}
	return cnt
}

func fix(A []rune) int {
	if A[0] != '0' {
		return 0
	}
	for i := 1; i < len(A) - 2; i++ {
		if A[i] != '0' {
			return i
		}
	}
	return INF
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


package main

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

func main() {

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

	str1, _ := in.ReadString('\n')
	str2, _ := in.ReadString('\n')

	str1 = strings.Replace(str1, "\n", "", -1)
	str2 = strings.Replace(str2, "\n", "", -1)

	hh1mm1 := strings.Split(str1, ":")
	hh2mm2 := strings.Split(str2, ":")

	hh1, _ := strconv.ParseInt(hh1mm1[0], 10, 64)
	mm1, _ := strconv.ParseInt(hh1mm1[1], 10, 64)

	hh2, _ := strconv.ParseInt(hh2mm2[0], 10, 64)
	mm2, _ := strconv.ParseInt(hh2mm2[1], 10, 64)

	if (hh1 == hh2) {
		fmt.Fprintf(out, "%v:%v\n", hh1,(mm2-mm1)/2)
	} else if (hh2 > hh1) {
		mins := 60 - mm1
		hh1New := hh1 + 1
		mins += (hh2 - hh1New) * 60
		mins += mm2
		mediana := mins / 2

		var hhres, mmres int64

		if ((mm1 + mediana) < 60) {
			fmt.Fprintf(out, "%02d:%02d\n", hh1, mm1 + mediana)
		} else {
			hhres = hh1
			mediana = (mediana - (60 - mm1))
			hhres += 1
			numHh := mediana / 60
			hhres += numHh
			mmres = mediana - numHh*60
			fmt.Fprintf(out, "%02d:%02d\n", hhres, mmres)
		}
	}
	out.Flush()
}


package main

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

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

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

func main() {
	defer out.Flush()
	var sh, sm, eh, em int
	Fscanf(in, "%d:%d\n", &sh, &sm)
	Fscanf(in, "%d:%d", &eh, &em)
	minute := (eh-sh)*60 + em - sm
	minute /= 2
	sh += minute / 60
	sm += minute % 60
	if sm >= 60 {
		sh++
		sm -= 60
	}
	Fprintf(out, "%d:%d", sh, sm)
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, m int
	var n1, m1 int
	fmt.Fscanf(reader, "%d:%d\n", &n, &m)
	fmt.Fscanf(reader, "%d:%d\n", &n1, &m1)

	var mn, h int
	if m1 < m {
		mn = 60 + m1 - m
		h--
	} else {
		mn = m1 - m
	}

	if n1 < n {
		n1 = 24 + n1
	}

	h += (n1-n)*60 + mn

	md := (h / 2) / 60
	mx := h/2 - md*60

	if n+md+1 < 10 {
		fmt.Print(0)
	}

	fmt.Println(mx, m)
	if mx+m >= 60 {
		defer fmt.Println(mx + m - 60)
		fmt.Print(n+md+1, ":")
		if mx+m-60 < 10 {
			fmt.Print(0)
		}
	} else {
		defer fmt.Println(mx + m)
		fmt.Print(n+md, ":")
		if mx+m < 10 {
			fmt.Print(0)
		}
	}
}


package main

import (
	"fmt"
	"strings"
)

func main() {
	var num string
	fmt.Scan(&num)

	for _, v := range []string{"144", "14", "1"} {
		num = strings.Replace(num, v, "", -1)
	}

	if len(num) > 0 {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    scanner.Scan()
    a := scanner.Text()
    a = strings.Replace(a,"144","",-1)
    a = strings.Replace(a,"14","",-1)
    a = strings.Replace(a,"1","",-1)
    if (a == "") {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


package main

import "fmt"

func main() {
	var line string
	fmt.Scanf("%s", &line)

	foursExpect := 2
	okay := true

	for i := 0; i < len(line); i++ {
		switch line[i] {
		case '1':
			foursExpect = 2
		case '4':
			foursExpect--
			if foursExpect < 0 {
				okay = false
			}
		default:
			okay = false
		}
	}

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


package main

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

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

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

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

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

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

func main() {
  sc.Split(bufio.ScanWords)
  sc.Scan()
  s := sc.Text()
  c := 0
  for i := 0; i < len(s); i++ {
    if s[i] == '1' {
      if c >= 3 {
        w.WriteString("NO\n")
        w.Flush()
        return
      } else {
        c = 0
      }
    } else if s[i] == '4' {
      c++
    } else {
      w.WriteString("NO\n")
      w.Flush()
      return
    }
  }
  if c >= 3 {
    w.WriteString("NO\n")
    w.Flush()
    return
  }
  w.WriteString("YES\n")
  w.Flush()
}


package main

import "fmt"

func main() {
	n:=0
	fmt.Scanf("%d",&n)
	switch n%4 {
	case 0:
		fmt.Println("0")
	case 1:
		fmt.Println("1")
	case 2:
		fmt.Println("2")
	case 3:
		fmt.Println("3")
	}
}


package main

import "fmt"

func main() {
	var h int, n int64
	fmt.Scanf("%d %d", &h, &n)
	n -= 1
	tn := int64(1)
	r := int64(0)
	for i := 0; i < h; i++ {
		tn *= 2
	}
	isLeft := true
	for i := 0; i < h; i++ {
		tn /= 2
		r += 1
		if tn&n > 0 {
			if isLeft {
				r += 2*tn - 1
			}
			isLeft = true
		} else {
			if !isLeft {
				r += 2*tn - 1
			}
			isLeft = false
		}
	}
	fmt.Println(r)
}


package main

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

func main() {
  var n int
  var encodeStr string

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

  var answer []string
  var counter int
  var prevDigit string = "-1"

  for i := 0; i < n; i++ {
    var currentDigit string = string(encodeStr[i])
    if currentDigit == "1" {
      counter++
      if i == n-1 {
        answer = append(answer, strconv.Itoa(counter))
      }
    } else if currentDigit == "0" && prevDigit == "0" {
      answer = append(answer, "0")
    } else if currentDigit == "0" && prevDigit != "0" {
      answer = append(answer, strconv.Itoa(counter))
      counter = 0
    }
    prevDigit = currentDigit
  }
  fmt.Println(strings.Join(answer, ""))
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	 reader.ReadString('\n')
	text, _ := reader.ReadString('\n')
	result := ""
	curNum := 0
	for _, value := range text{
		if value == 49 {
			curNum += 1
		} else if value == 48 {
			result += strconv.Itoa(curNum)
			curNum = 0
		}
	}

	if curNum != 0{
		result += strconv.Itoa(curNum)
	}

	  fmt.Println(result)
}


package main

import (
    "fmt"
    //"strings"
)

func main() {
    var n string = ""
    fmt.Scan(&n)
    for x:=0;x<len(n);x++{
        if !(n[x]=='4' || n[x]=='7') {
            fmt.Println("NO")
            return
        }
    }
    fmt.Println("YES")
}


package main

import "fmt"

func main() {
	var n, cnt, div, d, digit int64
	fmt.Scan(&n)
	cnt, div, d = 0, 1, 0
	for div < n {
		digit = (n/div)%10
		if digit == 4 || digit == 7 {
			cnt++
		}
		d++
		div *= 10
	}
	var result string
	if cnt == d {
		result = "YES"
	} else {
		result = "NO"
	}
	fmt.Print(result)
}


package main
import "fmt"
import "strconv"
func main() {
    var f int
    var a,b int
    var s string
    fmt.Scanf("%d", &b)
    a=0
    for _,c := range strconv.Itoa(b) {
        if ( c == '4' || c == '7' ){
            a++
		}
	}
    f = 0
    for _,c := range strconv.Itoa(a) {
        if ( c != '4' && c != '7' ){
		    f=1;
		    break;
		}
	}
	if f == 0{
	    fmt.Println("YES")
	} else {
	    fmt.Println("NO")
	}
}


package main

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

func main() {
	stdin := readStdIn()
	nums := convertToInts(stdin)

	w1 := nums[0]
	h1 := nums[1]
	w2 := nums[2]
	h2 := nums[3]

	sum := 0

	sum += w1 + 2
	for j := 1; j <= h2; j++ {
		sum += 2
	}

	sum += w1 - w2 + 2
	for i := 1; i <= h1; i++ {
		sum += w1 + 2
	}
	sum += w1 + 2
	fmt.Println(sum)
}

func readStdIn() string {
	r := bufio.NewReader(os.Stdin)
	text, err := r.ReadString('\n')
	if err != nil {
		panic(err)
	}
	return strings.TrimSpace(text)
}

func convertToInts(str string) []int {
	tokens := strings.Split(str, " ")
	nums := make([]int, 0, len(tokens))
	for _, t := range tokens {
		n, _ := strconv.Atoi(t)
		nums = append(nums, n)
	}
	return nums
}


package main

import "os"
import "fmt"

func main() {
	w1, h1, w2, h2 := os.Args[0], os.Args[1], os.Args[2], os.Args[3]
	fmt.Println(1 + w2 + 1 + h2 + h2 + h1 + h1 + w1 - w2 + 1 + w1 + 1)
}


package main

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

func strToInt(s string) uint64 {
	result, err := strconv.ParseUint(s, 10, 32)

	if err != nil {
		fmt.Printf("%s", err.Error())
		os.Exit(1)
	}

	return result
}

func main() {
	w1, h1, w2, h2 := strToInt(os.Args[1]), strToInt(os.Args[2]), strToInt(os.Args[3]), strToInt(os.Args[4])
	fmt.Println(1 + w2 + 1 + h2 + h2 + h1 + h1 + w1 - w2 + 1 + w1 + 1)
}


package main

import (
	"fmt"
)

func main() {
	var d1, d2, d3 int
	fmt.Scanf("%d %d %d", &d1, &d2, &d3)

	if d1*2+d2*2 < d1+d2+d3 {
		fmt.Println(d1*2 + d2*2)
	} else {
		fmt.Println(d1 + d2 + d3)
	}
}


package main;

import (
    "fmt"
)

func main() {
    var a, b, c int
    fmt.Scanf("%d%d%d", &a, &b, &c)
    x := 2 * a + 2 * b
    y := a + b + c
    if x < y {
        fmt.Println(x)
    } else {
        fmt.Println(y)
    }
}


package main

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

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

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


package main

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

func winpos(table [][]byte, sx, sy, dx, dy int) bool {
	x, y := sx, sy
	i := 0
	for i < 5 {
	    if  x>=10 || y>=10 {
	        return false
	    }

		if table[x][y]!='X' {
			return false
		}

		x += dx
		y += dy

		i++
	}

	return true
}

func win(table [][]byte) bool {
	for i := 0; i < 10; i++ {
		for j := 0;j < 10; j++ {
			if winpos(table, i, j, 0, 1) || winpos(table, i, j, 1, 0) || winpos(table, i, j, 1, 1) {
				return true
			}
		}
	}

	return false
}

func main() {
    stdin := bufio.NewReader(os.Stdin)
	table := make([][]byte,  10)
	for i := 0; i < 10; i++ {
		table[i], _, _ = stdin.ReadLine()

	}

	for i := 0; i < 10; i++ {
		for j := 0;j < 10; j++ {
			if table[i][j]=='.' {
				table[i][j]='X'
				if win(table) {
					fmt.Println("YES")
					os.Exit(0)
				}

				table[i][j]='.'
			}
		}
	}

	fmt.Println("NO")
	os.Exit(0)
}


package main

import (
	"fmt"
	"sort"
)

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


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 intersect(l1 int, r1 int, l2 int, r2 int) bool {
    if l1 > r1 {
        l1, r1 = r1, l1
    }
    if l2 > r2 {
        l2, r2 = r2, l2
    }
    return l1 < l2  && l2 < r1 && r1 < r2 || l2 < l1 && l1 < r2 && r2 < r1
}

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    a := make([]int, n)
    for i := 0; i < n; i++ {
        a[i] = nextInt()
    }

    for i := 0; i < n - 1; i++ {
        for j := i + 1; j < n - 1; j++ {
            if intersect(a[i], a[i + 1], a[j], a[j + 1]) {
                fmt.Fprintln(out, "yes")
                return
            }
        }
    }
    fmt.Fprintln(out, "no")
}


package main

import (
	"fmt"
)

type Vertex struct {
	neighbors []*Vertex
}

func main() {
	var n, m int
	fmt.Scanf("%d %d", &n, &m)
	g1 := make([][]*Vertex, n)
	g2 := make([][]*Vertex, n)
	for i := range g1 {
		g1[i] = make([]*Vertex, m)
		g2[i] = make([]*Vertex, m)
		for j := range g1[i] {
			g1[i][j] = &Vertex{neighbors: make([]*Vertex, 2)}
			g2[i][j] = &Vertex{neighbors: make([]*Vertex, 2)}
		}
	}

	var horizon, vertical string
	fmt.Scanf("%s %s", &horizon, &vertical)
	for i, c := range horizon {
		if c == '>' {
			for j := 0; j < m-1; j++ {
				g1[i][j].neighbors[0] = g1[i][j+1]
			}
			for j := 1; j < m; j++ {
				g2[i][j].neighbors[0] = g2[i][j-1]
			}
		} else {
			for j := 1; j < m; j++ {
				g1[i][j].neighbors[0] = g1[i][j-1]
			}
			for j := 0; j < m-1; j++ {
				g2[i][j].neighbors[0] = g2[i][j+1]
			}
		}
	}
	for j, c := range vertical {
		if c == 'v' {
			for i := 0; i < n-1; i++ {
				g1[i][j].neighbors[1] = g1[i+1][j]
			}
			for i := 1; i < n; i++ {
				g2[i][j].neighbors[1] = g2[i-1][j]
			}
		} else {
			for i := 1; i < n; i++ {
				g1[i][j].neighbors[1] = g1[i-1][j]
			}
			for i := 0; i < n-1; i++ {
				g2[i][j].neighbors[1] = g2[i+1][j]
			}

		}
	}
	if dfs(g1) && dfs(g2) {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

func dfs(g [][]*Vertex) bool {
	visited := make(map[*Vertex]struct{})
	v := g[0][0]
	dfsRecurse(v, visited)
	return len(visited) == len(g) * len(g[0])

}

func dfsRecurse(v *Vertex, visited map[*Vertex]struct{}) {
	visited[v] = struct{}{}
	for _, n := range v.neighbors {
		if n == nil {
			continue
		}
		if _, ok := visited[n]; !ok {
			dfsRecurse(n, visited)
		}
	}
}


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(x int) (res int)  {
	scanner.Scan()

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

type building struct
{
	a , b ,c int
}

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

func main()  {
	var n int
	fmt.Scan(&n)
	var s string
	fmt.Scan(&s)
	var ans int
	for index,_ := range s{
		if(string(s[index]) == "+"){
			ans ++
		}else{
				ans --;
		}

	}
	fmt.Print(max(ans,0))

}


package main

import "fmt"

func main() {
	var n int32
	var str string
	fmt.Scanf("%d\n",&n)
	fmt.Scanf("%s\n",&str)
	fmt.Println(n)
	fmt.Println(str)
	ans:=0
	for _,c:=range str{
		if c=='+'{
			ans++
		}else if c=='-'{
			if ans>0{
				ans--
			}
		}
	}
	fmt.Println(ans)
}


```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 d int
	scanf("%d\n", &d)
	var s string
	scanf("%s\n", &s)
	sa := []byte(s)
	cur := 0
	for _, c := range sa {
		if c == '-' {
			cur--
		} else {
			cur++
		}
		if cur < 0 {
			cur = 0
		}
	}

	printf("%d", cur)
}


package main

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

func readline(reader *bufio.Reader) string {
	str, _ := reader.ReadString('\n')
	return strings.TrimSuffix(str, "\n")
}

func readInt(reader *bufio.Reader) int {
	str := readline(reader)
	n, _ := strconv.Atoi(str)
	return n
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	n := readInt(reader)
	pattern := readline(reader)

	ct := 0
	minSeen := 0
	for i := 0; i < n; i++ {
		if pattern[i] == '+' {
			ct++
		} else if pattern[i] == '-' {
			ct--
		}
		if ct < minSeen {
			minSeen = ct
		}
	}
	fmt.Println(ct, minSeen)
	fmt.Println(ct - minSeen)
}


package main

import (
	"bufio"
	"os"
)

func main() {
	ss := bufio.NewScanner(os.Stdin)
	ss.Scan()
	s := ss.Text()
	n := len(s)
	count:=0

	for i:=0; i< n-2; i++  {
		if s[i] != 'Q' { continue }
		for j:= i+1;  j< n-1; j++  {
			if s[j] != 'A' { continue }
			for k:=j+1; k< n; k++  {
				if s[k] != 'Q' { continue }
				count++
			}

		}

	}
	println(count)
}


// cf894a project main.go
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scanf("%s", &s)
	flag := true
	i := 0
	for _, c := range s {
		if c == 'Q' {
			if !flag {
				i++
			}
			flag = true
		} else if c == 'A' {
			flag = false
		}
	}
	fmt.Printf("%d\n", i*i)
}


package main

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

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

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

// Helpers

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

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

// Math

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

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

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

// IO

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

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

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

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

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

// Sort

type Ints64 []int64

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

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


package main

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

type move struct {
	x  int
	y  int
	dx int
	dy int
	w  int
}

const W = 5000 * 1000
const H = 5*30*2 + 10
const Z = H / 2

var used [H][H][3][3]bool
var wave [H][H][3][3]int
var t [31]int
var n int

var q [W]move
var hd, tl int

func push(m move) {
	q[tl] = m
	if tl == W-1 {
		tl = 0
	} else {
		tl += 1
	}
}

func pop() move {
	ret := q[hd]
	if hd == W-1 {
		hd = 0
	} else {
		hd += 1
	}
	return ret
}

func empty() bool {
	return hd == tl
}

var ndx [3][3]int
var ndy [3][3]int
var ndxx [3][3]int
var ndyy [3][3]int

func do() {
	m := pop()

	tt := t[m.w]
	lx := m.x + (tt-1)*m.dx
	ly := m.y + (tt-1)*m.dy

	//fmt.Printf("%d lines from (%d, %d) with dir (%d, %d)\n", tt, m.x-Z, m.y-Z, m.dx, m.dy)

	for i := 0; i < tt; i++ {
		used[m.x+i*m.dx][m.y+i*m.dy][1+m.dx][1+m.dy] = true
	}
	wave[m.x][m.y][1+m.dx][1+m.dy] = m.w

	if m.w+1 < n {
		ndx1 := ndx[1+m.dx][1+m.dy]
		ndy1 := ndy[1+m.dx][1+m.dy]
		x1 := lx + ndx1
		y1 := ly + ndy1
		if wave[x1][y1][1+ndx1][1+ndy1] < m.w+1 {
			push(move{x1, y1, ndx1, ndy1, m.w + 1})
		}

		ndx2 := ndxx[1+m.dx][1+m.dy]
		ndy2 := ndyy[1+m.dx][1+m.dy]
		x2 := lx + ndx2
		y2 := ly + ndy2
		if wave[x2][y2][1+ndx2][1+ndy2] < m.w+1 {
			push(move{x2, y2, ndx2, ndy2, m.w + 1})
		}
	}
}

func main() {

	ndy = [3][3]int{
		{0, 1, 1},
		{-1, 0, 1},
		{-1, -1, 0},
	}

	ndx = [3][3]int{
		{-1, -1, 0},
		{-1, 0, 1},
		{0, 1, 1},
	}

	ndyy = [3][3]int{
		{-1, -1, 0},
		{-1, 0, 1},
		{0, 1, 1},
	}

	ndxx = [3][3]int{
		{0, -1, -1},
		{1, 0, -1},
		{1, 1, 0},
	}

	in := bufio.NewReader(os.Stdin)

	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(in, "%d", &t[i])
	}

	for x := 0; x < H; x++ {
		for y := 0; y < H; y++ {
			for i := 0; i < 3; i++ {
				for j := 0; j < 3; j++ {
					wave[x][y][i][j] = -1
					used[x][y][i][j] = false
				}
			}
		}
	}

	push(move{Z, Z, 0, 1, 0})

	for !empty() {
		do()
	}

	ret := 0
	for x := 0; x < H; x++ {
		for y := 0; y < H; y++ {
			fg := false
			for i := 0; i < 3; i++ {
				if fg {
					break
				}
				for j := 0; j < 3; j++ {
					if used[x][y][i][j] {
						fg = true
						break
					}
				}
			}
			if fg {
				ret += 1
			}
		}
	}
	fmt.Println(ret)
}


package main

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

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

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


package main

import (
	"fmt"
	"math"
)

func main() {
	var n, k int
	var types []int

	fmt.Scan(&n, &k)
	for i := 0; i < n; i++ {
		var t int
		fmt.Scan(&t)
		types = append(types, t)
	}

	maxDiff := 0
	for i := 0; i < k; i++ {
		countTest := 0
		countSocialNetwork := 0
		for j := 0; j < n; j++ {
			if (j-i)%k != 0 {
				if types[j] == 1 {
					countTest++
				} else {
					countSocialNetwork++
				}
			}
		}
		diff := int(math.Abs(float64(countSocialNetwork - countTest)))
		fmt.Println(i)
		fmt.Println(diff)
		if maxDiff < diff {
			maxDiff = diff
		}
	}
	fmt.Println(maxDiff)
}


package main

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

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

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

	s, t := next(), next()

	if len(s) < len(t) {
		println("need tree")
		return
	}

	if strings.Contains(s, t) {
		println("automaton")
		return
	}

	chars := countChars(s)
	chart := countChars(t)

	if len(chars) < len(chart) {
		println("need tree")
		return
	}

	for k := range chart {
		_, ok := chars[k]

		if !ok || chars[k] < chart[k] {
			println("need tree")
			return
		}
	}

	if len(s) == len(t) {
		println("array")
	} else {
		println("both")
	}
}

func countChars(s string) map[uint8]int {
	chars := make(map[uint8]int)

	for i := range s {
		_, ok := chars[s[i]]

		if ok {
			chars[s[i]]++
		} else {
			chars[s[i]] = 1
		}
	}

	return chars
}

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

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

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

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

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

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


package main

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

type sortRunes []rune

func (s sortRunes) Less(i, j int) bool {
	return s[i] < s[j]
}

func (s sortRunes) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

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

func need_array(input1 string, input2 string) bool {
	if len(input1) != len(input2) {
		return false
	}

	input1Bytes := []rune(input1)
	input2Bytes := []rune(input2)

	sort.Sort(sortRunes(input1Bytes))
	sort.Sort(sortRunes(input2Bytes))

	for i := 0; i < len(input1Bytes); i++ {
		if input1Bytes[i] != input2Bytes[i] {
			return false
		}
	}

	return true
}

func need_both(input1 string, input2 string) bool {
	input1Bytes := []rune(input1)
	input2Bytes := []rune(input2)

	sort.Sort(sortRunes(input1Bytes))
	sort.Sort(sortRunes(input2Bytes))

	if len(input2Bytes) > len(input1Bytes) {
		return false
	}

	i, j := 0, 0

	for {
		if i >= len(input2Bytes) || j >= len(input1Bytes) {
			break
		}

		if input2Bytes[i] == input1Bytes[j] {
			i++
			j++
		} else if input2Bytes[i] > input1Bytes[j] {
			j++
		} else {
			break
		}
	}

	if i == len(input2Bytes) {
		return true
	} else {
		return false
	}
}

func main() {
	var word1, word2 string
	scanner := bufio.NewScanner(os.Stdin)

	if scanner.Scan() {
		word1 = scanner.Text()
	}

	if scanner.Scan() {
		word2 = scanner.Text()
	}

	if need_array(word1, word2) {
		fmt.Println("array")
	} else if strings.Contains(word1, word2) {
		fmt.Println("automaton")
	} else if need_both(word1, word2) {
		fmt.Println("both")
	} else {
		fmt.Println("need tree")
	}
}


package main

import (
	"fmt"
)

func solve(s, t string) string {
	// atomaton
	first := 0
	find := true
	for i := 0; i < len(t); i++ {
		for ; first < len(s); first++ {
			if s[first] == t[i] {
				break
			}
		}
		if first == len(s) {
			find = false
			break
		}
	}

	if find == true {
		return "automaton"
	}

	// counts
	count_s := make([]int, 26, 26)
	count_t := make([]int, 26, 26)
	for i := 0; i < len(s); i++ {
		count_s[s[i]-'a']++
	}
	for i := 0; i < len(t); i++ {
		count_t[t[i]-'a']++
	}

	// array
	array := true
	for i := 0; i < 26; i++ {
		if count_t[i] != count_s[i] {
			array = false
			break
		}
	}
	if array {
		return "array"
	}

	// both
	both := true
	for i := 0; i < 26; i++ {
		if count_t[i] > count_s[i] {
			both = false
			break
		}
	}
	if both {
		return "both"
	}

	return "need tree"
}

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

	fmt.Println(solve(s, t))
}


package main

import (
	"fmt"
)

func solve(s, t string) string {
	// atomaton
	first := 0
	second := 0

	for ; first < len(s); first++ {
		if s[first] == t[second] {
			second++
		}
	}

	if second == len(t) && first <= len(s) {
		return "automaton"
	}

	// counts
	count_s := make([]int, 26, 26)
	count_t := make([]int, 26, 26)
	for i := 0; i < len(s); i++ {
		count_s[s[i]-'a']++
	}
	for i := 0; i < len(t); i++ {
		count_t[t[i]-'a']++
	}

	// array
	array := true
	for i := 0; i < 26; i++ {
		if count_t[i] != count_s[i] {
			array = false
			break
		}
	}
	if array {
		return "array"
	}

	// both
	both := true
	for i := 0; i < 26; i++ {
		if count_t[i] > count_s[i] {
			both = false
			break
		}
	}
	if both {
		return "both"
	}

	return "need tree"
}

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

	fmt.Println(solve(s, t))
}


package main;

import "fmt"

func main() {
	var n,d int
	fmt.Scan(&n, &d)
	t := make([]int, n)
	time := 0
	for i := range n {
		fmt.Scan(&t[i])
		time += t[i]
		if i!= 0 {
			time += 10
		}
	}
	if time >= d {
		fmt.Println(-1)
	}
	else{
		fmt.Println((d-time)/5)
	}
}


package main

import (
	"fmt"
)

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

	var ti int
	fmt.Scan(&ti)

	ans := 0
	sum := ti
	for i := 1; i < n; i++ {
		fmt.Scan(&ti)
		sum += (10 + ti)

		if sum > d {
			ans = -1
			break
		}
		ans += 2
	}
	if ans > -1 {
		ans += ((d - sum) / 5)
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
	"os"
	)

const INF = 0x3f3f3f3f

var n, m, tot int

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

func main() {
	// fd, _ := os.Open("in.txt")
	// os.Stdin = fd
	var T int = 1
	// fmt.Scanf("%d", &T)
	for ci:=1; ci<=T; ci++ {
		fmt.Scanf("%d %d", &n, &m)
		// fmt.Printf("Case #%d: ", ci)
		var ans int = 0
		for i:=1; i<=n; i++ {
			var x int
			fmt.Scanf("%d", &x)
			if m%x==0 {
				ans = m/x
			}
		}
		fmt.Printf("%d\n", ans)
	}
}


package main

import (
	"fmt"
	// "os"
	)

const INF = 0x3f3f3f3f

var n, m, tot int

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

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

func main() {
	// fd, _ := os.Open("in.txt")
	// os.Stdin = fd
	var T int = 1
	// fmt.Scanf("%d", &T)
	for ci:=1; ci<=T; ci++ {
		fmt.Scanf("%d %d\n", &n, &m)
		// fmt.Printf("Case #%d: ", ci)
		var ans int = 0
		for i:=1; i<=n; i++ {
			var x int
			fmt.Scanf("%d", &x)
			if m%x==0 {
				ans = max(ans, m/x)
			}
		}
		fmt.Printf("%d\n", ans)
	}
}


package main

import (
	"os"
	"strconv"
)

func main() {
	//n, _ := strconv.ParseInt(os.Args[0], 2, 32)
	k, _ := strconv.Atoi(os.Args[2])

	sol := 0

	for i := 3; i < len(os.Args); i++ {
		d, _ := strconv.Atoi(os.Args[i])
		if k%d == 0 && sol < d {
			sol = d
		}
	}

	println(k / sol)
}


package main

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

func main() {
	var n, k int
	input := bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &n, &k)
	ans := 12345678
	for i := 0; i < n; i++ {
		var val int
		// fmt.Fscan(input, &val)
		fmt.Scanf("%d", &val)
		if k%val == 0 {
			if ans > k/val {
				ans = k / val
			}
		}
	}
	fmt.Println(ans)
}


package main

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

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

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

	s := next()
	t := "CODEFORCES"
	idx := 0
	r, l := "", ""

	for i := 0; i < len(t); i++ {
		r, l = t[:i], t[i:]

		idx = strings.Index(s, r)

		if idx >= 0 && strings.Index(s[idx+1:], l) >= 0 {
			println("YES")
			return
		}
	}

	println("NO")
}

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

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

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

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

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

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

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

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


package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	size := len(s)
	extra := size - len("CODEFORCES")
	for i := 0; i < size-extra; i++ {
		x := s[:i] + s[i+extra:]
		if x == "CODEFORCES" {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	size := len(s)
	extra := size - len("CODEFORCES")
	if extra < 0 {
		fmt.Println("NO")
		return
	}
	for i := 0; i < size-extra; i++ {
		x := s[:i] + s[i+extra:]
		if x == "CODEFORCES" {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


package main

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

func sortAsc(numbers string) (result string) {
	splitResult := strings.Split(numbers, "+")
	if len(splitResult) <= 1 {
		result = numbers
		return
	}

	var index int
	var isSwap bool
	for {
		if splitResult[index] > splitResult[index+1] {
			temp := splitResult[index]
			splitResult[index] = splitResult[index+1]
			splitResult[index+1] = temp
			isSwap = true
		} else {
			isSwap = false
		}

		index++
		if index == len(splitResult)-1 {
			index = 0
			if !isSwap {
				break
			}
		}
	}

	var sb strings.Builder
	for i, number := range splitResult {
		sb.WriteString(number)
		if i < len(splitResult)-1 {
			sb.WriteString("+")
		}
	}

	return sb.String()
}

func main() {

	// var firstWord, secondWord string
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		if err := scanner.Err(); err != nil {
			panic(err)
		}

		fmt.Println(sortAsc(scanner.Text()))

		// if firstWord == "" {
		// 	firstWord = scanner.Text()
		// 	continue
		// }

		// if secondWord == "" {
		// 	secondWord = scanner.Text()
		// 	fmt.Println(compareString(firstWord, secondWord))
		// 	firstWord, secondWord = "", ""
		// }
	}
}


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


package main

import (
	"fmt"
)

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

func main() {
	var a, b, c, d int

	fmt.Scan(&a, &b, &c, &d)

	m := max(3*a/10, a/250*c)
	v := max(3*b/10, b/250*d)

	var res string

	if m > v {
		res = "Misha"
	} else if m < v {
		res = "Vasya"
	} else {
		res = "Tie"
	}

	fmt.Println(res)
}


package main

import (
	"fmt"
)

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

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

	misha := max(3*a/10, a/250*c)
	vasya := max(3*b/10, b/250*d)

	if misha > vasya {
		fmt.Println("Misha")
	} else if misha < vasya {
		fmt.Println("Vasya")
	} else {
		fmt.Println("Tie")
	}
}


package main

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

const (
	BIG = 1024 * 1024 * 10
)

func readLine(r *bufio.Reader) string {
	bytes, _, err := r.ReadLine()
	if err != nil {
		log.Fatalln("Failed to read line")
	}

	return string(bytes)
}

func readInts(r *bufio.Reader) []int {
	elems := strings.Fields(readLine(r))

	ret := make([]int, len(elems))
	for i, el := range elems {
		tmp, err := strconv.ParseInt(el, 10, 64)
		if err != nil {
			log.Fatalf("Failed to parse number %v", el)
		}
		ret[i] = int(tmp)
	}

	return ret
}

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

func combination(a, b int64) int64 {
	b = min(b, a-b)
	nom, denom := int64(1), int64(1)
	for b > 0 {
		nom *= a
		denom *= b
		a -= 1
		b -= 1
	}

	return nom / denom
}

func pow(a, b int64) int64 {
	ret := int64(1)
	for b > 0 {
		ret *= a
		b -= 1
	}

	return ret
}

func main() {
	r := bufio.NewReaderSize(os.Stdin, BIG)

	n := readInts(r)[0]

	res := int64(4*(n-1)) * pow(int64(3), int64(n-2))

	fmt.Println(res)
}


package main
import "fmt"

func main() {
	sdeck := make([]string, 8)
	for i := 0; i < 8; i++{
		fmt.Scan(&sdeck[i])
	}
	var deck [8][8]int
	count := 0
	for i, s := range sdeck{
		for j, c := range s{
			if c == 'B'{
				deck[i][j] = 1
			}else{
				deck[i][j] = 0
			}
		}
	}
	for i := 0; i < 8; i++{
		sum := 0
		for j := 0; j < 8; j++ {
			if deck[i][j] == 1{
				sum++
			}
		}
		if sum == 8 {
			count++
		}
	}
	for i := 0; i < 8; i++{
		sum := 0
		for j := 0; j < 8; j++ {
			if deck[j][i] == 1{
				sum++
			}
		}
		if sum == 8 {
			count++
		}
	}
	fmt.Print(count)
}


package main

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

func main() {
	z := bufio.NewScanner(os.Stdin)
	var col [8]int
	var count int
	for i := 0; i < 8 ; i++ {
		z.Scan()
		s := z.Text()
		row := 0
		for j := 0; j < 8 ; j++  {
			if s[i] == 'B' {
				row++
				col[j]++
			}
			if row == 8 {
				count++
			}

		}
	}
	for i := 0 ; i < 8 ; i++ {
		if col[i] == 8 {
			count++
		}
	}
	if count == 16 {count = 8}
	fmt.Println(count)
}


package main

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

type caseInput struct {
	num int
}

func readCaseInput(scanner *bufio.Scanner) caseInput {
	return caseInput{readInt(scanner)}
}

type caseOutput struct {
	ops int
}

func writeCaseOutput(writer *bufio.Writer, out caseOutput) {
	writef(writer, "%d\n", out.ops)
}

func solveCase(in caseInput) caseOutput {
	numStr := fmt.Sprintf("%d", in.num)
	root := int(math.Floor(math.Sqrt(float64(in.num))))
	for root > 0 {
		squareStr := fmt.Sprintf("%d", root*root)
		if len(lcs(numStr, squareStr)) == len(squareStr) {
			return caseOutput{len(numStr) - len(squareStr)}
		}
	}
	return caseOutput{-1}
}

//	that's from rozetta code and seems to work
func lcs(a, b string) string {
	arunes := []rune(a)
	brunes := []rune(b)
	aLen := len(arunes)
	bLen := len(brunes)
	lengths := make([][]int, aLen+1)
	for i := 0; i <= aLen; i++ {
		lengths[i] = make([]int, bLen+1)
	}
	// row 0 and column 0 are initialized to 0 already

	for i := 0; i < aLen; i++ {
		for j := 0; j < bLen; j++ {
			if arunes[i] == brunes[j] {
				lengths[i+1][j+1] = lengths[i][j] + 1
			} else if lengths[i+1][j] > lengths[i][j+1] {
				lengths[i+1][j+1] = lengths[i+1][j]
			} else {
				lengths[i+1][j+1] = lengths[i][j+1]
			}
		}
	}

	// read the substring out from the matrix
	s := make([]rune, 0, lengths[aLen][bLen])
	for x, y := aLen, bLen; x != 0 && y != 0; {
		if lengths[x][y] == lengths[x-1][y] {
			x--
		} else if lengths[x][y] == lengths[x][y-1] {
			y--
		} else {
			s = append(s, arunes[x-1])
			x--
			y--
		}
	}
	// reverse string
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return string(s)
}

func solveSequential(scanner *bufio.Scanner, writer *bufio.Writer) {
	writeCaseOutput(writer, solveCase(readCaseInput(scanner)))
}

func main() {
	var scanner *bufio.Scanner
	if len(os.Args) > 1 {
		reader, err := os.Open(os.Args[1])
		if err != nil {
			panic(err)
		}
		defer reader.Close()
		scanner = bufio.NewScanner(reader)
	} else {
		scanner = bufio.NewScanner(os.Stdin)
	}
	scanner.Split(bufio.ScanWords)

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

	solveSequential(scanner, writer)
}

func readInt64(sc *bufio.Scanner) int64 {
	sc.Scan()
	res, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return res
}

func readInt(sc *bufio.Scanner) int {
	return int(readInt64(sc))
}

func writef(writer *bufio.Writer, formatStr string, values ...interface{}) {
	out := fmt.Sprintf(formatStr, values...)
	_, err := writer.WriteString(out)
	if err != nil {
		panic(err)
	}
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	a := make([]int, n)
	readN(a, 0, n)
	out := make(map[int]bool, n)
	for v := range a {
		out[v] = true
	}
	var count int
	for k := range out {
		if k != 0 {
			count++
		}
	}
	fmt.Println(count)
}

func readN(all []int, i, n int) {
	if n == 0 {
		return
	}
	if m, err := fmt.Scan(&all[i]); m != 1 {
		panic(err)
	}
	readN(all, i+1, n-1)
}


package main

import (
	"fmt"
)

func main() {
	a, b, r := 0, 0, 0
	fmt.Scanf("%d %d %d\n", &a, &b, &r)
	winner := "Second"
	var xDiameter float32
	if a > b {
		xDiameter = float32(a) / float32(r*2)
	} else {
		xDiameter = float32(b) / float32(r*2)
	}
	if xDiameter >= 1 && int32((xDiameter-1)/1.5)%2 == 0 {
		winner = "First"
	}
	fmt.Printf("%s\n", winner)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	var n uint64
	var c int64
	fmt.Fscanf(in, "%d\n", &n)
	for i:=1; uint32(i) <= n; i++{
		if i % 2 != 0{
			c -= int32(i);
		}else{
			c += int32(i);
		}
	}
	fmt.Println(c)
}


package main

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

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


package main

import (
	"fmt"
)

func main() {
	var n, r, i int64 = 0, 0, 1
	fmt.Scan(&n)

	for ; i <= n; i++ {
		if i%2 == 0 {
			r += i
		} else {
			r -= i
		}
	}
	fmt.Print(r)
}


package main

import "fmt"

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

    p := 1
    if n % 2 == 1 {
        p = -1
    }

    fmt.Println(((n + 1) / 2) * p)
}


package main

import (
	"fmt"
	"os"
)

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

func main() {
	Problem486A()
}

func Problem486A() {
	var n int
	scanf("%d\n", &n)
	rs := processProblem486A(n)
	printf("%d", rs)

}

func processProblem486A(n int) int {
	var even, odd int
	for i := 1 ; i <= n ; i++ {
		if i % 2 > 0 {
			odd += i
		}else {
			even += i
		}
	}
	return even + ( odd - ( odd * 2))
}

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

func scanf(format string, x ...interface{}) {
	if _, err := fmt.Fscanf(os.Stdin, format, x...); err != nil {
		panic(err)
	}
}


package main

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

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

func main() {
	rs := Problem486A()
	printf("%d", rs)
}

func Problem486A() int {
	var n int
	scanf("%d\n", &n)
	if n % 2 > 0 {
		return (( n + 1 ) / 2 ) - ( ( ( n + 1 ) / 2 ) * 2 )
	}else {
		return n / 2
	}
}

func printf(format string, x ...interface{}) {
	fmt.Fprintf(os.Stdout, format, x...)
}

func scanf(format string, x ...interface{}) {
	if _, err := fmt.Fscanf(os.Stdin, format, x...); err != nil {
		panic(err)
	}
}


package main

import "fmt"

func main() {
	var n,i,r int64
	_, _ = fmt.Scanf("%d\n", &n)

	for i = 1; i <= n; i++ {
		if i&1 == 1 {
			r += -i
			continue
		}
		r += i
	}
	fmt.Println(r)
}


package main

import "fmt"

func main() {
    var x,y int
    dx := [4]int{1,0,-1,0}
    dy := [4]int{0,1,0,-1}
    abs := func(a int) int { if a < 0 { return -a } else { return a } }
    fmt.Scan(&x,&y)
    curx, cury, ans, in := 0, 0, 0, 0
    for (curx != x) || (cury != y) {
        if ((in == 0) && (curx-cury == 1)) || ((in > 0) && (abs(curx) == abs(cury))) {
            in = (in+1)%4
            ans++
        }
        curx += dx[in]
        cury += dy[in]
    }
    fmt.Println(ans)
}


package main

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

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

	tc := readNum(reader)
	for tc > 0 {
		tc--
		n := readNum(reader)
		a, b := solve(n)
		fmt.Printf("%d %d\n", a, b)
	}
}

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

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

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

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

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

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

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

	return i
}

func solve(n int) (int, int) {
	if n%2 == 0 {
		return n / 2, n / 2
	}
	N := int64(n)
	best := n - 1
	// n is odd
	for a := 3; int64(a)*int64(a) <= N; a += 2 {
		if n%a == 0 {
			b := n - a
			if b%a == 0 {
				best = min(best, b)
			}
		}
	}

	return n - best, best
}

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


package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)
var input *bufio.Reader

func main() {
	var T int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input = bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &T)
	for i := 0; i < T; i++ {
		solver()
	}
}

func solver() {
    var n int
	fmt.Fscan(input, &n)
    b := int(1e9)
    for i := n / 2; true; i-- {
        if (n - i) % i == 0 {
            b = min(b, n - i)
            break
        }
    }
	fmt.Println(n - b, b)
}

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


package main

import (
	"fmt"
)

func main() {
	var n int
	var done bool
	_, _ = fmt.Scanf("%d", &n)

	for p := 2; p * p <= n && !done; p++ {
		if n % p == 0 {
			k := n / p
			fmt.Println(k, n - k)
			done = true
		}
	}

	if !done {
		fmt.Println(1, n - 1)
	}
}


package main

import (
	"fmt"
)

func main() {
	var t int
	fmt.Scan(&t)
	for c:=0; c<t; c++{
		var n int
		fmt.Scan(&n)
		var p int
		for i:=2;i<=100000;i++{
			if n%i==0{
				p=i
				break
			}
		}
		if p==0{
			p=n
		}
		fmt.Printf("%v %v", (n/p), (n-n/p))
	}
}


package "main"

import "fmt"

func main() {
    var n,k int
    fmt.Scanf("%d%d", &n, &k)
    for i := 1; i <= n; i++ {
        if 5 * i * (i + 1) / 2 + k > 240 {
            fmt.Println(i - 1)
            return
        }
    }
    fmt.Println(n)
}


package main

import "fmt"

func main() {
	var n,k int
	fmt.Scanf("%d%d",&n,&k)
	remain := 240 - k
	sum := 0
	var i int = 0
	for var i int = 1;i<=n&&sum<=remain;i++{
		sum += 5*i
		if sum<=remain{
			ans = i
		}
	}
	fmt.Println(ans)
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	cnt := 0
	for i:=2; i<=n; i++ {
		if (n%i==0) {
			cnt++
		};
	}
	print(cnt);
}


package main

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

func Employee(number int) int {
	var array []int
	for i:=1;i<=number/2;i++ {
		if number % i == 0 {
			array = append(array,i)
		}
	}
	fmt.Println(array)
	return len(array)
}

func main() {
	var number int
	var err error
	for {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text =  strings.TrimRight(text,"\r\n")
	number,err = strconv.Atoi(text)
	if err == nil {
		if number > 2 && number <  int(math.Pow(10,5)) {
			break
		} else {
			fmt.Println("Enter number > 2 and < 10^5")
		}
		fmt.Println(err)
	}
	}
	fmt.Println(Employee(number))
}


package main

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

func Employee(number int) int {
	var array []int
	for i:=1;i<=number/2;i++ {
		if number % i == 0 {
			array = append(array,i)
		}
	}
	fmt.Println(array)
	return len(array)
}

func main() {
	var number int
	var err error
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	text =  strings.TrimRight(text,"\r\n")
	number,err = strconv.Atoi(text)
	fmt.Println(Employee(number))
}


package main

import "fmt"

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


package main

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

type graph struct {
	edges  [][]int
	degree []int
	scc    int
	color  []int
}

func (g *graph) add(from, to int) {
	g.edges[from] = append(g.edges[from], to)
	g.degree[from]++
}

func (g *graph) addBoth(from, to int) {
	g.add(from, to)
	if from != to {
		g.add(to, from)
	}
}

func (g *graph) dfs(v int) {
	g.color[v] = g.scc
	for _, w := range g.edges[v] {
		if g.color[w] == 0 {
			g.dfs(w)
		}
	}
}

func (g *graph) check() bool {
	cnt := 0
	for _, c := range g.color {
		if c == g.scc {
			cnt++
		}
	}
	for i, c := range g.color {
		if c == g.scc && g.degree[i] != cnt-1 {
			return false
		}
	}
	return true
}

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

	var n, m int
	Fscan(in, &n, &m)
	g := &graph{
		edges:  make([][]int, n+1),
		degree: make([]int, n+1),
		scc:    1,
		color:  make([]int, n+1),
	}
	for ; m > 0; m-- {
		var v, w int
		Fscan(in, &v, &w)
		g.addBoth(v, w)
	}

	g.dfs(1)
	if !g.check() {
		Fprint(out, "No")
		return
	}
	g.scc++
	for i := 2; i <= n; i++ {
		if g.color[i] == 0 {
			g.dfs(i)
			break
		}
	}
	if !g.check() {
		Fprint(out, "No")
		return
	}
	for _, c := range g.color[1:] {
		if c == 0 {
			Fprint(out, "No")
			return
		}
	}

	Fprintln(out, "Yes")
	for _, c := range g.color[1:] {
		if c == 1 {
			Fprint(out, "a")
		} else {
			Fprint(out, "c")
		}
	}
}

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


package main

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

func main() {
    var s string
    //fmt.Scan(&s)
    input:= bufio.NewScanner(os.Stdin)
    //input.Split(bufio.ScanLines)
    var c rune
    input.Scan()
    s=input.Text()
    fmt.Println(s)
    //s = strings.TrimSpace(s)
    c = rune(s[len(s)-2])
    c = unicode.ToLower(c)
    var cek bool
    cek = unicode.IsSpace(c)
    //fmt.Println(cek)
    for i:=3;cek==true;i++ {
    	c = rune(s[len(s)-i])
    	c = unicode.ToLower(c)
    	cek = unicode.IsSpace(c)
    }
    //fmt.Println(s)
    //fmt.Println(string(c))
    if (c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' || c == 'y') {
    	fmt.Println("YES")
    	return
    }
    fmt.Println("NO")
}


package main

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

func main() {
    var s string
    fmt.Scan(&s)
    input:= bufio.NewScanner(os.Stdin)
    var c rune
    input.Scan()
    s=input.Text()
    c = rune(s[len(s)-2])
    //c = unicode.ToLower(c)
    //fmt.Println(s)
    fmt.Println(string(c))
    if (c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' || c == 'y') {
    	fmt.Println("YES")
    	return
    }
    fmt.Println("NO")
}


package main

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

func main() {
    var s string
    fmt.Scan(&s)
    input:= bufio.NewScanner(os.Stdin)
    var c rune
    input.Scan()
    s=input.Text()
    s = strings.TrimSpace(s)
    c = rune(s[len(s)-2])
    c = unicode.ToLower(c)
    var cek bool
    cek = unicode.IsSpace(c)
    //fmt.Println(cek)
    for i:=3;cek==true;i++ {
    	c = rune(s[len(s)-i])
    	c = unicode.ToLower(c)
    	cek = unicode.IsSpace(c)
    }
    //fmt.Println(s)
    //fmt.Println(string(c))
    if (c == 'a' || c == 'e' || c == 'i' || c == 'u' || c == 'o' || c == 'y') {
    	fmt.Println("YES")
    	return
    }
    fmt.Println("NO")
}


// 49A-mic
package main

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

func main() {
    z := bufio.NewScanner(os.Stdin)
    var y bool
    var s []string
    y = false
    z.Scan()
    ss := z.Text()
    ss = strings.ToLower(ss)
    l := len(ss)
    for i := l - 1; i > 0; i-- {
        if ss[i] == ' ' || ss[i] == '?' {
            continue
        } else {
            s = append(s, string(ss[i]))
            break
        }
    }
    if s[0] == "a" || s[0] == "i" || s[0] == "u" || s[0] == "e" || s[0] == "o" || s[0] == "y" {
        y = true
    }
    if y {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}


package main

import (
	"fmt"
)

func main()  {
	var n int
	fmt.Scanf("%d\n", &n)
	var A = make([]int, n)
	var T = make([]int, n)

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

	for i := 0; i < n; i++ {
		T[n - 1 - i] = A[i]

		for j := 0; n - 1 - i + j + 1 <= n - 1; j++ {
			l := n - 1 - i + j
			r := l + 1
			d := T[l] - T[r]

			if d > 0 {
				T[r] += d
				T[l] -= d
			}
		}
	}

	fmt.Println(T)
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var t, a int
	var arr []int
	fmt.Scanf("%d\n", &t)
	for i := 0; i < t; i++ {
		fmt.Scanf("%d", &a)
		arr = append(arr, a)
	}
	sort.Ints(arr)
	fmt.Println(arr)
}


package main

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

func fastGetInt(b []byte) int {
	neg := false
	if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n
	}
	return n
}

func solveFromFile() []int {
	var num int
	var numList []int
	file, err := os.Open(os.Args[1])
	if err != nil {
		log.Fatalf("failed opening file: %s", err)
	}
	scanner := bufio.NewScanner(file)
	scanner.Split(bufio.ScanWords)

	scanner.Scan()
	num = fastGetInt(scanner.Bytes())
	num++
	for scanner.Scan() {
		numList = append(numList, fastGetInt(scanner.Bytes()))
	}

	defer file.Close()

	return solution(numList)
}

//========== Implement Algorithm =======================
func solution(numList []int) []int {
	sort.Ints(numList)

	return numList
}

func main() {

	//================== Variables used ====================
	var num int
	var numList, ret []int
	//======================================================

	if len(os.Args) >= 2 {
		//============== Get return value from File ============
		ret = solveFromFile()

	} else {
		//============== Get return value from STDIN ===========
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Split(bufio.ScanWords)

		scanner.Scan()
		num = fastGetInt(scanner.Bytes())
		num++

		for scanner.Scan() {
			numList = append(numList, fastGetInt(scanner.Bytes()))
		}

		ret = solution(numList)
	}

	//================== OUTPUT ============================
	for x := range ret {
		fmt.Print(x)
		fmt.Print(" ")
	}
}


package main

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

func main() {
	var n int
	fmt.Scanf("%d", &n)
	var a = make([]string, n, n)
	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &a[i])
	}
	sort.Strings(a)
	fmt.Printf(strings.Join(a, " "))
}


package main

import "fmt"
import "os"

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


// You can edit this code!
// Click here and start typing.
package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)

	s.Scan()
	start := strconv.Atoi(s.Text())
	s.Scan()
	every := strconv.Atoi(s.Text())
	s.Scan()
	eat := strconv.Atoi(s.Text())

	if eat == start {
		fmt.Println("YES")
	}

	for i := start + every; i <= eat; i += every {
		if eat == i || eat == i+1 {
			fmt.Println("YES")
			os.Exit(0)
		}
	}

	fmt.Println("NO")

}


package main

import "fmt"

func main() {
	var t, s, x int
	fmt.Scanf("%d%d%d", &t, &s, &x)
	if (x - t) % s == 0 || (x - t) % s == 1 && (x - t) / s > 0 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
    "fmt"
    "strconv"
)

func base(s, b int) int {
    ans := 0
    for s > 0 {
        s = s/b
        ans += 1
    }
    return ans
}

func main(){
    var a, b int
    fmt.Scan(&a)
    fmt.Scan(&b)
    sum := a+b
    x := strconv.Itoa(a) + strconv.Itoa(b)
    z := uint8(48)
    for i := 0; i < len(x); i++ {
        if z < x[i] {
            z = x[i]
        }
    }
    fmt.Print(base(sum, int(z-47)))

}


package main

import (
	"fmt"
)

var ps = fmt.Printf
var ss = fmt.Scanf

const mod int = 1000000007

func main() {
	t := 0
	m := 0
	var s, s1 string
	res := "FUCK\n"
	ss("%d\n%s", &t, &s)
	for i := 0; i < t-1; i++ {
		s1 = ""
		count := 0
		s1 = s1 + string(s[i]) + string(s[i+1])
		for j := 0; j < t-1; j++ {
			if s1[0] == s[i] && s1[1] == s[i+1] {
				count++
			}
		}
		if count >= m {
			m = count
			res = s1
		}
	}
	ps("%s", res)
}


package main
import."fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	n,s,m:=0,"",""
	Scan(&n, &s)
	c:=map[string]int{}
	for i := range s {
		for j := i + 2; j <= n; j++ {
			c[s[i:j]]++
		}
	}
	for s, v := range c {
		if v > c[m] {
			m = s
		}
	}
	Print(m)
}


package main

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

func getMaxFromMap(ma map[string]int) int {
    max := -999999999
    for _, m := range(ma) {
        if m > max {
            max = m
        }
    }

    return max
}

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

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

        cu := string(c) + string(input[i + 1])
        if _, ok := ma[cu]; ok {
            ma[cu] += 1
        } else {
            ma[cu] = 1
        }
    }

    fmt.Println(getMaxFromMap(ma))
}


package main

import "fmt"

func main() {
	var data string
	var n int
	fmt.Scanln(&n)
	fmt.Scanln(&data)
	var ans2, max int = 0, 0
	former := make([]int, 26)
	same := make([]int, 26)
	next := make([]int, 26)
	for i := 0;i < n-1 ; i++ {
		if data[i] == data[i+1]{
			same[data[i] - 'A']++
			if same[data[i] - 'A'] > max{
				ans2 = i
				max = same[data[i] - 'A']
			}
		} else if data[i] == 'Z' && data[i+1] == 'A' || data[i+1] == data[i]+1{
			next[data[i] - 'A']++
			if next[data[i] - 'A'] > max{
				ans2 = i
				max = next[data[i] - 'A']
			}
		}else if data[i] == 'A' && data[i+1] == 'Z' || data[i+1] == data[i]-1{
			former[data[i] - 'A']++
			if former[data[i] - 'A'] > max{
				ans2 = i
				max = former[data[i] - 'A']
			}
		}
	}
	fmt.Printf("%c%c", data[ans2], data[ans2+1])
}


// A. Petya and Origami
/*
Petya is having a party soon, and he has decided to invite his 𝑛 friends.

He wants to make invitations in the form of origami. For each invitation, he needs two red sheets, five green sheets, and eight blue sheets. The store sells an infinite number of notebooks of each color, but each notebook consists of only one color with 𝑘 sheets. That is, each notebook contains 𝑘 sheets of either red, green, or blue.

Find the minimum number of notebooks that Petya needs to buy to invite all 𝑛 of his friends.

Input
The first line contains two integers 𝑛 and 𝑘 (1≤𝑛,𝑘≤108) — the number of Petya's friends and the number of sheets in each notebook respectively.

Output
Print one number — the minimum number of notebooks that Petya needs to buy.

Examples
Input
3 5

Output
10

Input
15 6

Output
38

Note
In the first example, we need 2 red notebooks, 3 green notebooks, and 5 blue notebooks.

In the second example, we need 5 red notebooks, 13 green notebooks, and 20 blue notebooks.
*/
package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	input, _ := reader.ReadString('\n')
	arr := strings.Split(strings.TrimSpace(input), " ")
	n, _ := strconv.ParseFloat(arr[0], 64)
	k, _ := strconv.ParseFloat(arr[1], 64)

	r := math.Ceil(float64(2.0 * n / k))
	g := math.Ceil(float64(5.0 * n / k))
	b := math.Ceil(float64(8.0 * n / k))

	fmt.Print(r + g + b)

}


package main

import (
	"fmt"
)

func need(person, paper int) int {
	return person / paper + add(person, paper)
}

func add(item1, item2 int) int {
	if item1 < item2 || item1 % item2 == 0 {
		return 0
	} else {
		return 1
	}
}

func main() {
	var friends, papers, count int

	fmt.Scan(&friends, &papers)

	count = need(friends*2, papers) + need(friends*5, papers) + need(friends*8, papers)
	fmt.Println(count)
}


package main

import "fmt"

func GCD(a,b int64) int64 { if b == 0 { return a } else { return GCD(b,a%b) } }
func LCM(a,b int64) int64 { return (a/GCD(a,b))*b }

func main() {
    var n int64
    fmt.Scan(&n)
    ans := int64(1);
    if n <= 3 {
        for ; n > 0; n-- { ans *= n }

    } else if n%2 == 1 {
        for i := int64(0); i < 3; i++ {
            ans = LCM(ans,n-i)
        }
    } else {
        for i := int64(1); i <= 3; i++ {
            ans = LCM(ans,n-i)
        }
    }
    fmt.Println(ans)
}


package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	primes := sieves(n)

	if n == 1 {
		fmt.Println("1")
		return
	} else if n == 2 {
		fmt.Println("2")
		return
	} else if n == 3 {
		fmt.Println("6")
		return
	}

	set := []int64(nil)
	if n%2 == 0 {
		set = append(set, int64(n-1))
	} else {
		set = append(set, int64(n))
	}
	for i := set[0] - 1; i >= 1; i-- {
		isDiv := false
		for j := 0; j < len(set); j++ {
			if i%set[j] == 0 {
				isDiv = true
			}
		}
		if !isDiv {
			set = append(set, i)
		}
		if len(set) == 3 {
			break
		}
	}
	//fmt.Println(set)
	fmt.Println(mul(set, primes))
}

func mul(xs, primes []int64) (ans int64) {
	factors := make([]int64, len(primes))
	for i := 0; i < len(xs); i++ {
		x := xs[i]
		iFactors := make([]int64, len(primes))
		for x > 1 {
			for j := 0; j < len(primes); j++ {
				if x%primes[j] == 0 {
					x /= primes[j]
					iFactors[j]++
					if iFactors[j] > factors[j] {
						factors[j] = iFactors[j]
					}
					break
				}
			}
		}
	}

	ans = 1
	for i := 0; i < len(factors); i++ {
		if factors[i] > 0 {
			ans *= int64(math.Pow(float64(primes[i]), float64(factors[i])))
		}
	}
	return
}

func sieves(n int) (primes []int64) {
	n = n + 1
	xs := make([]bool, n)
	xs[0] = true
	xs[1] = true
	primes = make([]int64, 0, n)
	for i := 2; i < n; i++ {
		for j := i * 2; j < n; j = j + i {
			xs[j] = true
		}
	}

	for i := 0; i < n; i++ {
		if !xs[i] {
			primes = append(primes, int64(i))
		}
	}

	return
}


package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Scan()
	n, _ := strconv.Atoi(s.Text())
	primes := sieves(n)

	if n <= 3 {
		fmt.Println(mul([]int64{1, 2, 6}, primes), primes)
		return
	}

	set := []int64(nil)
	if n%2 == 0 {
		set = append(set, int64(n-1))
	} else {
		set = append(set, int64(n))
	}
	for i := set[0] - 1; i >= 1; i-- {
		isDiv := false
		for j := 0; j < len(set); j++ {
			if i%set[j] == 0 {
				isDiv = true
			}
		}
		if !isDiv {
			set = append(set, i)
		}
		if len(set) == 3 {
			break
		}
	}
	//fmt.Println(set)
	fmt.Println(mul(set, primes))
}

func mul(xs, primes []int64) (ans int64) {
	factors := make([]int64, len(primes))
	for i := 0; i < len(xs); i++ {
		x := xs[i]
		iFactors := make([]int64, len(primes))
		for x > 1 {
			for j := 0; j < len(primes); j++ {
				if x%primes[j] == 0 {
					x /= primes[j]
					iFactors[j]++
					if iFactors[j] > factors[j] {
						factors[j] = iFactors[j]
					}
					break
				}
			}
		}
	}

	ans = 1
	for i := 0; i < len(factors); i++ {
		if factors[i] > 0 {
			ans *= int64(math.Pow(float64(primes[i]), float64(factors[i])))
		}
	}
	return
}

func sieves(n int) (primes []int64) {
	n = n + 1
	xs := make([]bool, n)
	xs[0] = true
	xs[1] = true
	primes = make([]int64, 0, n)
	for i := 2; i < n; i++ {
		for j := i * 2; j < n; j = j + i {
			xs[j] = true
		}
	}

	for i := 0; i < n; i++ {
		if !xs[i] {
			primes = append(primes, int64(i))
		}
	}

	return
}


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

package main

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

func Solve(n int64) int64 {
	if n%2 == 1 {
		return n * (n - 1) * (n - 2)
	} else if n%2 == 0 && n%3 == 0 {
		return (n - 1) * (n - 2) * (n - 3)
	}
	return n * (n - 1) * (n - 3)
}

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

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

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


// https://codeforces.com/contest/13/problem/A
package main

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

// (c) Dmitriy Blokhin (sv.dblokhin@gmail.com)

func main() {
	var (
		A int
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)
	fmt.Fscan(input, &A)
	ans := 0
	cnt := 0
	for i := 2; i < A; i++ {
		tmp := A
		for tmp > 0 {
			ans += tmp % i
			tmp /= i
		}
		cnt++
	}

	fmt.Printf("%d/%d", ans, cnt)
}


// 13A
package main

import (
	"fmt"
)

func gcd(n, m int) int {
	if m == 0 {
		return n
	} else {
		return gcd(m, n%m)
	}
}

func main() {
	var n, m, i int
	sum := 0
	fmt.Scan(&n)
	for i = 2; i < n; i++ {
		m = n
		for m != 0 {
			sum += m % i
			m /= i
		}
	}
	fmt.Println(sum/gcd(sum, n-2), "/", (n-2)/gcd(sum, n-2))
}


package main

import (
	"fmt"
)

func build_tree() [][]uint64 {
	output := make([][]uint64, 35)
	for i:=0; i<=30; i++ {
		t := make([]uint64, 35)
		t[0]=1
		for j:=1; j<=i; j++ {
			t[j] = output[i-1][j] + output[i-1][j-1]
		}
		output[i] = t
	}
	return output
}

func main() {
	tree := build_tree()
	var n, m, t int
	var ans uint64
	fmt.Scan(&n, &m, &t)
	for i:=4; i<=n; i++ {
		if t-i < 1 {continue}
		ans += tree[n][i] * tree[m][t-i]
	}
	fmt.Println(ans)
}


package main

import "fmt"
import "strconv"

func main() {
    var n int
    fmt.Scan(&n)
    str := "0"
    for i:=1; i<=n; i++{
        s, _ := strconv.Itoa(i)
        str += s
    }
    fmt.Print(str[n])
}


package main

import "fmt"
import "strconv"

func main() {
    var n int
    fmt.Scan(&n)
    str := "0"
    for i:=1; i<=n; i++{
        s := strconv.Itoa(i)
        str += s
    }
    fmt.Printf("%d", str[n])
}


package main

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

func solve(s string) int {
	var current byte = 'a'
	sum := 0
	for i := range s {
		d := abs(int(current), int(s[i]))
		if d < 13 {
			sum += d
		} else {
			sum += 26 - d
		}
		current = s[i]
	}

	return sum
}

func abs(n1 int, n2 int) int {
	d := n1 - n2
	if d > 0 {
		return d
	}

	return n2 - n1
}

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

	var s string

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

	fmt.Fprintf(os.Stdout, "%d\n", solve(s))
}


/*
Epic Game
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Simon and Antisimon play a game. Initially each player receives one fixed positive integer that doesn't change throughout the game. Simon receives number a and Antisimon receives number b. They also have a heap of n stones. The players take turns to make a move and Simon starts. During a move a player should take from the heap the number of stones equal to the greatest common divisor of the fixed number he has received and the number of stones left in the heap. A player loses when he cannot take the required number of stones (i. e. the heap has strictly less stones left than one needs to take).

Your task is to determine by the given a, b and n who wins the game.

Input
The only string contains space-separated integers a, b and n (1 ≤ a, b, n ≤ 100) — the fixed numbers Simon and Antisimon have received correspondingly and the initial number of stones in the pile.

Output
If Simon wins, print "0" (without the quotes), otherwise print "1" (without the quotes).

Sample test(s)
input
3 5 9
output
0
input
1 1 100
output
1
Note
The greatest common divisor of two non-negative integers a and b is such maximum positive integer k, that a is divisible by k without remainder and similarly, b is divisible by k without remainder. Let gcd(a, b) represent the operation of calculating the greatest common divisor of numbers a and b. Specifically, gcd(x, 0) = gcd(0, x) = x.

In the first sample the game will go like that:

Simon should take gcd(3, 9) = 3 stones from the heap. After his move the heap has 6 stones left.
Antisimon should take gcd(5, 6) = 1 stone from the heap. After his move the heap has 5 stones left.
Simon should take gcd(3, 5) = 1 stone from the heap. After his move the heap has 4 stones left.
Antisimon should take gcd(5, 4) = 1 stone from the heap. After his move the heap has 3 stones left.
Simon should take gcd(3, 3) = 3 stones from the heap. After his move the heap has 0 stones left.
Antisimon should take gcd(5, 0) = 5 stones from the heap. As 0 < 5, it is impossible and Antisimon loses.
In the second sample each player during each move takes one stone from the heap. As n is even, Antisimon takes the last stone and Simon can't make a move after that.
*/

package main

import (
	"fmt"
)

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

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

	var person int
	for take, count := gcd(a, n), 1;take < n;take = gcd(a, n) {
		n -= take
		person += count
		count *= -1
	}
	fmt.Println(person)
}


package main

import (
	"fmt"
	"strconv"
)

func main() {
	var a, b, n int
	fmt.Scanf("%d %d %d \n", &a, &b, &n)
	res := getStones(a, b, n)
	fmt.Println(strconv.Itoa(res))

}

func canN(n, a int) bool {
	if n >= a {
		return true
	}
	return false
}

func getStones(a, b, n int) (result int) {
	for n > 0 {
		first := Nod(a, n)
		second := Nod(b, n)
		if canN(n, first) {
			n -= first
			result = 0
		} else {
			result++
			return
		}
		if canN(n, second) {
			n -= second
			result++
		} else {
			result = 0
			return
		}
	}
	return
}

func Nod(a, b int) int {
	var del int
	chastnoe := 0
	del = min(a, b)
	for i := 1; chastnoe != a; i++ {
		if a%i != 0 {
			continue
		}
		del = a / i
		chastnoe = a / del
		if b%del == 0 {
			return del
		}
	}
	return 1
}

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


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

package main

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

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

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

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

type Scanner struct {
    *bufio.Scanner
}

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

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

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


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

package main

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

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

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

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

type Scanner struct {
    *bufio.Scanner
}

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

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

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

package main

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

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

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

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

type Scanner struct {
    *bufio.Scanner
}

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

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

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


package main

import "fmt"

func main() {
	var totalNum, currentNum, showSize int
	fmt.Scanf("%d", &totalNum)
	fmt.Scanf("%d", &currentNum)
	fmt.Scanf("%d", &showSize)

	if currentNum - showSize > 1 {
		fmt.Print("<< ")
	}
	for i := showSize; i >0; i-- {
		fmt.Printf("%d ", currentNum - i)
	}
	fmt.Printf("(%d)", currentNum)
	for i := 1; i <= showSize; i++ {
		showNum := currentNum + i
		if showNum > totalNum {
			break
		} else {
			fmt.Printf(" %d", showNum)
		}
	}
	if(currentNum + showSize < totalNum) {
		fmt.Print(" >>")
	}
}


package main

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

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

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

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

  a, b := getI(), getI()
  t, d := getI(), getI()
  result := a + b
  x := a
  for i := 2; i < t; i++ {
    x += d
    result += x
  }
  excess := x-b-d
  subtract := 0
  for excess > 0 {
    if excess < 2*d {
      subtract += excess
      excess = 0
    } else {
      subtract += 2*d
      excess -= 2*d
    }
    result -= subtract
  }
  writer.WriteString(fmt.Sprintf("%d\n", result))
}


package main

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

const (
	MAX_T = 100
)

var v1, v2 int
var T, D int
var dp [MAX_T][MAX_T * 10]int

func init() {
	for i := 0; i < MAX_T; i++ {
		for j := 0; j < len(dp[i]); j++ {
			dp[i][j] = -1
		}
	}
}

func memo(t, v int) int {
	if t == T {
		if v == v2 {
			return 0
		}
		return -1145141919
	}
	if dp[t][v] >= 0 {
		return dp[t][v]
	}
	res := -1145141919
	res = IntMax(res, memo(t+1, v)+v)
	for i := 1; i <= D; i++ {
		res = IntMax(res, memo(t+1, v+i)+v+i)
		if v-i >= 0 {
			res = IntMax(res, memo(t+1, v-i)+v-i)
		}
	}
	dp[t][v] = res
	return res
}

func main() {
	fsc := NewFastScanner()
	v1, v2 = fsc.NextInt(), fsc.NextInt()
	T, D = fsc.NextInt(), fsc.NextInt()
	fmt.Println(memo(1, v1) + v1)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) 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 *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) 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
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}


package main

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

const (
	MAX_T = 100
)

var v1, v2 int
var T, D int
var dp [MAX_T][MAX_T * 10]int
var visited [MAX_T][MAX_T * 10]bool

func init() {
	for i := 0; i < MAX_T; i++ {
		for j := 0; j < len(dp[i]); j++ {
			dp[i][j] = -1
		}
	}
}

func memo(t, v int) int {
	if t == T {
		if v == v2 {
			return 0
		}
		return -1145141919
	}
	if visited[t][v] {
		return dp[t][v]
	}
	visited[t][v] = true
	res := -1145141919
	res = IntMax(res, memo(t+1, v)+v)
	for i := 1; i <= D; i++ {
		res = IntMax(res, memo(t+1, v+i)+v+i)
		if v-i >= 0 {
			res = IntMax(res, memo(t+1, v-i)+v-i)
		}
	}
	dp[t][v] = res
	return res
}

func main() {
	fsc := NewFastScanner()
	v1, v2 = fsc.NextInt(), fsc.NextInt()
	T, D = fsc.NextInt(), fsc.NextInt()
	fmt.Println(memo(1, v1) + v1)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) 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 *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) 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
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

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

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}


package main

import (
	"fmt"
)

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

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

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

func main() {
	var v1, v2, t, d int
	fmt.Scanf("%d%d%d%d", &v1, &v2, &t, &d)
	ans := 0
	speed := v1
	for i := 0; i < t; i++ {
		ans += speed
		speed = int_min(speed+d, v2+d*(t-2-i))
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
)

func queen(x int64, y int64, z int64) int {
	res := z * 2
	if x == y {
		res += x * 2
		return res
	} else if x > y {
		res += y * 2 + 1
		return res
	} else {
		res += x * 2 + 1
		return res
	}
}

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


package main

import "fmt"

func solve(a, b, c uint64) uint64 {
	res := a
	if b < a {
		res = b
	}

	return 2*res + 2*c
}

func main() {
	var a, b, c uint64

	fmt.Scan(&a, &b, &c)

	res := solve(a, b, c)
	fmt.Println(res)
}


package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var a , b ,c int
	fmt.Fscan(in,&a,&b,&c)
	//3 2
	total := min1(a,b) + c * 2
	if(a != b){
		total += 1
	}
	fmt.Fprint(out,total)

}
func min1(x1,x2 int) int  {
	if(x1 < x2){
		return x1
	}else{
		return x2
	}
}


package main

import (
	"fmt"
)

func main() {
	var k,w,d int64
	fmt.Scan(&k,&d,&w)
	n:=(k+(w*k))*w/2
	n-=d
	if n<0{
		fmt.Printf("%d\n",'0')
	} else {
		fmt.Printf("%d\n",n)
	}

}


package main

import (
	"fmt"
)

func main() {
	var k,w,d int64
	fmt.Scan(&k,&d,&w)
	n:=(k+(w*k))*w/2
	n-=d
	if n<0{
		fmt.Printf('0')
	} else {
		fmt.Printf(n)
	}

}


package main

import(
    "fmt"
)

type i64 int64

func main(){
    var(
        k,n,w,res i64
    )
    fmt.Scan(&k,&n,&w)
    res = (k *w*(w+1))/2
    fmt.Println(res)
    if res > n{
        fmt.Println(res-n)
    }else{
        fmt.Println(0)
    }
}


package main

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

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

	var x, s, i int
	Fscan(in, &x)
	if x < 0 {
		x = -x
	}
	for {
		s += i
		if s >= x && (s-x)&3 == 0 {
			Fprint(out, i)
			return
		}
		i++
	}
}

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


// 388A
package main

import (
	"fmt"
	"sort"
)

func main() {
	var x [100]int
	var n, rnt int
	for fmt.Scan(n) {
		for i := 0; i < n; i++ {
			fmt.Scan(x[i])
		}
		sort.Ints(x[:])
		for rnt = 1; rnt <= n; rnt++ {
			for j := 0; j < n; j++ {
				if x[j]-j/rnt < 0 {
					break
				}
				if j == n {
					break
				}
			}
		}
	}
	fmt.Println(rnt)
}


// 388A
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, rnt int
	x := make([]int, n)
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		fmt.Scan(x[i])
	}
	sort.Ints(x)
	for rnt = 1; rnt <= n; rnt++ {
		for j := 0; j < n; j++ {
			if x[j]-j/rnt < 0 {
				break
			}
			if j == n {
				break
			}
		}
	}
	fmt.Println(rnt)
}


// 388A
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, rnt int
	fmt.Scan(&n)
	x := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(x[i])
	}
	sort.Ints(x)
	for rnt = 1; rnt <= n; rnt++ {
		for j := 0; j < n; j++ {
			if x[j] < (j / rnt) {
				break
			}
			if j == n {
				break
			}
		}
	}
	fmt.Println(rnt)
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	_, _, _ = reader.ReadLine()
	text, _, _ := reader.ReadLine()

	str := string(text)

	if !strings.Contains(str, "R") && !strings.Contains(str, "B") {
		fmt.Println("G")
	} else if !strings.Contains(str, "G") && !strings.Contains(str, "B") {
		fmt.Println("R")
	} else if !strings.Contains(str, "R") && !strings.Contains(str, "G") {
		fmt.Println("B")
	} else if !strings.Contains(str, "R") && len(str) == 2 {
		fmt.Println("R")
	} else if !strings.Contains(str, "B") && len(str) == 2 {
		fmt.Println("B")
	} else if !strings.Contains(str, "G") && len(str) == 2 {
		fmt.Println("G")
	} else if !strings.Contains(str, "R") {
		if ada1(str, "B") {
			fmt.Println("BR")
		} else if ada1(str, "G") {
			fmt.Println("GR")
		} else {
			fmt.Println("BGR")
		}
	} else if !strings.Contains(str, "B") {
		if ada1(str, "R") {
			fmt.Println("BR")
		} else if ada1(str, "G") {
			fmt.Println("BG")
		} else {
			fmt.Println("BGR")
		}
	} else if !strings.Contains(str, "G") {
		if ada1(str, "B") {
			fmt.Println("BG")
		} else if ada1(str, "R") {
			fmt.Println("GR")
		} else {
			fmt.Println("BGR")
		}
	} else {
		fmt.Println("BGR")
	}
}

func ada1(str string, a string) bool {

	return strings.Contains(str, a)
}


package main

import (
	"fmt"
)

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

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

	counts := [3]int{}

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

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


package main

import (
	"fmt"
)

const None = 0
const Red = 1
const Blue = 2
const Green = 4

func colors(r, g, b int) int {
	if r < 0 || g < 0 || b < 0 {
		return None
	}
	// fmt.Println(r, g, b)
	if r == 1 && g == 0 && b == 0 {
		return Red
	}
	if r == 0 && g == 1 && b == 0 {
		return Green
	}
	if r == 0 && g == 0 && b == 1 {
		return Blue
	}

	result := None

	for _, i := range [][]int{
		[]int{r + 1, g - 1, b - 1},
		[]int{r - 1, g + 1, b - 1},
		[]int{r - 1, g - 1, b + 1},
	} {
		result = result | colors(i[0], i[1], i[2])
	}
	if r > 1 {
		result = result | colors(r-1, g, b)
	}
	if g > 1 {
		result = result | colors(r, g-1, b)
	}
	if b > 1 {
		result = result | colors(r, g, b-1)
	}
	return result
}

func main() {
	var count int
	var col string

	fmt.Scan(&count)
	fmt.Scan(&col)

	var r, g, b int

	for _, c := range col {
		switch c {
		case 'R':
			r++
		case 'G':
			g++
		case 'B':
			b++
		}
	}

	// fmt.Println(r, g, b)
	result := colors(r, g, b)
	// fmt.Println(result)
	if (result & Blue) != 0 {
		fmt.Print("B")
	}
	if (result & Green) != 0 {
		fmt.Print("G")
	}
	if (result & Red) != 0 {
		fmt.Print("R")
	}
	fmt.Println()
}


package main

import "fmt"

func main() {
    var n, ans int64
    var a [10]int64
    fmt.Scan(&n)

    for i := 0; i < 9; i++ {
        a[i] = n / 9
        if i != 0 && n % 9 >= i {
            a[i] += 1
        }
    }

    for i := 0; i < 9; i++ {
        for j := 0; j < 9; j++ {
            ans += a[i] * a[j] * a[i * j]
        }
    }

    for i := 1; i <= n; i++ {
        ans -= n / int64(i)
    }
    fmt.Println(ans)

    return
}


package main

import "fmt"

func main() {
    var n, ans int64
    var a [10]int64
    fmt.Scan(&n)

    for i := 0; i < 9; i++ {
        a[i] = n / 9
        if i != 0 && n % 9 >= int64(i) {
            a[i] += 1
        }
    }

    for i := 0; i < 9; i++ {
        for j := 0; j < 9; j++ {
            ans += a[i] * a[j] * a[i * j]
        }
    }

    for i := 1; int64(i) <= n; i++ {
        ans -= n / int64(i)
    }
    fmt.Println(ans)

    return
}


package main

import "fmt"

func main() {
	var m, n uint64
	fmt.Scan(&n, &m)
	if n > 31 {
		n = uint64(31)
	}
	pow := uint64(2) << n
	fmt.Println(m % pow)
}


package main

import (
	"fmt"
	"os"
)

func main() {
	var n, m int
	fmt.Fscan(os.Stdin, &n, &m)
	var v = 2
	for i := 1; i < n; i++ {
		if m <= v {
			break
		}
		v *= 2
	}
	fmt.Println(m % v)
}


package main

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

func main() {
	var scanner *bufio.Scanner
	var n int
	var e error
	var min [6]int = [6]int{0, 0, 0, 0, 0, 1}
	var max [7]int = [7]int{1, 2, 2, 2, 2, 2, 2}

	scanner = bufio.NewScanner(os.Stdin)

	scanner.Scan()

	n, e = strconv.Atoi(strings.TrimSpace(scanner.Text()))
	if e != nil {
		panic(e)
	}

	fmt.Println(min[(n-1)%6]+(n/7)*2, max[(n-1)%7]+(n/8)*2)

}


package main

import "fmt"

func main() {
	var d int
	fmt.Scanf("%d", &d)
	mod := d % 7
	weeksCompleted := (d - mod) / 7
	weekend := weeksCompleted * 2
	minWeekend := weekend
	maxWeekend := weekend
	if mod > 1 {
		maxWeekend += 2
	}
	if mod == 1 {
		maxWeekend++
	}
	fmt.Println(minWeekend, maxWeekend)
}


package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    var min, max int
    min, max = n/7, n/7
    if n%7 > 5 {
        min += (n%7)-5
        max += 2
    } else if n%7 < 2 {
        max += n%7
    } else {
        max += 2
    }
    fmt.Print(min, " ", max)
}


// cf670a project main.go
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var ma int
	if ma > 1 {
		ma = 2 + (((n - 2) / 7) * 2)
		if (n-2)%7 > 5 {
			ma += ((n - 2) % 7) - 5
		}
	} else {
		ma = n
	}
	mi := (n / 7) * 2
	if n%7 > 5 {
		mi += (n % 7) - 5
	}
	fmt.Println(mi, ma)
}


package main

import "fmt"

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

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

func main() {
	var n int
	fmt.Scan(&n)
	crush := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&crush[i])
		crush[i]--
	}
	ans := 1
	for i := 0; i < n; i++ {
		node := i
		for k := 0; k < n; k++ {
			node = crush[node]
			if node == i {
				ans = lcm(ans, (k+1)/2)
				goto start
			}
		}
		ans = -1
		break
	start:
	}
	fmt.Println(ans)
}


package main

import "fmt"

func getCrush(x, t int, crush []int) int {
	for i := 0; i < t; i++ {
		x = crush[x]
	}
	return x
}

func main() {
	var n int
	fmt.Scan(&n)
	crush := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&crush[i])
		crush[i]--
	}
	ans := -1
	for t := 1; t <= 2*n*n; t++ {
		flag := true
		for x := 0; x < n; x++ {
			y := getCrush(x, t, crush)
			if x != getCrush(y, t, crush) {
				flag = false
				break
			}
		}
		if flag {
			ans = t
			break
		}
	}
	fmt.Println(ans)
}


package main

import "fmt"

type crushes []int

func gcd(a, b int64) int64 {
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

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

func lcmm(a ...int) int64 {
	l := int64(a[0])
	for _, v := range a {
		l = lcm(l, int64(v))
	}
	return l
}

func (cr crushes) CountStepsToReturn(start int) int {
	cnt := 1
	cur := start
	for cnt <= len(cr) {
		cur = cr[cur]
		if cur == start {
			break
		}
		cnt++
	}
	if cnt > len(cr) {
		return -1
	}
	return cnt
}

func main() {
	var n int
	fmt.Scan(&n)
	var cr crushes = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&cr[i])
		cr[i]--
	}
	min := make([]int, n)
	var ans int
	for i := 0; i < n; i++ {
		m := cr.CountStepsToReturn(i)
		if m == -1 {
			ans = -1
			break
		} else if m%2 == 0 {
			m = m / 2
		}
		min[i] = m
	}
	if ans != -1 {
		ans = lcmm(min...)
	}
	fmt.Println(ans)
}


package main

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

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

	N, H := readTwoNums(reader)

	fmt.Println(solve(N, H))
}

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

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

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

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

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

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

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

	return i
}

func solve(N, H int) int64 {
	dp := make([][]int64, N+1)
	fp := make([][]int64, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = make([]int64, N+1)
		fp[i] = make([]int64, N+1)
	}

	for h := 0; h <= N; h++ {
		dp[0][h] = 1
	}

	for h := 1; h <= N; h++ {
		for n := h; n <= N; n++ {
			for x := 0; x < n; x++ {
				dp[n][h] += dp[x][h-1] * dp[n-1-x][h-1]
			}
			fp[n][h] = dp[n][h]
			dp[n][h] += dp[n][h-1]
		}
	}
	var res int64
	for h := H; h <= N; h++ {
		res += fp[N][h]
	}

	return res
}


package main

import (
	"fmt"
)

func check(k,n uint64) bool  {
	total := n
	tot := uint64(0)
	for n > 0 {
		if k >= n {
			n = 0
			tot += n
		}else{
			n -= k
			tot +=k
			n -= n/10
		}
	}
	return tot * 2 >= total
}

func main() {
	var n uint64
	fmt.Scan(&n)
	lb := uint64(0)
	ub := n

	for ub - lb > 1{
		mid := (lb + ub)/2
		if check(mid,n) {
			ub = mid
		}else{
			lb = mid
		}
	}
	fmt.Println(ub)
}


package main

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

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

	s := strings.TrimSpace(line)
	stringLength := len(s)

	line, _ = reader.ReadString('\n')
	var k int

	fmt.Sscanf(line, "%d", &k)

	newString := make([]rune, stringLength+k)
	copy(newString, []rune(s))

	bestRepeat := 0
	for i := 0; i < stringLength+k; i++ {
		currentRepeat := 0
		for i+currentRepeat < stringLength+k && currentRepeat <= (stringLength+k-i)/2 {
			if newString[i+currentRepeat] == newString[i] || newString[i+currentRepeat] == 0 {
				if currentRepeat > bestRepeat {
					bestRepeat = currentRepeat
				}
			}
			currentRepeat++
		}
	}
	fmt.Println(2 * (bestRepeat - 0))
}


// 443B
package main

import (
	"fmt"
)

func main() {
	var st [500]string
	var ans, i, j, k, n, length, flag, max int
	fmt.Scan(&st)
	length = len(st)
	fmt.Scan(&n)
	ans = n + length
	max = 0
	for i = 0; i < ans; i++ {
		for j = 0; i+2*j-1 < ans; j++ {
flag = 0
			for k = i; k < i+j; k++ {
				if k >= length || j+k >= length || st[k] == st[j+k] {
					continue
				} else {
					flag = 1
					break
				}
			}
			if flag == 0 {
				if 2*j > max {
					max = 2 * j
				}
			}
			max = 2 * j
		}
	}
	fmt.Println(max)
}


package main

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

func main() {
	var n, a, b, x, y, cnt int
	scr := bufio.NewReader(os.Stdin)
	// ocr := bufio.NewWriter(os.Stdout)

	fmt.Fscanln(scr, &n, &a, &x, &b, &y)

	for i := 0; i <= n; i++ {
		if a == b {
			cnt = 2
			break
		}
		a++
		a = a % (n + 1)
		b--
		if b == 0 {
			b = n
		}

		if a == b {
			cnt = 2
			break
		}

		if a == x || b == y {
			break
		}
	}

	if cnt == 2 {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
	"fmt"
)

func solve339a() {
	// digits can only be {1,2,3}
	// input is <= 100 characters
	// no spaces
	// digit and/or plus sign
	// could be a single character(digit)

	// if we use sorting in stdlib, then parse by "+", sort, and join with "+"

	// if we implement sorting, a good constraint is that numbers are {1,2,3}.

	// count 1, 2 and 3 digits in a map(nah just variables)
	// create a string with "+" between each counted digit if sum of count > 1
	// else just print

	equation := ""
	fmt.Scan(&equation)

	one := 0
	two := 0
	three := 0

	for _, c := range equation {
		switch c {
		case '1':
			one++
		case '2':
			two++
		case '3':
			three++
		}
	}

	if one+two+three <= 1 {
		fmt.Println(equation)
	} else {
		result := ""
		result = appendNumber(result, one, 1)
		result = appendNumber(result, two, 2)
		result = appendNumber(result, three, 3)
		result = result[:len(result)-1]
		fmt.Println(result)
	}
}

func appendNumber(result string, count, num int) string {
	for count > 0 {
		result += fmt.Sprintf("%d+", num)
		count--
	}
	return result
}


package main

import (
	"fmt"
	"strings"
	"math/rand"
	"sort"
	"sync"
)

const MAX = 3

func Sort(A []int) []int {
	N := rand.Intn(len(A))
	q := len(A) / N
	r := len(A) % N
	splits := make([][]int, N)
	pos := 0
	for i := 0; i < N; i++ {
		var delta int
		if i < r {
			delta = q + 1;
		} else {
			delta = q;
		}
		splits[i] = A[pos : pos + delta]
		pos += delta
	}
	waitGroup := new(sync.WaitGroup)
	for i := 0; i < N; i++ {
		waitGroup.Add(1)
		go func(B []int) {
			sort.Ints(B)
			waitGroup.Done()
		}(splits[i])
	}
	waitGroup.Wait()
	B := make([]int, 0);
	next := make([]int, N)
	for len(B) < len(A) {
		idx := -1
		for i := 0; i < N; i++ {
			if next[i] < len(splits[i]) && (idx == -1 || splits[i][next[i]] < splits[idx][next[idx]]) {
				idx = i
			}
		}
		B = append(B, splits[idx][next[idx]])
		next[idx]++
	}
	return B
}

func main() {
	var input string
	fmt.Scanln(&input)
	digits := strings.Split(input, "+")
	ints := make([]int, 0)
	for i := 0; i < len(digits); i++ {
		ints = append(ints, int(digits[i][0]) - '0')
	}
	ints = Sort(ints)
	for i := 0; i < len(ints); i++ {
		if i > 0 {
			fmt.Print("+")
		}
		fmt.Print(ints[i])
	}
	fmt.Println()
}