package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	var array [200]int
	for i := 0; i < n; i++ {
		fmt.Scanf("%d", &array[i])
	}
	sort.Ints(array[:n])
	var sum float64 = float64(4.5 * float64(n))

	for i := 0; i < n; i++ {
		sum -= float64(array[i])
		//	fmt.Printf("%d ", array[i])
	}
	//	fmt.Printf("%f\n", sum)
	if sum <= 0 {
		fmt.Printf("0\n")
		return
	} else {
		//	fmt.Printf("%f\n", sum)
		sum = -sum
		var result int = 0
		for i := 0; i < n; i++ {
			sum += float64(5 - array[i])
			result++
			//	fmt.Printf("%f", sum)
			if sum >= 0 {
				break
			}
		}
		fmt.Printf("%d\n", result)
	}

}


package main

import "fmt"

func main(){
	var n int
	fmt.Scan(&n)
	slice := make([][]int, n)
	for i := 0; i < n; i++{
		for j := 0; j < n; j++ {
			if i == 0 {
				slice[0] = append(slice[0], 1)
			} else if j == 0{
				slice[i] = append(slice[i], 1)
			} else {
				slice[i] = append(slice[i], slice[i-1][j] + slice[i][j - 1])
			}
		}
	}
	fmt.Println(slice[n - 1][n - 1])
}


package main

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

var scanner *bufio.Scanner

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

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

  base, target := getI64(), getI64()
  count := -2
  for x := int64(1); x <= target; x *= base {
    count++
    if x == target {
      writer.WriteString(fmt.Sprintf("YES\n%d\n", count))
      return
    }
  }
  writer.WriteString("NO\n")
}


package main

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

func main() {
	buf := bufio.NewReader(os.Stdin)
	var t int
	fmt.Fscanf(buf, "%d\n", &t)
	v := make([]int,t)
	for i := 0; i < t; i++ {
		fmt.Fscanf(buf, "%d", &v[i])
	}
	sort.Ints(v)
	ans := 0
	for i := 0; i < t; i+=2 {
		ans += v[i+1]-v[i]
	}
	fmt.Printf("%d\n",ans)
}


package main

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

func main() {
	var (
		n, t int
		a    []int
	)

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

	n, _ = strconv.Atoi(scanner.Text())

	t = n / 2

	a = make([]int, t)

	for i := 0; i < t; i++ {
		scanner.Scan()
		a[i], _ = strconv.Atoi(scanner.Text())
	}

	sort.Ints(a)

	current := 0
	cnt1 := 0

	// Blacks
	for i := 1; i <= n; i += 2 {
		pos := a[current]
		dist := pos - i

		// math.Abs emulation
		if dist < 0 {
			dist = dist * -1
		}

		cnt1 += dist
		current++
	}

	current = 0
	cnt2 := 0

	// Whites
	for i := 2; i <= n; i += 2 {
		pos := a[current]
		dist := pos - i

		// math.Abs emulation
		if dist < 0 {
			dist = dist * -1
		}

		cnt2 += dist
		current++
	}

	if cnt1 < cnt2 {
		fmt.Println(cnt1)
	} else {
		fmt.Println(cnt2)
	}
}


package main

import "fmt"

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

func main() {
    var x, y, a, b, lcm int
    fmt.Scanf("%d %d %d %d", &x, &y, &a, &b)
    if x > y {
        lcm = x*y/gcd(x, y)

    } else {
        lcm = x*y/gcd(y, x)
    }

    fmt.Print(b/lcm - (a-1)/lcm)
}


package main

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

func main() {
	A:=""
  _, err := fmt.Scanf("%s", &A)
  b:=strings.Split(A,"+")

	if err !=nil{
		log.Fatal(err)
  }
  sort.Strings(b)
  A=b[0]
  for x:=1; x<len(b);x++{
      A += "+" + b[x]
  }
  fmt.Print(A)

}


package main

import (
    "fmt"
    "sort"
)

func main() {
    var k int
    a := make([]int,12)
    fmt.Scan(&k)
    for i := 0; i < 12; i++ {
        fmt.Scan(&a[i])
    }
    sort.Sort(sort.IntSlice(a))
    cnt, ans := 0, 0
    for i := 11; (i >= 0) && (cnt < k); i-- {
        cnt += a[i]
        ans++
    }
    if cnt < k { fmt.Println(-1) } else { fmt.Println(ans) }
}


// 343A
package main

import (
	"fmt"
)

func main() {
	var a, b, c, ans int64
	ans = 0
	fmt.Scan(&a, &b)
	for b != 0 {
		ans += a / b
		a %= b
		c = a
		a = b
		b = c
	}
	fmt.Print(ans)
}


package main

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

func main() {
	var x1,y1 float64
	fmt.Scanf("%f %f\n", &x1, &y1)
	x := (math.Log(x1)*y1)
	y := (math.Log(y1)*x1)
	if x == y {
		fmt.Println("=")
	} else if x > y {
		fmt.Println(">")
	} else {
		fmt.Println("<")
	}
}

func readOneInt64(r *bufio.Reader) (n int64) {
	bytes, _ := r.ReadBytes('\n')
	n, _ = strconv.ParseInt(string(bytes[:len(bytes)-2]), 10, 64)
	return
}

func readInt64Slice(r *bufio.Reader, n int) (slice []int64) {
	var bytes []byte
	slice = make([]int64, n)
	n--
	for i := 0; i < n; i++ {
		bytes, _ = r.ReadBytes(' ')
		slice[i], _ = strconv.ParseInt(string(bytes[:len(bytes)-1]), 10, 64)
	}
	slice[n] = readOneInt64(r)
	return
}

func readOneString(r *bufio.Reader) string {
	bytes, _ := r.ReadBytes('\n')
	return string(bytes[:len(bytes)-2])
}

func abs(i int) int {
	if i < 0 {
		return i * -1
	}
	return i
}


package main

import "fmt"

func main() {
	var a, ans uint
	fmt.Scanf("%d", &a)
	in3 := (a & 0x8) != 0
	in2 := (a & 0x4) != 0
	in1 := (a & 0x2) != 0
	in0 := (a & 0x1) != 0

	out3 := !in3
	out2 := out3 != in2
	out1 := in1 != (out3 && out2)
	out0 := in0 != (out3 && out2 && out1)

	if out3 {
		ans += 8
	}
	if out2 {
		ans += 4
	}
	if out1 {
		ans += 2
	}
	if out0 {
		ans += 1
	}
	fmt.Printf("%d", ans)

}


package main

import "fmt"

func main() {

	var n, m int
	fmt.Scan(&n, &m)
	knownArray := make([]byte, n)
	prints := make([]bool, 10)

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

	for i := 0; i < m; i++ {
		var singlePrint byte
		fmt.Scan(&singlePrint)
		prints[singlePrint] = true
	}

	for i := 0; i < n; i++ {
		if prints[knownArray[i]] == true {
			fmt.Printf("%d ", knownArray[i])
		}
	}
}


package main

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

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

func scan(a ...interface{}) {
	fmt.Fscan(in, a...)
}
func printf(f string, a ...interface{}) {
	fmt.Fprintf(out, f, a...)
}
func IntPow(n, m int) int {
    if m == 0 {
        return 1
    }
    result := n
    for i := 2; i <= m; i++ {
        result *= n
    }
    return result
}
func solve() {
	var n int
	scan(&n)
	printf("%d\n",IntPow(2,n)-1)
}
func main() {
	defer out.Flush()
	n := 0
	scan(&n)
	for i := 0; i < n; i++ {
		solve()
	}
}


package main

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

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

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

	var count int64
	for i := 3; i <= n; i++ {
		count += int64(i * (i - 1))
	}

	fmt.Println(count)
}


package main
import "fmt"

func mask(a int) int{
	b := 0
	bas := 1
	for a>0{
		if (a%10 == 7 || a%10 == 4){
			b+=bas*(a%10)
			bas*=10
		}
		a/=10
	}
	return b
}

func main (){
	var a, b int
	fmt.Scan(&a, &b)
	for c:= a+1;;c++{
		if(mask(c)==b){
			fmt.Print(c)
			break
		}
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF1515E(in io.Reader, out io.Writer) {
	var n int
	var mod, ans int64
	Fscan(in, &n, &mod)
	inv := make([]int64, n+1)
	inv[1] = 1
	for i := 2; i <= n; i++ {
		inv[i] = (mod - mod/int64(i)) * inv[mod%int64(i)] % mod
	}

	dp := [2][][]int64{}
	for i := range dp {
		dp[i] = make([][]int64, n+1)
		for j := range dp[i] {
			dp[i][j] = make([]int64, n+1)
		}
	}
	dp[1][1][1] = 1
	for i := 2; i <= n; i++ {
		cur, pre := dp[i&1], dp[i&1^1]
		for _, r := range cur {
			for j := range r {
				r[j] = 0
			}
		}
		cur[1][0] = pre[1][1]
		for j := 2; j <= i; j++ {
			for k := 1; k <= j; k++ {
				cur[j][0] += pre[j][k]
			}
			cur[j][0] %= mod
			cur[j][1] = pre[j-1][0] * int64(j) % mod
			for k := 2; k <= j; k++ {
				cur[j][k] = pre[j-1][k-1] * int64(j) * 2 % mod * inv[k] % mod
			}
		}
	}
	for _, r := range dp[n&1] {
		for _, v := range r[1:] {
			ans += v
		}
	}
	Fprint(out, ans%mod)
}

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


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

func main() {
	reader := bufio.NewReader(os.Stdin)
	text, _ := reader.ReadString('\n')
	res, _ := strconv.Atoi(string(text[6]))

	fmt.Printf("%d\n", res % 2)

}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n int
	s := make([]byte, 0, 105)
	for {
		if _, err := fmt.Fscan(reader, &n, &s); err != nil {
			break
		}
		// fmt.Println(n, s)
		ans := len(s)
		for i := 1; i*2-1 < len(s); i++ {
			if bytes.Equal(s[:i], s[i:i*2]) {
				ans = min(ans, i+1+len(s)-i*2)
			}
		}
		fmt.Println(ans)
	}
}

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


package main

import "fmt"

var (
	onRow [15]bool
	onCol [15]bool
	rowN  int
	colN  int
)

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

	var line string
	for i := 0; i < r; i++ {
		fmt.Scan(&line)
		for j := 0; j < c; j++ {
			v := line[j]
			if v == 'S' {
				if !onRow[i] {
					onRow[i] = true
					rowN += 1
				}
				if !onCol[j] {
					onCol[j] = true
					colN += 1
				}
			}
		}
	}

	fmt.Println((r-rowN)*c + (c-colN)*rowN)
}


package main

import (
	"fmt"
	"strings"
)

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

	if strings.ToUpper(w[1:]) == w[1:] && (w[0] >= 'a' && w[0] <= 'z') {
		fmt.Print(strings.ToUpper(w[0:1]) + strings.ToLower(w[1:]))
	} else if strings.ToUpper(w) == w {
		fmt.Print(strings.ToLower(w))
	} else {
		fmt.Print(w)
	}
}


package main

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

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

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

	ok := solve(normalize(s))

	if ok {
		fmt.Println("OK")
	} else {
		fmt.Println("BUG")
	}
}

const N = 110

var vis [2 * N][2 * N]int

func reset(n int) {
	for i := N - n; i <= N+n; i++ {
		for j := N - n; j <= N+n; j++ {
			vis[i][j] = 0
		}
	}
}

func normalize(s string) string {

	for i := len(s); i > 0; i-- {
		if s[i-1] >= 'A' && s[i-1] <= 'Z' {
			return s[:i]
		}
	}
	return ""
}

var dd = []int{-1, 0, 1, 0, -1}

func solve(s string) bool {
	reset(len(s))

	var x, y = N, N
	vis[x][y] = 1
	for i := 0; i < len(s); i++ {
		steps := vis[x][y]
		cur := s[i]
		if cur == 'L' {
			x--
		} else if cur == 'R' {
			x++
		} else if cur == 'U' {
			y++
		} else {
			y--
		}

		if vis[x][y] > 0 {
			return false
		}

		for k := 0; k < 4; k++ {
			u, v := x+dd[k], y+dd[k+1]
			if vis[u][v] > 0 && vis[u][v] != steps {
				return false
			}
		}
		vis[x][y] = steps + 1
	}

	return true
}


package main

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

func main() {
	var a, b int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &a, &b)
	m := min(a, b)
	ans := int64(1)
	for i := 2; i <= m; i++ {
		ans *= int64(i)
	}
	fmt.Println(ans)
}

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


package main

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

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


package main

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

var reader *bufio.Reader

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

var n int

func main() {
	m := make(map[int]int)
	for i := 0; i < 4; i++ {
		fmt.Fscan(reader, &n)
		m[n] = 1
	}

	fmt.Println(4 - len(m))
}


package main

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

func main() {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	s.Scan()
	a := s.Text()
	var c int
	for i:=0; i<len(a) ; i++ {
		b := a[i] - '0'
		if 9 -b < b {
			if i==0 && b==9 {
				c=9
			} else {
				c = int(9 - b)
			}
		} else {
			c=int(b)
		}
		fmt.Print(c)
	}
}


package main

import (
	"fmt"
	//"math"
)

var glasses [][]float32
var n int
var t int
func fill(glassNum int, level int, volume float32) {
	glasses[level][glassNum] += volume
	if glasses[level][glassNum] > 1 {
		remainVolume := glasses[level][glassNum] - 1
		glasses[level][glassNum] = 1
		if level != n - 1 {
			fill(glassNum, level + 1, remainVolume / 2.0)
			fill(glassNum + 1, level + 1, remainVolume / 2.0)
		}
	}
}

func main() {

	//fmt.Print(math.Abs(2 - 1))

	fmt.Scan(&n, &t)

	glasses = make([][]float32, 10)

	for i := range glasses {
		glasses[i] = make([]float32, i + 1)
	}

	for i := 0 ; i < t; i++ {
		fill(0,0,1)
	}

	ans := 0
	for i := range glasses {
		for j := range glasses[i] {
			if glasses[i][j] == 1 {
				ans++
			}
		}
		glasses[i] = make([]float32, i + 1)
	}

	fmt.Print(ans)

}


package main

import (
	"fmt"
	"math"
)

func main() {
	var r, x, y, xp, yp int64

	fmt.Scan(&r, &x, &y, &xp, &yp)

	fmt.Println((int64(math.Ceil(math.Sqrt(float64((xp-x)*(xp-x)+
		(yp-y)*(yp-y))))) + 2*r - 1) / (2 * r))
}


package main

import "fmt"

func main() {
  var (
    n int
    min int
    minIndex int
    height [100]int
  )
  fmt.Scanln(&n)
  for i:=0; i < n; i++ {
    fmt.Scan(&height[i])
  }
  fmt.Scanln()
  min = 1001
  for i:=1; i < n-1; i++ {
    if height[i+1] - height[i-1] < min {
      min = height[i+1] - height[i-1]
      minIndex = i
    }
  }
  for i:=minIndex; i < n-1; i++ {
    height[i] = height[i+1]
  }
  n--
  min = -1
  for i:=0; i < n-1; i++ {
    if height[i+1] - height[i] > min {
      min = height[i+1] - height[i]
    }
  }
  fmt.Println(min)
}


package main

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

func solve() {
    n := readInt()
    a, was := readIntArray(n), make([]bool, n)
    c, ok := []int{}, true
    for i := range a {
        cur, cnt := i, 0
        for !was[cur] {
            was[cur] = true
            cur = a[cur]-1
            cnt++
        }

        if cnt%2 == 0 {
            cnt /= 2
        }

        if cur != i {
            ok = false
        } else {
            if cnt > 0 {
                c = append(c, cnt)
            }
        }
    }
    ans := -1
    if ok {
        ans = 1
        for d := 2; d < 101; d++ {
            mul := 1
            for i := range c {
                curMul := 1
                for c[i]%d == 0 {
                    c[i] /= d
                    curMul *= d
                }
                if curMul > mul {
                    mul = curMul
                }
            }
            ans *= mul
        }
    }
    fmt.Println(ans)
}

// Helpers

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

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

// Math

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

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

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

// IO

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

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

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

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

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

// Sort

type Ints64 []int64

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

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


package main

import "fmt"

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

	pos := a + 1
	if pos < n-b {
		pos = n - b
	}

	fmt.Println(n - pos + 1)
}


package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	for len(s) > 0 && (s[len(s)-1] == '\n' || s[len(s)-1] == '\r') {
		s = s[:len(s)-1]
	}
	return s
}

func main() {
	// STDOUT MUST BE FLUSHED MANUALLY!!!
	defer writer.Flush()

	var n int
	scanf("%d\n", &n)
	var min1, max1, min2, max2, min3, max3 int
	scanf("%d %d\n", &min1, &max1)
	scanf("%d %d\n", &min2, &max2)
	scanf("%d %d\n", &min3, &max3)
	n = n - min1 - min2 - min3
	var ans1 = min1
	var ans2 = min2
	var ans3 = min3
	if n >= 0 && n <= max1-min1 {
		ans1 = min1 + n
		n = 0
	} else if n > max1-min1 {
		ans1 = max1
		n -= max1 - min1
	}

	if n >= 0 && n <= max2-min2 {
		ans2 = min2 + n
		n = 0
	} else if n > max2-min2 {
		ans2 = max2
		n -= max2 - min2
	}

	if n >= 0 && n <= max3-min3 {
		ans3 = min3 + n
		n = 0
	} else if n > max3-min3 {
		ans3 = max3
		n -= max3 - min3
	}
	printf("%d %d %d\n", ans1, ans2, ans3)
}


package main

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

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

	fmt.Println(do(n, primes))
}

func do(n int64, primes []int64) int64 {
	if n == 1 {
		return 1
	} else if n == 2 {
		return 2
	} else if n == 3 {
		return 6
	}

	var max int64
	if n%2 == 1 {
		set := []int64{n, n - 1, n - 2}
		max = mul(set, primes)
	} else if n%3 == 0 {
		set := []int64{n - 1, n - 2, n - 3}
		max = mul(set, primes)
	} else {
		set := []int64{n, n - 1, n - 3}
		max = mul(set, primes)
	}
	return max
}

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

func Init() {
}

func Solve(io *FastIO) {
	N := io.NextInt()
	T := io.NextLine()

	S := []rune(T)
	for d := 2; d <= N; d++ {
		if N % d == 0 {
			reverse(S, 0, d - 1)
		}
	}
	io.Println(string(S))
}

func reverse(S []rune, start, end int) {
	for i, j := start, end; i < j; i, j = i + 1, j - 1 {
		S[i], S[j] = S[j], S[i]
	}
}

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"
	"bytes"
	"fmt"
	"io"
	"os"
	"strconv"
)

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	a := readi()
	b := readi()
	c := readi()
	d := readi()
	e := readi()
	f := readi()

	var c1, c2 int
	if e < f {
		c2 = min(b, min(c, d))
		d -= c2
		c1 = min(a, d)
	} else {
		c1 = min(a, d)
		d -= c1
		c2 = min(b, min(c, d))
	}
	println(e*c1 + f*c2)
}


package main

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

func main(){
	var p1, p2, p3, p4 int
	var a, b int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	w := bufio.NewWriter(os.Stdout)
	r.Scan()
	p1, _ = strconv.Atoi(r.Text())
	r.Scan()
	p2, _ = strconv.Atoi(r.Text())
	r.Scan()
	p3, _ = strconv.Atoi(r.Text())
	r.Scan()
	p4, _ = strconv.Atoi(r.Text())
	r.Scan()
	a, _ = strconv.Atoi(r.Text())
	r.Scan()
	b, _ = strconv.Atoi(r.Text())
	count := 0
	for i:=a; i<=b; i++ {
		if ((((i % p1) % p2) % p3) % p4) == i {
			count += 1
		}
	}
	w.WriteString(strconv.Itoa(count)+"\n")
	w.Flush()
}


package main

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

func main() {
	defer _w.Flush()
	n := ReadInt()
	println(solve(n))
}

func solve(n int) int64 {
	c := circle(n / 2)
	return partition(n) * c * c
}

func partition(n int) int64 {
	return Combination(n, n/2) / 2
}

func circle(n int) int64 {
	if n <= 2 {
		return 1
	}
	return Factorial(n - 1)
}

func Combination(n int, k int) int64 { return Permutation(n, k) / Factorial(k) }
func Factorial(n int) int64          { return Permutation(n, n-1) }
func Permutation(n_ int, r_ int) int64 {
	n, r := int64(n_), int64(r_)
	v := int64(1)
	for i := int64(0); i < r; i++ {
		v *= n - i
	}
	return v
}

var _r, _w = bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)

func print(a ...interface{})            { fmt.Fprint(_w, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(_w, f, a...) }
func println(a ...interface{})          { fmt.Fprintln(_w, a...) }
func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(_r, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }
func ReadInt() (i int)       { Scan(&i); return }
func ReadInts(n int) (a []int) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt())
	}
	return
}
func ReadInt64() (i int64) { Scan(&i); return }
func ReadInt64s(n int) (a []int64) {
	for i := 0; i < n; i++ {
		a = append(a, ReadInt64())
	}
	return
}


package main

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

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

	groupA := make([]int, 5)
	groupB := make([]int, 5)

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

	moves := 0
	for i := 0; i < 5; i++ {
		groupA[i] -= groupB[i]
		if groupA[i]%2 != 0 {
			fmt.Println(-1)
			return
		} else if groupA[i] > 0 {
			moves += groupA[i]
		}
	}
	fmt.Println(moves / 2)
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	t := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
	}
	var AP bool = true
	commonDiff := t[1] - t[0]
	for i := 1; i < n; i++ {
		if t[i] - t[i-1] != commonDiff {
			AP = false
			break
		}
	}
	if AP {
		fmt.Println(t[n-1]+commonDiff)
	}
	if !AP {
		fmt.Println(t[n-1])
	}
}


/*
URL:
https://codeforces.com/problemset/problem/1184/A1
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	r int64
)

func main() {
	r = ReadInt64()

	for x := int64(1); x <= 1000000; x++ {
		tmp := x*x + x + 1
		bunshi := r - tmp
		if bunshi <= 0 || bunshi%(2*x) != 0 {
			continue
		}

		y := bunshi / (2 * x)
		fmt.Println(x, y)
		return
	}

	fmt.Println("NO")
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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


package main

import (
	"fmt"
	"regexp"
)

func main() {

	var (
		count int
		line string
	)

	fmt.Scanf("%d\n", &count)
	fmt.Scanln(&line)

	var re = regexp.MustCompile(`o(go)+`)
	fmt.Println(re.ReplaceAllString(line, "***"))
}


package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n)
	m := make(map[string]int)
	for i:= 0; i < n; i++{
		fmt.Scan(&s)
		m[s] = m[s] + 1
	}
	result := 0
	for _, value := range m{
		if value > result{
			result = value
		}
	}
	fmt.Println(result)
}


package main

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

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

func p(a ...interface{})                { fmt.Fprint(writer, a...) }
func pln(a ...interface{})              { fmt.Fprintln(writer, a...) }
func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }

func scan(a ...interface{})             { fmt.Fscan(reader, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }

func main() {
  defer writer.Flush()

  var a, b int
  scan(&a, &b)

  if b % a !=  0 {
    pln(-1)
    return
  }

  div := b / a
  count := 0

  for div > 1 {
    if div % 2 == 0 {
      div /= 2
      count += 1
    } else if div % 3 == 0 {
      div /= 3
      count += 1
    } else {
      break
    }
  }

  if div == 1 {
    pln(count)
  } else {
    pln(-1)
  }
  return
}


package main

import (
	"fmt"
)

func main() {
	var table[3][3]int

	for i := 0; i < 3; i++ {
		fmt.Scanf("%d %d %d\n", &table[i][0], &table[i][1], &table[i][2])
	}

	var sum int = 0
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			sum = 0
			if i-1 >= 0 {
				sum += table[i-1][j]
			}
			if i+1 < 3 {
				sum += table[i+1][j]
			}
			if j-1 >= 0 {
				sum += table[i][j-1]
			}
			if j+1 < 3 {
				sum += table[i][j+1]
			}
			sum += table[i][j]+1
			fmt.Printf("%d", sum%2)
		}
		fmt.Printf("\n")
	}
}


package main
import "fmt"
import "bufio"
import "os"
import "sort"

var input *bufio.Reader

const N = 200005

type arrs []int

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

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

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

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

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

	arr := make([]arrs, N)
	for i:=0; i<n; i++ {
		var x int
		fmt.Fscanf(input, "%d", &x)
		for cnt:=0; x>=0; x/=2 {
			arr[x] = append(arr[x], cnt)
			cnt++
			if x==0 {
				break
			}
		}
	}

	ans := n*30
	for i:=0; i<N; i++ {
		if len(arr[i])<k {
			continue
		}
		sort.Sort(arr[i])
		cnt := 0
		for j:=0; j<k; j++ {
			cnt += arr[i][j]
		}
		if cnt<ans {
			ans = cnt
		}
	}

	fmt.Println(ans)
}


package main

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

func main() {
	defer out.Flush()

	n := ScanInt()
	a := ScanInts(n)
	P(solv(n, a))

}

func solv(n int, a []int) int {
	dp := make([][]int, n+1)
	for i := 0; i <= n; i++ {
		dp[i] = make([]int, 4)
	}

	for i := 1; i <= n; i++ {
		dp[i][0] = Mx(dp[i-1][0], dp[i-1][1], dp[i-1][2])
		if a[i-1] == 1 || a[i-1] == 3 {
			dp[i][1] = Mx(dp[i-1][0], dp[i-1][2]) + 1
		}
		if a[i-1] == 2 || a[i-1] == 3 {
			dp[i][2] = Mx(dp[i-1][0], dp[i-1][1]) + 1
		}
	}
	return n - Mx(dp[n][0], dp[n][1], dp[n][2])
}

/*********************** I/O ***********************/
var in *bufio.Scanner
var out *bufio.Writer

func init() {
	in = bufio.NewScanner(os.Stdin)
	in.Buffer(make([]byte, 1024), int(1e+9))
	in.Split(bufio.ScanWords)
	out = bufio.NewWriter(os.Stdout)
}

func P(args ...interface{}) {
	print("\n", args...)
}

func PS(args ...interface{}) {
	print(" ", args...)
	print("\n", nil)
}

func print(seperator string, args ...interface{}) {
	for _, arg := range args {
		str := ""
		switch v := arg.(type) {
		case byte:
			str = string(v)
		case rune:
			str = string(v)
		case int:
			str = strconv.Itoa(v)
		case []int:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.Itoa(v[i]) + " ")
			}
			str = sb.String()
		case int64:
			str = strconv.FormatInt(v, 10)
		case []int64:
			sb := strings.Builder{}
			for i := 0; i < len(v); i++ {
				sb.WriteString(strconv.FormatInt(v[i], 10) + " ")
			}
			str = sb.String()
		case string:
			str = v
		default:
			panic("invalid print arg: " + fmt.Sprintf("%v", arg))

		}
		out.WriteString(str + seperator)
	}
}

func ScanWord() string { in.Scan(); return in.Text() }
func ScanWords(n int) []string {
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = ScanWord()
	}
	return s
}
func ScanInt() int { i, _ := strconv.Atoi(ScanWord()); return i }
func ScanInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = ScanInt()
	}
	return a
}

func MnMx(args ...int) (int, int) {
	minVal, maxVal := math.MaxInt32, math.MinInt32
	for _, v := range args {
		if v < minVal {
			minVal = v
		}
		if v > maxVal {
			maxVal = v
		}
	}
	return minVal, maxVal
}
func Mn(args ...int) int { mn, _ := MnMx(args...); return mn }
func Mx(args ...int) int { _, mx := MnMx(args...); return mx }
func LCM(a, b int) int   { return a / GCD(a, b) * b }
func GCD(a, b int) int {
	if a == 0 {
		return b
	}
	return GCD(b%a, a)
}
func Abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}


package main

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

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

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

	n := nextInt64()

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

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

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

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

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

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

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


package main

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

func main() {
	var s string
	fmt.Scan(&s)
	g := "aeiou"
	k := 0
	for _,a := range s {
		if strings.Count(g,string(a)) >0  {
			k++
		}
		n,err := strconv.Atoi(string(a))
		if err==nil && n%2 !=0 {
			k++
		}
	}
	fmt.Println(k)
}


package main
import "fmt"

func abs(n int64) int64 {
    if n>0 {
        return n
    }
    return (-n)
}

func main() {
    var a,b,s int64
    fmt.Scanf("%d%d%d",&a,&b,&s)
    if s>= abs(a)+abs(b) && (s-(abs(a)+abs(b)))%2==0 {
        fmt.Println("Yes")
    } else {
        fmt.Println("No")
    }
}


package main

import (
	"fmt"
)

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

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

	var ok1, ok2 bool
	for size, _ = range ballSize {
		_, ok1 = ballSize[size+1]
		_, ok2 = ballSize[size+2]
		if ok1 && ok2 {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}


package main

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

func solve(s string) string {
	return s
}

func output(i int, ans string) {
	fmt.Printf("Case #%d: %s\n", i, ans)
}

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 1000000), 1000000)

	scanner.Scan()
	x := strings.Split(scanner.Text(), " ")
	a, _ := strconv.Atoi(x[0])
	b, _ := strconv.Atoi(x[1])
	da := 1
	for a >= 0 && b >= 0 {
		a -= da
		b -= (da + 1)
		da += 2
	}

	if a < 0 {
		fmt.Println("Vladik")
	} else {
		fmt.Println("Valera")
	}
}


package main
import "fmt"
var s string
func ispal(r int)bool{
    for i:=0;i<r-1-i;i++{
        if s[i]!=s[r-1-i]{
            return false
        }
    }
    return true
}
func main(){
    fmt.Scanf("%s",&s)
    for i:=len(s);i>0;i--{
        if !ispal(i){
            fmt.Println(i)
            return
        }
    }
    fmt.Println(0)
}


package main

import "fmt"

func main() {
	var k, r, mod uint
	fmt.Scan(&k, &r)
	mod = k % 10
	for i := uint(1); i <= 9; i++ {
		if (i*mod%10) == r || (i*mod%10) == 0 {
			fmt.Println(i)
			return
		}
	}
}


package main

import (
	"fmt"
	"math"
)

var problems, parametres, problem, time int

func score( start, end int, scores, TIME []int ) int{
	var score, time int

	for i := 0; i < problems; i++ {
		time += TIME[i]
		initial := scores[i] - parametres * time

		score += int(math.Max(0, float64(initial)))

	}

	return int(score)
}

func reverse( array []int ) []int {
	for i := 0; i < len(array) / 2; i++ {
		array[i], array[len(array) - i - 1] = array[len(array) - i - 1], array[i]
	}

	return array
}

func main() {
	fmt.Scan(&problems, &parametres)
	var scores, TIME []int

	for i := 0; i < problems; i++ {
		fmt.Scan(&problem)
		scores = append(scores, problem)
	}

	for i := 0; i < problems; i++ {
		fmt.Scan(&time)
		TIME = append(TIME, time)
	}

	var LimakScore, RadewooshScore int

	// Limak Score
	LimakScore = score(0, problems, scores, TIME)
	// Reverse
	scores, TIME = reverse(scores), reverse(TIME)
	// Radewoosh Score
	RadewooshScore = score(problems, 0, scores, TIME)

	if LimakScore > RadewooshScore {
		fmt.Println("Limak")
	} else if LimakScore == RadewooshScore {
		fmt.Println("Tie")
	} else {
		fmt.Println("Radewoosh")
	}
}


package main

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

func solve(t string) string {
	cache := make(map[byte]int)

	for i := range t {
		if isUpper(t[i]) {
			cache[t[i]+32]++
		} else {
			cache[t[i]]++
		}
		if len(cache) == 26 {
			return "YES"
		}
	}
	return "NO"
}

func isUpper(b byte) bool {
	return 65 <= b && b <= 90
}

func main() {
	r := bufio.NewReader(os.Stdin)
	var n int
	var t string
	fmt.Fscanf(r, "%d\n", &n)
	fmt.Fscanf(r, "%s\n", &t)
	fmt.Fprintf(os.Stdout, "%s\n", solve(t))
}


package main

import (
	"fmt"
)

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


package main

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

func main() {
	sc := NewScanner()
	n, a, b, c := sc.NextInt64(), sc.NextInt64(), sc.NextInt64(), sc.NextInt64()
	switch (4 - (n % 4)) % 4{
	case 0:
		fmt.Println(0)
	case 1:
		fmt.Println(min(min(a, b + c), 3 * c))
	case 2:
		fmt.Println(min(min(2 * a, b), 2 * c))
	case 3:
		fmt.Println(min(min(3 * a, c), a + b))
	}

}

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

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

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

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

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

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

	return mp
}

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


package main

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

var local = false
var scanner *bufio.Scanner

func main() {
	setup()
	n := readInt()
	commands := readString()

	total := make(map[byte]int)
	for i := 0; i < n; i++ {
		total[commands[i]]++
	}

	acc := math.Min(float64(total[byte('L')]), float64(total[byte('R')])) * 2
	acc += math.Min(float64(total[byte('U')]), float64(total[byte('D')])) * 2
	fmt.Println(int(acc))
}

func setup() {
	source := os.Stdin
	if local == true {
		file, _ := os.Open("input.txt")
		source = file
	}
	scanner = bufio.NewScanner(source)
	scanner.Split(bufio.ScanWords)
}

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

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


package main

import "fmt"

func main() {
	var input string
	fmt.Scanf("%s", &input)
	ans := 0
	var k int
	fmt.Scanf("%d", &k)
	i := len(input) - 1
	for k > 0 && i >= 0 {
		if input[i] == '0' {
			k--
		} else {
			ans++
			if i == 0 {
				ans = len(input) - 1
			}
		}
		i--
	}
	fmt.Println(ans)
}


package main

import (
	"fmt"
)

const SIDES int64 = 6

func main() {
	var n int64

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

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


package main

import (
	. "fmt"
)

// github.com/EndlessCheng/codeforces-go
func main() {
	var s []byte
	Scan(&s)
	n, ans := len(s), 99
	if n < 2 {
		Print(-1)
		return
	}
	for i := range s {
		for j := range s {
			if i == j {
				continue
			}
			t := make([]byte, n)
			copy(t, s)
			c := 0
			for k := i; k < n-1; k++ {
				t[k], t[k+1] = t[k+1], t[k]
				c++
			}
			k := j
			if j > i {
				k--
			}
			for ; k < n-2; k++ {
				t[k], t[k+1] = t[k+1], t[k]
				c++
			}
			for k = 0; t[k] == '0'; k++ {
			}
			for ; k > 0; k-- {
				t[k], t[k-1] = t[k-1], t[k]
				c++
			}
			if c < ans && (t[n-2]&15*10+t[n-1]&15)%25 == 0 {
				ans = c
			}
		}
	}
	if ans == 99 {
		ans = -1
	}
	Print(ans)
}


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
	var total int64
	total = int64(min1(a,b) + c) * 2
	if(a != b){
		total += 1
	}
	fmt.Fprint(out,int64(total))

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


package main

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

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

	var n, m, k int
	fmt.Fscanf(in, "%d %d %d\n", &n, &m, &k)
	fmt.Println(vusTheCossackAndAContest(n, m, k))
}

func vusTheCossackAndAContest(n, m, k int) string {
	if n <= m && n <= k {
		return "Yes"
	}
	return "No"
}


package main

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

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

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

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

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

func main() {
	defer w.Flush()
	var n int
	s := ""
	for i := 1; i < 1001; i++ {
		s += strconv.Itoa(i)
	}
	for I(&n, "\n") == nil {
		O(string(s[n-1]), "\n")
	}
}


package main

import "fmt"

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


package main

import "fmt"

func main() {
	var x, y, c string

	fmt.Scanf("%s\n%s", &x, &y)

	for i:=0; i < len(x); i++{
		if x[i] == y[i]{
			c += "0"
		}else{
			c += "1"
		}
	}

	fmt.Println(c)
}


package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]byte, 1000000), 1000000)
	scanner.Scan()
	s := strings.Split(scanner.Text(), " ")
	x := []int{}
	for _, v := range s {
		vv, _ := strconv.Atoi(v)
		x = append(x, vv)
	}
	floors := x[1] - x[0]
	if floors < 0 {
		floors = -floors
	}

	elevExtra := x[2] - x[0]
	if elevExtra < 0 {
		elevExtra = -elevExtra
	}

	elevTime := ((floors + elevExtra) * x[4]) + (3 * x[5])
	stairTime := floors * x[3]
	if elevTime <= stairTime {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


package main

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

const M int64 = 998244353
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 sp(x, y int64) int64 {
  var mul, res int64 = x, 1
  for y != 0 {
    if y % 2 != 0 {
      res = (res * mul) % M
    }
    mul = (mul * mul) % M
    y /= 2
  }
  return res
}

func main() {
  defer writer.Flush()
  var n, m, k int
  scanf("%d%d%d", &n, &m, &k)
  fac := make([]int64, n+1)
  fac[0] = 1
  for i := 1; i <= n; i += 1 {
    fac[i] = (fac[i-1] * int64(i)) % M
  }

  sol := fac[n-1]
  sol = (sol * sp(fac[n-1-k], M-2)) % M
  sol = (sol * sp(fac[k], M-2)) % M
  sol = (sol * sp(int64(m-1), int64(k))) % M
  sol = (sol * int64(m)) % M
  printf("%d\n", sol)
}


package main

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

func main() {
	io := NewFastIO(os.Stdin, os.Stdout)
	defer io.Flush()

	const mod = int64(1e9 + 7)

	n := int64(io.NextInt())
	p, f := (mod+1)/2, int64(1)
	for i := int64(1); i <= n; i++ {
		f = f * i % mod
		p = p * 2 % mod
	}
	ans := (f - p + mod) % mod
	io.Println(ans)
}

type FastIO struct {
	*bufio.Reader
	*bufio.Writer
	c [1]byte
}

func NewFastIO(r io.Reader, w io.Writer) *FastIO {
	return &FastIO{Reader: bufio.NewReader(r), Writer: bufio.NewWriter(w)}
}

func (f *FastIO) readC() byte {
	f.Read(f.c[:])
	return f.c[0]
}

func (f *FastIO) NextInt() int {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	neg := false
	if c == '-' {
		neg = true
		c = f.readC()
	}
	n := 0
	for ; '0' <= c && c <= '9'; c = f.readC() {
		n = n*10 + int(c) - '0'
	}
	if neg {
		return -n
	}
	return n
}

func (f *FastIO) NextInts(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = f.NextInt()
	}
	return a
}

func (f *FastIO) Next() string {
	c := f.readC()
	for ; c <= ' '; c = f.readC() {
	}
	var s []byte
	for ; c > ' '; c = f.readC() {
		s = append(s, f.c[0])
	}
	return string(s)
}

func (f *FastIO) Println(a ...interface{}) {
	fmt.Fprintln(f.Writer, a...)
}

func (f *FastIO) Print(a ...interface{}) {
	fmt.Fprint(f.Writer, a...)
}

func (f *FastIO) PrintInts(a ...int) {
	if len(a) > 0 {
		f.Print(a[0])
		for _, x := range a[1:] {
			f.Print(" ", x)
		}
	}
}

func (f *FastIO) PrintlnInts(a ...int) {
	f.PrintInts(a...)
	f.Println()
}


package main

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

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

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

type intPair struct {
	a int64
	b int64
}

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

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

func main() {
	defer writer.Flush()

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

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

	if a == b {
		printf("1\n")
		return
	}

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

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


package main
import (
	"fmt"
	//"sort"
	//"unicode/utf8"
)
func main() {
	var n,a int
	var c string
	flag:= false
	fmt.Scan(&n)
	v:=make([]int,10001)
	for i:=0;i<4;i++ {
		fmt.Scan(&c)
		for j:=0;j<len(c);j++ {
			//fmt.Println(c[j])
			a = int(c[j])- 48
			//fmt.Println(a)
			if a>0 {
				v[a]++
			}
			if a>0 {
				if v[a]>2*n {
				flag=true
			}
			}
		}
	}
	if flag == true {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	encodedString := scanner.Text()
	re := regexp.MustCompile(`(WUB)+`)
	fmt.Print(strings.TrimSpace(re.ReplaceAllString(encodedString, " ")))
}


package main

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

func main() {
	sc := NewScanner()
	A, B, C := sc.NextInt(), sc.NextInt(), sc.NextInt()

	mp := map[int]bool{}
	a := A
	for p := 0; ; p++ {
		a = a * 10

		if _, b := mp[a]; b {
			fmt.Println(-1)
			return
		}
		mp[a] = true
		if a/B == C {
			fmt.Println(p + 1)
			return
		}
		a = a % B

	}

}

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

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

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

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

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

	return mp
}

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


package main
import (
	"bufio"
	. "fmt"
	"io"
	"os"
	//. "strconv" Itoa
)
func max(i int64, j int64) int64 {
	if (i > j) {
		return i;
	} else {
		return j;
	}
}
func min(i int64, j int64) int64 {
	if (i < j) {
		return i;
	} else {
		return j;
	}
}
const (
	INF64 = int64(1e18)
)
func solve(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)

	defer out.Flush()

	p := [2]int64{}
	t := [2]int64{}
	Fscan(in, &p[0], &t[0], &p[1], &t[1])

	var h, s int64
	Fscan(in, &h, &s)

	ans := INF64
	dp := make([]int64, h+1)
	for i := range dp {
		dp[i] = INF64
	}
	dp[0] = 0

	for i := int64(0); i <= h; i++ {
		for j := int64(1); j <= h - i; j++ {
			for k := 0; k < 2; k++ {
				ni := min(h, i + j*(p[k]-s) + j*t[k]/t[k^1]*(p[k^1]-s))
				if ni == h {
					ans = min(ans, dp[i] + j*t[k])
				}
				if j*t[k] >= t[k^1] {
					ni = min(h, i + (j-1)*(p[k]-s) + (j*t[k]/t[k^1] - 1)*(p[k^1]-s) + (p[0]+p[1]-s))
					dp[ni] = min(dp[ni], dp[i] + j*t[k])
				}
			}
		}
	}
	ans = min(ans, dp[h])
	Fprintln(out, ans)
}
func main() { solve(os.Stdin, os.Stdout) }


package main

import (
	"fmt"
)

func main() {
	var input uint64
	fmt.Scanf("%d", &input)
	digits := countDigits(input)
	rem := (input - pow10(digits-1) + 1) * digits
	res := uint64(0)
	for i := uint64(1); i < digits; i++ {
		res += (pow10(i) - pow10(i-1)) * i
	}
	fmt.Println(res + rem)
}

func pow10(n uint64) uint64 {
	if n == 0 {
		return 1
	} else {
		res := uint64(1)
		for ; n > 0; n-- {
			res *= 10
		}
		return res
	}
}

func countDigits(ub uint64) uint64 {
	count := uint64(0)
	for ; ub > 0; ub /= 10 {
		count++
	}
	return count
}


// cf80a project main.go
package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if od(n, m) == m {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}
func od(n, m int) int {
	for i := n + 1; i <= m; i++ {
		d := 0
		for j := 1; j <= i; j++ {
			if i%j == 0 {
				d++
			}
		}
		if d == 2 {
			return i
		}
	}
	return 0
}


package main

import (
  "fmt"
)

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


package main

import (
	"bufio"
	. "fmt"
	"io"
	"io/ioutil"
	"os"
	"strings"
)

func CFc(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()

	// single test case

	var s string
	Fscan(in, &s)

	// a := strings.Split(s, "")

	b := []byte(s)

	// for k := range b {
	// 	Fprint(out, b[k]-'A', " ")
	// }

	if len(b) < 2 {
		Fprint(out, "YES")
	} else {
		result := "YES"
		pre := b[0] - 'A'
		cur := b[1] - 'A'
		for i := 2; i < len(b); i++ {
			if (pre+cur)%26 == b[i]-'A' {
				pre = cur
				cur = b[i] - 'A'
			} else {
				// Fprint(out, cur, "===")
				result = "NO"
				break
			}
		}

		Fprint(out, result)
	}

	// 입력 에러 방지
	_leftData, _ := ioutil.ReadAll(in)
	if _s := strings.TrimSpace(string(_leftData)); _s != "" {
		panic("읽지않은 데이터 발견：\n" + _s)
	}
}

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

// YTELYTELYTEL


package main

import (
        "fmt"
)

var (
        n int
        k int
        t int
)

func main() {
        fmt.Scanf("%d %d %d\n", &n, &k, &t)
        if t <= k {
                fmt.Println(t)
        } else if t >= n {
                fmt.Println(n + k - t)
        } else {
                fmt.Println(k)
        }
}


package main

import "fmt"

func isAeiou(t string) bool {
	if t=="a" || t == "e" || t=="i" || t == "o" || t == "u" {
		return true
	}
	return false
}

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


// 337B-mic
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, c, d, A, B, g int
    fmt.Scan(&a, &b, &c, &d)
    if b*c <= a*d {
        A = (a*d - b*c) * c
        B = a * c * d
    } else {
        A = (b*c - a*d) * d
        B = b * c * d
    }
    if A == 0 {
        fmt.Println("0/1")
        return
    }
    g = gcd(A, B)
    fmt.Print(A / g)
    fmt.Print("/")
    fmt.Print(B / g)
    fmt.Println()
}


package main

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

func main() {
	const b_size int = 4

	reader := bufio.NewReader(os.Stdin)
	re := regexp.MustCompile(`\r?\n`)

	board := [b_size]string{}

	for i := 0; i < b_size; i++ {
		if s, err := reader.ReadString('\n'); err != nil {
			if err == io.EOF {
				break
			} else {
				return
			}
		} else {
			s = re.ReplaceAllString(s, "")
			board[i] = s
		}
	}

	ok := false
	candidate := make([]rune, b_size)
	n := 0

	for i := 0; i < b_size; i++ {
		// Horizontally
		for j := 0; j < b_size; j++ {
			candidate[j] = rune(board[i][j])
		}
		if is_ok(candidate, b_size) {
			ok = true
			break
		}

		// Vertically
		for j := 0; j < b_size; j++ {
			candidate[j] = rune(board[j][i])
		}
		if is_ok(candidate, b_size) {
			ok = true
			break
		}
	}

	if ok {
		fmt.Println("YES")
		return
	}

	dia_array := make([][b_size]rune, (b_size*2-1)*2)
	for j := 0; j < b_size; j++ {
		off0 := j
		off1 := (b_size*2 - 1) + (b_size - j - 1)
		for i := 0; i < b_size; i++ {
			dia_array[i+off0][j] = rune(board[i][j])
			dia_array[i+off1][j] = rune(board[i][j])
		}
	}

	for i := 0; i < (b_size*2-1)*2; i++ {
		n = 0
		for j := 0; j < b_size; j++ {
			if dia_array[i][j] != dia_array[0][b_size-1] {
				candidate[n] = dia_array[i][j]
				n++
			}
		}
		if is_ok(candidate, n) {
			ok = true
			break
		}
	}

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

func is_ok(candidate []rune, n int) bool {
	if n < 3 {
		return false
	} else {
		for e := 3; e <= n; e++ {
			xs := 0
			dots := 0
			for i := e - 3; i < e; i++ {
				if candidate[i] == 'x' {
					xs++
				} else if candidate[i] == '.' {
					dots++
				} else { // 'o'
					continue
				}
			}
			if xs == 2 && dots == 1 {
				return true
			}
		}
	}
	return false
}


package main

import "fmt"

// https://codeforces.com/problemset/problem/750/A
// A. New Year and Hurry
// time limit per test
// 1 second
// memory limit per test
// 256 megabytes
// input
// standard input
// output
// standard output

// Limak is going to participate in a contest on the last day of the 2016. The contest will start at 20:00 and will last four hours, exactly until midnight. There will be n problems, sorted by difficulty, i.e. problem 1 is the easiest and problem n is the hardest. Limak knows it will take him 5·i minutes to solve the i-th problem.

// Limak's friends organize a New Year's Eve party and Limak wants to be there at midnight or earlier. He needs k minutes to get there from his house, where he will participate in the contest first.

// How many problems can Limak solve if he wants to make it to the party?
// Input

// The only line of the input contains two integers n and k (1 ≤ n ≤ 10, 1 ≤ k ≤ 240) — the number of the problems in the contest and the number of minutes Limak needs to get to the party from his house.
// Output

// Print one integer, denoting the maximum possible number of problems Limak can solve so that he could get to the party at midnight or earlier.

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

	minutesLeft := 240 - k

	var nProblems int
	for i := 0; i < n; i++ {
		timeForProblem := (i + 1) * 5
		minutesLeft -= timeForProblem
		if minutesLeft < 0 {
			break
		}
		nProblems++
	}

	_, _ = fmt.Print(nProblems)
}


package main

import "fmt"

import "bytes"
import "io"
import "os"

//import "strings"

var dbg = false

var A = [][]int{
	[]int{0, 1, 2},
	[]int{1, 0, 2},
	[]int{1, 2, 0},
	[]int{2, 1, 0},
	[]int{2, 0, 1},
	[]int{0, 2, 1},
}

func solve() {
	var input bytes.Buffer

	io.Copy(&input, os.Stdin)

	var N, K int64 = 0, 0

	fmt.Fscanf(&input, "%d\n", &N)
	fmt.Fscanf(&input, "%d", &K)

	if dbg {
		fmt.Println(N, K)
		fmt.Println(N%6, K)
	}

	fmt.Println(A[N%6][K])
}

func main() {

	solve()
}


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

package main

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

func Solve(n int) int64 {
	if n%2 == 1 {
		return 0
	}
	return int64(math.Pow(float64(2), float64(n/2)))
}

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

	var n int
	fmt.Fscanf(reader, "%d\n", &n)
	fmt.Fprintf(writer, "%d\n", Solve(n))
}


package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scan(&a, &b)
	switch {
	case a < b:
		fmt.Println(0)
		return
	case a == b:
		fmt.Println("infinity")
		return
	default:
		z, d := 0, a-b
		for i := 1; i*i <= d; i++ {
			if d%i > 0 {
				continue
			}
			if i > b {
				z++
			}
			if d/i > b {
				z++
			}
			if i > b && i*i == d {
				z--
			}
		}
		fmt.Println(z)
	}
}


package main

import "fmt"

func main() {
	var (
		n, a, b, c, d int64
	)
	fmt.Scanf("%d%d%d%d%d", &n, &a, &b, &c, &d)
	fmt.Println(collect(a, b, c, d, n))
}
func collect(a, b, c, d, n int64) int64 {
	num := int64(0)
	xeh := d - a
	xfl := d - a
	xhf := c - b - (d - a)
	for e := int64(1); e <= n; e++ {
		h := e - xeh
		f := h - xhf
		l := f - xfl
		if (h >= 1 && h <= n) && (f >= 1 && f <= n) && (l >= 1 && l <= n) {
			num++
		}
	}
	return num * n
}


package main

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

func main() {
	in := bufio.NewScanner(os.Stdin)
	in.Scan()
	input := strings.Split(in.Text(), " ")
	n, _ := strconv.Atoi(input[0])
	k, _ := strconv.Atoi(input[1])
	in.Scan()
	input = strings.Split(in.Text(), " ")

	maxdel := 0
	for i := 0; i < n; i++ {
		current, _ := strconv.Atoi(input[i])
		if ((k % current == 0) && (current > maxdel)){
		    maxdel = current;
		}
	}
	fmt.Println(k / maxdel)
}


package main

import "fmt"

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

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

func main() {
	b, g, n := 0, 0, 0
	fmt.Scanf("%d\n%d\n%d", &b, &g, &n);

	min_b := max(0, n - g);
	max_b := min(b, n);

	fmt.Printf("%d\n", max_b - min_b + 1);
}


package main

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

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

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

func ReadFloat64() float64 {
    f64, _ := strconv.ParseFloat(ReadString(), 64)
    return f64
}

func ReadInt64() int64 {
    i64, _ := strconv.ParseInt(ReadString(), 10, 64)
    return i64
}

func ReadInt() int {
    return int(ReadInt64())
}

func work(length, index int64, go_left bool) int64 {
    if length == 1 {
        return 0
    }
    mid := length / 2
    if go_left {
        if index < mid {
            return work(mid, index, false) + 1
        } else {
            return work(mid, index-mid, true) + mid*2
        }
    } else {
        if index < mid {
            return work(mid, index, false) + mid*2
        } else {
            return work(mid, index-mid, true) + 1
        }
    }
}

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    h, n := uint64(ReadInt64()), ReadInt64()
    fmt.Fprintln(writer, work(int64(1)<<h, n-1, true))
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF148D(_r io.Reader, _w io.Writer) {
	var W, B int
	Fscan(_r, &W, &B)
	dp := make([][][2]float64, W+1)
	for i := range dp {
		dp[i] = make([][2]float64, B+1)
		for j := range dp[i] {
			dp[i][j] = [2]float64{-1, -1}
		}
	}
	var f func(w, b, who int) float64
	f = func(w, b, who int) (res float64) {
		if w <= 0 {
			if who == 0 {
				return 0
			}
			return 1
		}
		if b <= 0 {
			return 1
		}
		dv := &dp[w][b][who]
		if *dv != -1 {
			return *dv
		}
		defer func() { *dv = res }()
		if who == 0 {
			return (float64(w) + float64(b)*(1-f(w, b-1, 1))) / float64(w+b)
		}
		p := (float64(w)*f(w-1, b-1, 0) + float64(b-1)*f(w, b-2, 0)) / float64(w+b-1)
		return (float64(w) + float64(b)*(1-p)) / float64(w+b)
	}
	Fprintf(_w, "%.10f", f(W, B, 0))
}

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


package main

import (
            "fmt"
            "bytes"
            "strconv"
        )

func Trim(x string, begin, end bool) string {
    var a, b int = 0, len(x) - 1

    if begin {
        for string(x[a]) == "0" && a < b && string(x[a + 1]) != "."{
            a++
        }
    }

    if end {
        for (string(x[b]) == "0" || string(x[b]) == ".") && b > a {
            b--
        }
    }

    return x[a:b + 1]
}

type ExponentialNumber struct {
    n string
    exp string
}

func (e ExponentialNumber) String() string {
    var result string
    var s string = e.n
    var length int = len(s)
    exp, _ := strconv.Atoi(e.exp)
    exp += 1

    var buffer bytes.Buffer

    var fs int = exp
    if fs >= length {
        fs = length

        buffer.WriteString(s)

        for i := 0; i < exp - length; i++ {
            buffer.WriteString("0")
        }

        result = Trim(buffer.String(), true, false)
    } else {
        buffer.WriteString(Trim(s[:fs], true, false))

        var p string = Trim(s[fs:], false, true)
        if p != "0" {
            buffer.WriteString(".")
            buffer.WriteString(p)
        }

        result = buffer.String()
    }

    return result
}

func main() {
    var input string
    fmt.Scanln(&input)
    var a_s string //= fmt.Sprint(a), fmt.Sprint(d)

    var buffer bytes.Buffer

    i := 0
    for i < len(input) {
        if string(input[i]) == "e" {
            break
        }

        if string(input[i]) != "." {
            buffer.WriteByte(input[i])
        }

        i++
    }

    a_s = buffer.String()

    e := ExponentialNumber{a_s, input[i + 1:]}

    fmt.Println(e)
}


package main

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

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

// IO helper functions

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// IO functions

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

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

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

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

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

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

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

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

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

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

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

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

// Simple math functions

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

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

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

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

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

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

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

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

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

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

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

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

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

func main() {
	defer Flush()

	n := readi()
	s := readb()
	_ = n
	var t []byte
	t = append(t, s[0])
	for _, c := range s[1:] {
		j := len(t) - 1
		if is_vowel(c) && is_vowel(t[j]) {
			continue
		}
		t = append(t, c)
	}
	println(string(t))
}

func is_vowel(c byte) bool {
	switch c {
	case 'a', 'e', 'i', 'o', 'u', 'y':
		return true
	}
	return false
}


package main

import (
	"fmt"
)

func main() {
	var n,i int
	a:=make([]int,7)
	fmt.Scan(&n)
	for i=0;i<7;i++ {
		fmt.Scan(&a[i])
	}
	for i=0;n>0;i++ {
		n-=a[i%7]
	}
	n=(i+6)%7+1
	fmt.Println(n)
}


package main

import (
	"fmt"
)

func main() {
	var n int64
	fmt.Scan(&n)
	if n <= 5 {
		if n == 2 || n == 5 {
			fmt.Println("1")
		} else {
			fmt.Println("0")
		}
		return
	}
	lvl0 := (n - 2) / 3
	free := (n - 2) % 3
	have := int64(0)
	if free == 0 {
		have = 0
	} else if free == 2 {
		have = 1
	} else {
		lvl0 -= 2
		if lvl0 < 2 {
			fmt.Println("0")
			return
		}
		have = 2
	}
	ret := 1
	for {
		lvl0 -= have
		have++
		lvl0 -= have
		have++
		lvl0 -= have
		have++
		lvl0 -= 2
		if lvl0 < have {
			break
		}
		ret++
	}
	fmt.Println(ret)
}


package main

import "fmt"

func main() {
	var sh, sm, lh, lm int
	fmt.Scanf("%d:%d\n", &sh, &sm)
	fmt.Scanf("%d:%d", &lh, &lm)

	var ah,am int

	ah = sh - lh
	am = sm - lm

	if am < 0 {
		am = 60 + am
		ah = ah - 1
	}

	if ah < 0 {
		ah = 24 + ah
	}

	if ah < 10 {
		fmt.Printf("0%d:", ah)
	} else {
		fmt.Printf("%d:", ah)
	}

	if am < 10 {
		fmt.Printf("0%d", am)
	} else {
		fmt.Printf("%d", am)
	}
}


package main

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

// github.com/EndlessCheng/codeforces-go
func CF690D2(_r io.Reader, _w io.Writer) {
	in := bufio.NewReader(_r)
	out := bufio.NewWriter(_w)
	defer out.Flush()
	const mod int64 = 1e6 + 3
	fact := func(n int) int64 {
		x := int64(1)
		for i := int64(2); i <= int64(n); i++ {
			x = x * i % mod
		}
		return x
	}
	pow := func(x int64, n int64) int64 {
		res := int64(1)
		for ; n > 0; n >>= 1 {
			if n&1 == 1 {
				res = res * x % mod
			}
			x = x * x % mod
		}
		return res
	}
	inv := func(a int64) int64 { return pow(a, mod-2) }
	frac := func(a, b int64) int64 { return a * inv(b) % mod }

	var n, c int
	Fscan(in, &n, &c)
	Fprint(out, frac(fact(n+c), fact(n)*fact(c)%mod)-1)
}

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


package main

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

func compute(n, v int) (sum int) {
	c := 0
	for i := 1; i <= n; i++ {
		f := n - i
		e := v - c
		if f <= c {
			c = 0
			break
		}

		if e >= f {
			sum += f * i
			c += f
		} else {
			c = v
			sum += e * i
		}
		c--
	}
	return
}

type test struct {
	n, v, result int
}

var pretests = []test{
	test{
		n:      4,
		v:      2,
		result: 4,
	},
	test{
		n:      7,
		v:      6,
		result: 6,
	},
}

// A -
func main() {
	// for _, t := range pretests {
	// 	fmt.Printf("%d  %d", t.result, compute(t.n, t.v))
	// 	fmt.Println()
	// }
	// return
	reader := bufio.NewReader(os.Stdin)
	var (
		n, v int
	)
	fmt.Fscanln(reader, &n, &v)
	fmt.Printf("%d", compute(n, v))
	fmt.Println()
}


package main

import (
	"fmt"
)

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

func min(i, j int) int {
	if i < j {
		return i
	}
	return j
}

func main() {
	var n, pos, l, r int
	fmt.Scan(&n, &pos, &l, &r)

	goright := abs(r - pos)
	goleft := abs(l - pos)
	if l == 1 && r == n {
		fmt.Println(0)
	} else if l == 1 {
		fmt.Println(goright + 1)
	} else if r == n {
		fmt.Println(goleft + 1)
	} else {
		if pos < l {
			fmt.Println(goright + 2)
		} else if pos > r {
			fmt.Println(goleft + 2)
		} else {
			fmt.Println(min(goleft, goright) + r - l + 2)
		}
	}
}


package main

import (
    "fmt"
)

func main() {
    var str string
    fmt.Scan(&str)
    res := 1
    for i := 0; i < len(str); i++ {
        res = (res << 1)
        if str[i] == uint8('7') {
            res = (res ^ 1)
        }
    }
    fmt.Println(res - 1)
}


package main

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

var (
    mod = int64(1000000007)
)

var reader SReader

func main() {
    reader.Init()
	n := reader.ReadInt()
	m := reader.ReadInt()
	k := reader.ReadInt()
	if (k == -1 && n % 2 + m % 2 == 1) {
		fmt.Println("0")
	} else {
		fmt.Println(pow(pow(2, n-1, mod), m-1, mod))
	}

}

// a,b,m > 0
func pow(a, b, m int64) (res int64) {
	res = 1
	a2 := a // base a^1/a^2/a^4...
	for b > 0 {
		if b & 1 == 1 {
			res *= a2
			res %= m
		}

		a2 *= a2
		a2 %= m
		b >>= 1
	}

	return
}

// reader
type SReader struct {
    file *os.File
    scanner *bufio.Scanner
}

func (this *SReader) Init() {
    this.file = os.Stdin
    this.scanner = bufio.NewScanner(this.file)
    this.scanner.Split(bufio.ScanWords)
}

func (this *SReader) ReadInt() int64 {
    this.scanner.Scan()
    n, err:= strconv.ParseInt(this.scanner.Text(), 10, 64)
    if err != nil {
        panic(err)
    }
    return int64(n)
}


package main

import (
	"fmt"
)

func check(k,n uint64) bool  {
	total := n
	tot := uint64(0)
	for n > 0 {
		if k >= n {
			tot += n
			n = 0
		}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 "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	k := ((a + b - 1 ) % n + n) % n + 1
	fmt.Print(k)
}


package main

import (
	"fmt"
)

func main() {
	var s string
	var aCount, otherCount int
	fmt.Scan(&s)
	for _, Rune := range s {
		if Rune == 'a' {
			aCount++
		} else {
			otherCount++
		}
	}
	if aCount > otherCount {
		fmt.Println(aCount + otherCount)
	} else {
		fmt.Println(aCount*2 - 1)
	}
}


package main

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

func main() {
	fsc := NewFastScanner()
	a1, a2 := fsc.NextInt(), fsc.NextInt()
	res := 0
	for {
		a1, a2 = IntMax(a1, a2), IntMin(a1, a2)
		res++
		a2 += 1
		a1 -= 2
		if a1 <= 0 {
			if a1 < 0 {
				res--
			}
			break
		}

	}
	fmt.Println(res)
}

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

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
}


package main

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

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

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

func init() {
	ReadString = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	// r.Buffer(make([]byte, 1024), int(1e+11)) // for AtCoder
	r.Buffer(make([]byte, 1024), int(1e+9)) // for Codeforces
	// Split sets the split function for the Scanner. The default split function is ScanLines.
	// Split panics if it is called after scanning has started.
	r.Split(bufio.ScanWords)

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

/*********** DP sub-functions ***********/

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

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

// NthBit returns nth bit value of an argument.
// n starts from 0.
func NthBit(num, nth int) int {
	return num >> uint(nth) & 1
}

// OnBit returns the integer that has nth ON bit.
// If an argument has nth ON bit, OnBit returns the argument.
func OnBit(num, nth int) int {
	return num | (1 << uint(nth))
}

// OffBit returns the integer that has nth OFF bit.
// If an argument has nth OFF bit, OffBit returns the argument.
func OffBit(num, nth int) int {
	return num & ^(1 << uint(nth))
}

// PopCount returns the number of ON bit of an argument.
func PopCount(num int) int {
	res := 0

	for i := 0; i < 70; i++ {
		if ((num >> uint(i)) & 1) == 1 {
			res++
		}
	}

	return res
}

/*********** Arithmetic ***********/

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

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

// DigitSum returns digit sum of a decimal number.
// DigitSum only accept a positive integer.
func DigitSum(n int) int {
	if n < 0 {
		return -1
	}

	res := 0

	for n > 0 {
		res += n % 10
		n /= 10
	}

	return res
}

// DigitNumOfDecimal returns digits number of n.
// n is non negative number.
func DigitNumOfDecimal(n int) int {
	res := 0

	for n > 0 {
		n /= 10
		res++
	}

	return res
}

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

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

	return s
}

// Kiriage returns Ceil(a/b)
// a >= 0, b > 0
func Kiriage(a, b int) int {
	return (a + (b - 1)) / b
}

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

	if e == 0 {
		return 1
	}

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

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

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

// Gcd returns the Greatest Common Divisor of two natural numbers.
// Gcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Gcd uses the Euclidean Algorithm.
func Gcd(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}
	if a < b {
		a, b = b, a
	}

	// Euclidean Algorithm
	for b > 0 {
		div := a % b
		a, b = b, div
	}

	return a
}

// Lcm returns the Least Common Multiple of two natural numbers.
// Lcd only accepts two natural numbers (a, b >= 1).
// 0 or negative number causes panic.
// Lcd uses the Euclidean Algorithm indirectly.
func Lcm(a, b int) int {
	if a <= 0 || b <= 0 {
		panic(errors.New("[argument error]: Gcd only accepts two NATURAL numbers"))
	}

	// a = a'*gcd, b = b'*gcd, a*b = a'*b'*gcd^2
	// a' and b' are relatively prime numbers
	// gcd consists of prime numbers, that are included in a and b
	gcd := Gcd(a, b)

	// not (a * b / gcd), because of reducing a probability of overflow
	return (a / gcd) * b
}

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

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

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

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

	return string(res)
}

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

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

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

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

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

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

const MOD = 1000000000 + 7
const ALPHABET_NUM = 26
const INF_INT64 = math.MaxInt64
const INF_BIT60 = 1 << 60

var n, m int

var edges []Edge

type Edge struct {
	s, t int
}

func main() {
	n, m = ReadInt2()
	for i := 0; i < m; i++ {
		s, t := ReadInt2()
		s--
		t--
		edges = append(edges, Edge{s, t})
	}

	ans := 0
	patterns := DuplicatePatterns([]int{0, 1, 2, 3, 4, 5}, n)
	for _, p := range patterns {
		A := [6][6]int{}
		for i := 0; i < 6; i++ {
			for j := 0; j < 6; j++ {
				A[i][j] = 1
			}
		}

		cnt := 0
		for _, e := range edges {
			l, r := p[e.s], p[e.t]
			if A[l][r] == 1 {
				A[l][r], A[r][l] = 0, 0
				cnt++
			}
		}
		ChMax(&ans, cnt)
	}

	fmt.Println(ans)
}

// DuplicatePatterns returns all patterns of n^k of elems([]int).
func DuplicatePatterns(elems []int, k int) [][]int {
	return dupliRec([]int{}, elems, k)
}

// DFS function for DuplicatePatterns.
func dupliRec(pattern, elems []int, k int) [][]int {
	if len(pattern) == k {
		return [][]int{pattern}
	}

	res := [][]int{}
	for _, e := range elems {
		newPattern := make([]int, len(pattern))
		copy(newPattern, pattern)
		newPattern = append(newPattern, e)

		res = append(res, dupliRec(newPattern, elems, k)...)
	}

	return res
}

// func dfs(v []int) {
// 	if len(v) == n {
// 		A := [6][6]int{}
// 		for i := 0; i < 6; i++ {
// 			for j := 0; j < 6; j++ {
// 				A[i][j] = 1
// 			}
// 		}

// 		cnt := 0
// 		for _, e := range edges {
// 			l, r := v[e.s], v[e.t]
// 			if A[l][r] == 1 {
// 				A[l][r], A[r][l] = 0, 0
// 				cnt++
// 			}
// 		}
// 		ChMax(&ans, cnt)
// 	} else {
// 		for i := 0; i <= 5; i++ {
// 			tmp := CopySlice(v)
// 			tmp = append(tmp, i)
// 			dfs(tmp)
// 		}
// 	}
// }

// func CopySlice(v []int) []int {
// 	res := make([]int, len(v))
// 	for i := 0; i < len(v); i++ {
// 		res[i] = v[i]
// 	}
// 	return res
// }

// MODはとったか？
// 遷移だけじゃなくて最後の最後でちゃんと取れよ？

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


package main

import (
	"fmt"
	"sort"
)

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

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


package main

import (
	"fmt"
	"math"
	"regexp"
)

func main() {
	var size int
	var file string

	fmt.Scan(&size)
	fmt.Scan(&file)

	reg := regexp.MustCompile("x+")

	slice := reg.FindAllString(file, -1)

	var ans = 0
	for _, val := range slice {
		ans += int(math.Max(0, float64(len(val)-2)))
	}

	fmt.Println(ans)
}


package main

import "fmt"

func check(index int, pos string, k int, n int) bool {
	for i := index; i < n && i >= 0; i += k {
		if pos[i] == '#' {
			return false
		}
		if pos[i] == 'T' {
			return true
		}
	}
	return false
}

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

	var grasspos int
	for i := 0; i < n; i++ {
		if pos[i] == 'G' {
			grasspos = i
			break
		}
	}
	flag := check(grasspos, pos, k, n) || check(grasspos, pos, -k, n)
	if flag {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

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

var local = false
var scanner *bufio.Scanner

func main() {
	setup()
	result := false
	inp := readString()
	zeroes := 0
	for i := len(inp) - 1; i >= 0; i-- {
		if inp[i] == '0' {
			zeroes++
		}

		if inp[i] == '1' && zeroes >= 6 {
			result = true
		}
	}

	if result {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}

func setup() {
	source := os.Stdin
	if local == true {
		file, _ := os.Open("input.txt")
		source = file
	}
	scanner = bufio.NewScanner(source)
	scanner.Split(bufio.ScanWords)
}

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


package main

import "fmt"

func main() {
    var a, b uint64
    fmt.Scan(&a, &b);

    cnt := 0
    ref := uint64(0)
    for bits := 1; ref <= b; bits++ {
        ref = ref*2 + 1
        for i := 0; i < bits-1; i++ {
            ref2 := ref - 1<<uint(i)
            if ref2 >= a && ref2 <= b {
                cnt++
            }
        }
    }
    fmt.Println(cnt)
}


// 402A-mic_rizal
package main

import (
    "fmt"
)

func main() {
    var k, a, b, v, hasil int
    fmt.Scan(&k, &a, &b, &v)
    for a > 0 {
        if b >= k-1 {
            b -= (k - 1)
            a -= v * k
            hasil++
        } else if b != 0 {
            a -= v * (b + 1)
            hasil++
            b = 0
        } else {
            a -= v
            hasil++
        }
    }
    fmt.Println(hasil)
}


package main

import "fmt"

func main() {
    var n,m int
    fmt.Scan(&n,&m)
    ans := 0
    for a := 0; a <= m; a++ {
        for b := 0; b <= n; b++ {
            if ((a*a+b) == n) && ((a+b*b) == m) { ans++ }
        }
    }
    fmt.Println(ans)
}


package main

import (
	"fmt"
)

func main() {
	var n int64
	fmt.Scanf("%d", &n)
	fmt.Printf("%d", n / 2 * 3)
}


// 257B
package main

import (
	"fmt"
)

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

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	fmt.Print(max(n, m)-1, min(n, m))
}


package main

import (
	"fmt"
)

var sto [1005]int

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

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


 package main

 import (
 	"fmt"
 	"math"
 )

 func main() {
 	var x,y,z,t float64
 	fmt.Scan(&x,&y,&z)
 	t= math.Sqrt(x*y*z)
 	t= t/x+t/y+t/z
 	t*=4
 	fmt.Println(t)
 }