package main

import (
	"fmt"
	"sort"
)

var board [][]byte
var max [][]int
var n, m = 0, 0

func findMax() int {
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			if board[i][j] == 'W' {
				a, b, c, d := 0, 0, 0, 0
				if i > 0 && board[i-1][j] == 'P' {
					a = max[i-1][j] + 1
				}
				if j > 0 && board[i][j-1] == 'P' {
					b = max[i][j-1] + 1
				}
				if i < n - 1 && board[i+1][j] == 'P' {
					c = max[i+1][j] + 1
				}
				if j < m - 1 && board[i][j+1] == 'P' {
					d = max[i][j+1] + 1
				}
				var s = []int {a, b, c, d}
				sort.Sort(sort.Reverse(sort.IntSlice(s)))
				max[i][j] = s[0]
			}
		}
	}
	r := 0;
	for i := 0; i < n; i++ {
		for j := 0; j < m; j++ {
			r += max[i][j]
		}
	}
	return r
}

func main() {
	fmt.Scan(&n, &m)
	board = make([][]byte, n)
	max = make([][]int, n)
	for i := 0; i < n; i++ {
		board[i] = make([]byte, m)
		max[i] = make([]int, m)
		var s string
		fmt.Scan(&s)
		for j := 0; j < m; j++ {
			board[i][j] = s[j]
		}
	}
	fmt.Println(findMax())
}


package main

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

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

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

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

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

    n := ReadInt32()
    m := ReadInt32()
    s1 := ReadString()
    s2 := ReadString()
    count := n * m
    a := make([][]int, count)
    for i := 0; i < count; i++ {
        a[i] = make([]int, count)
        a[i][i] = 1
    }

    for i := 0; i < m; i++ {
        if s2[i] == 'v' {
            for j := 0; j < n-1; j++ {
                for k := j + 1; k < n; k++ {
                    a[j*m+i][k*m+i] = 1
                }
            }
        } else {
            for j := n - 1; j > 0; j-- {
                for k := j - 1; k >= 0; k-- {
                    a[j*m+i][k*m+i] = 1
                }
            }
        }
    }

    for i := 0; i < n; i++ {
        if s1[i] == '>' {
            for j := 0; j < m-1; j++ {
                for k := j + 1; k < m; k++ {
                    a[i*m+j][i*m+k] = 1
                }
            }
        } else {
            for j := m - 1; j > 0; j-- {
                for k := j - 1; k >= 0; k-- {
                    a[i*m+j][i*m+k] = 1
                }
            }
        }
    }

    for k := 0; k < count; k++ {
        for i := 0; i < count; i++ {
            for j := 0; j < count; j++ {
                if a[i][k] == 1 && a[k][j] == 1 {
                    a[i][j] = 1
                }
            }
        }
    }

    f := true

    for i := 0; (i < count) && (f); i++ {
        for j := 0; (j < count) && (f); j++ {
            f = a[i][j] != 0
        }
    }

    if f {
        writer.WriteString("YES\n")
    } else {
        writer.WriteString("NO\n")
    }
}


package main

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

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

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

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

var (
    n, m, count int
    row, col    string
    visited     []bool
)

func dfs(i, j int) {
    index := i*m + j
    if i < 0 || j < 0 || i >= n || j >= m || visited[index] {
        return
    }

    visited[index] = true

    if row[i] == '>' {
        dfs(i, j+1)
    } else {
        dfs(i, j-1)
    }

    if col[j] == 'v' {
        dfs(i+1, j)
    } else {
        dfs(i-1, j)
    }
}

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

    n = ReadInt32()
    m = ReadInt32()
    row = ReadString()
    col = ReadString()
    count = n * m
    f := true

    for i := 0; (i < n) && (f); i++ {
        for j := 0; (j < m) && (f); j++ {
            visited = make([]bool, count)
            dfs(i, j)
            for k := 0; (k < count) && (f); k++ {
                f = visited[k]
            }
        }
    }

    if f {
        writer.WriteString("YES\n")
    } else {
        writer.WriteString("NO\n")
    }
}


package main

import (
	"fmt"
)

type Vertex struct {
	neighbors []*Vertex
}

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

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

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

}

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


package main

import (
  "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 gcd(a, b int) int {
  if a == 0 || b == 0 {
    return 1
  }
  if a < 0 {
    a = -a
  }
  if b < 0 {
    b = -b
  }
  for b != 0 {
    a, b = b, a%b
  }
  return a
}

type Fraction struct {
  A, B int
  Invalid bool
}

func makeFraction(a, b int) Fraction {
  if b == 0 {
    return Fraction{ Invalid: true }
  }
  if a == 0 {
    return Fraction{ B: 1 }
  }
  if b < 0 {
    a, b = -a, -b
  }
  g := gcd(a, b)
  return Fraction{ A: a/g, B: b/g }
}

type Line struct {
  A, B, C int
  Slope, Intercept Fraction
  Empty, Plane, Vertical, Horizontal bool
}

func makeLine(a, b, c int) Line {
  line := Line{ A: a, B: b, C: c }
  line.Slope = makeFraction(-a, b)
  line.Intercept = makeFraction(-c, b)
  if a == 0 && b == 0 {
    if c == 0 {
      line.Plane = true
    } else {
      line.Empty = true
    }
  } else if a == 0 {
    line.Horizontal = true
  } else if b == 0 {
    line.Vertical = true
  }
  return line
}

func solve(q, r Line) int {
  if q.Empty || r.Empty {
    return 0
  }
  if q.Plane || r.Plane {
    return -1
  }
  if q.Horizontal && r.Horizontal {
    if q.Intercept == r.Intercept {
      return -1
    }
    return 0
  }
  if q.Vertical && r.Vertical {
    if makeFraction(-q.C, q.A) == makeFraction(-r.C, r.A) {
      return -1
    }
    return 0
  }
  if q.Horizontal || q.Vertical || r.Horizontal || r.Vertical {
    return 1
  }
  if q.Slope == r.Slope {
    if q.Intercept == r.Intercept {
      return -1
    }
    return 0
  }
  return 1
}

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

  q := makeLine(getI(), getI(), getI())
  r := makeLine(getI(), getI(), getI())
  writer.WriteString(fmt.Sprintf("%d\n", solve(q, r)))
}


package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var a1,b1,c1,a2,b2,c2 int
	fmt.Fscanf(reader, "%d %d %d\n", &a1, &b1, &c1)
	fmt.Fscanf(reader, "%d %d %d", &a2, &b2, &c2)

	if a1 * b2 - a2 * b1 != 0 {
		fmt.Printf("1")
	} else if a1 * c2 - a2 * c1 == 0 && b1 * c2 - b2 * c1 == 0{
		if a1 == 0 && a2 == 0 && b1 == 0 && b2 == 0 && (c1 != 0 || c2 != 0) {
			fmt.Printf("0")
		} else {
			fmt.Printf("-1")
		}
	} else {
		fmt.Printf("0")
	}
	return
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	n := 0
	fmt.Fscanf(in, "%d\n", &n)
	if n < 10 {
		fmt.Fprintf(out, "%d\n", n)
		return
	}
	a := make([]int, 0)
	for n > 0 {
		a = append(a, n%10)
		n /= 10
	}
	b := make([]int, len(a))
	for i := 0; i < len(a); i++ {
		b[i] = a[len(a)-i-1]
	}
	ans := 1
	for i := 0; i < len(a); i++ {
		ans *= b[i]
	}
	tmp := 1
	for i := 1; i < len(a); i++ {
		tmp *= 9
	}
	if tmp > ans {
		ans = tmp
	}
	// c := make([]int, len(b))
	// for i := 0; i < len(b); i++ {
	// 	c[i] = b[i]
	// }

	for i := 0; i < len(b); i++ {
		if b[i] > 1 {
			tmp := 1
			for j := 0; j < i; j++ {
				tmp *= b[j]
			}
			tmp *= b[i] - 1
			for j := i + 1; j < len(b); j++ {
				tmp *= 9
			}
			if tmp > ans {
				ans = tmp
			}
		}
	}
	fmt.Fprintf(out, "%d\n", ans)
	return
}

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

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


package main

import (
	"fmt"
	"math"
)

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

func power(a int) (int) {
	if a < 10 {
		return a
	}
	//fmt.Println(a)

	order := int(math.Floor(math.Log10(float64(a))))
	addition := max(a / int(math.Pow10(order)) - 1, 1)
	top := int(math.Pow(9.0, float64(order))) * addition

	//fmt.Println("Versus", top, "order", order, "addition", addition)
	return max(top, (a / int(math.Pow10(order))) * power(a % int(math.Pow10(order))))
}

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


// Author: sighduck
// URL: https://codeforces.com/contest/1143/problem/B

package main

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

func getLength(n int) int {
	length := 0
	for n > 0 {
		n /= 10
		length += 1

	}
	return length
}

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

func product(n int) int64 {
	product := int64(1)
	for n > 0 {
		product *= int64(n % 10)
		n /= 10
	}
	return product
}

func Solve(n int) int64 {
	base := 10
	maxProduct := int64(0)
	for n > 0 {
		maxProduct = max(maxProduct, product(n))
		n -= (n%base + 1)
		base *= 10
	}
	return maxProduct
}

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

var a, b int64
var aDiv, bDiv, sumDiv []int64

func checkDivisor(d []int64, n, div int64) []int64 {
	if n % div == 0 && div * div <= n {
		d = append(d, div)
		q := n / div
		if q * q != n {
			d = append(d, q)
		}
	}
	return d
}

func checkBest(divs []int64, n int64, smaller, bigger int64, best *int64) {
	ld := len(divs)
	l := sort.Search(ld, func(ind int) bool {
		return smaller < divs[ind]
	})
	if l == ld && divs[l - 1] > smaller {
		return
	}
	y := n / divs[l - 1]
	if y <= bigger {
		tmp := 2 * (smaller + bigger)
		if tmp < *best {
			*best = tmp
		}
	}
}

func main() {
	fmt.Scanf("%d %d", &a, &b)
	s := a + b
	aDiv, bDiv, sumDiv = make([]int64, 0), make([]int64, 0), make([]int64, 0)

	for i := int64(1); i*i <= s; i++ {
		aDiv = checkDivisor(aDiv, a, i)
		bDiv = checkDivisor(bDiv, b, i)
		sumDiv = checkDivisor(sumDiv, s, i)
	}

	makeLess := func(s []int64) func(x, y int) bool {
		return func(x, y int) bool {
			return s[x] < s[y]
		}
	}

	sort.Slice(aDiv, makeLess(aDiv))
	sort.Slice(bDiv, makeLess(bDiv))
	sort.Slice(sumDiv, makeLess(sumDiv))

	best := (s + 1) * 2

	for i := 0; i < len(sumDiv); i++ {
		smaller := sumDiv[i]
		if smaller * smaller > s {
			break
		}
		bigger := s / smaller
		checkBest(aDiv, a, smaller, bigger, &best)
		checkBest(bDiv, b, smaller, bigger, &best)
	}

	fmt.Println(best)
}


package main

import (
    "fmt"
    )

func factorize(x int64) (length int, result [50]int64) {
    ri:=0
    reminder:=x
    lastdivider:=int64(2)
    for 1<reminder {
        reminderisprime:=true
        for i:=lastdivider; i*i<=reminder; i++ {
            if reminder%i==0 {
                result[ri]=i
                ri++
                reminder/=i
                lastdivider=i
                reminderisprime=false
                break
            }
        }
        if reminderisprime {
            result[ri]=reminder
            break
        }
    }
    return ri,result
}

func convolute(lng int, x [50]int64) (length int,primes,powers,quotients [15]int64) {
    for i:=0; i<=lng; i++ {
        if x[i]==0 {return}
        if i==0||primes[length-1]!=x[i] {
            primes[length]=x[i]
            quotients[length]=x[i]
            length++
        } else {
            quotients[length-1]*=x[i]
        }
        powers[length-1]++
    }
    return
}

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

    la,da,pa,qa:=convolute(factorize(a))
    lb,db,pb,qb:=convolute(factorize(b))
    lab,dab,pab,qab:=convolute(factorize(a+b))

    var veca,vecb, vec [15]int64

    la--
    lb--
    lab--
    xab:=int64(1)

    min_p:=2*(a+b+1)
MainLoop:
    for {
        for i:=lab; i>=0; i-- {
            vec[i]++
            if pab[i]<vec[i] {
                if i==0 {break MainLoop}
                vec[i]=0
                xab/=qab[i]
            } else {
                xab*=dab[i]
                break
            }
        }
        yab:=(a+b)/xab
        p:=2*(xab+yab)
        if min_p<=p {continue}

        for i:=la; i>=0; i-- {
            veca[i]=0
        }

        xa:=int64(1)

MainLoopA:
        for {
            for i:=la; i>=0; i-- {
                veca[i]++
                if pa[i]<veca[i] {
                    if i==0 {break MainLoopA}
                    veca[i]=0
                    xa/=qa[i]
                } else {
                    xa*=da[i]
                    break
                }
            }
            ya:=a/xa

            if xa<=xab&&ya<=yab||ya<=xab&&xa<=yab {
                min_p=p
                break
            }
        }

        if min_p==p {continue}

        for i:=lb; i>=0; i-- {
            vecb[i]=0
        }

        xb:=int64(1)

 MainLoopB:
        for {
            for i:=lb; i>=0; i-- {
                vecb[i]++
                if pb[i]<vecb[i] {
                    if i==0 {break MainLoopB}
                    vecb[i]=0
                    xb/=qb[i]
                } else {
                    xb*=db[i]
                    break
                }
            }
            yb:=b/xb
            if xb<=xab&&yb<=yab||yb<=xab&&xb<=yab {
                min_p=p
                break
            }
        }

    }
    fmt.Println(min_p)
}


package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)
	var path string
	fmt.Fscanf(reader, "%s\n", &path)
	path = strings.TrimRight(path, "/")
	b := []byte(path)
	if path == "" {
		fmt.Printf("/")
		return
	}
	for i := 0;i < len(b);i ++ {
		if i == 0 || b[i] != '/' || b[i - 1] != '/' {
			fmt.Printf("%c", b[i])
		}
	}

}


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

  s := getS()
  chars := []byte{ s[0] }
  for i := 1; i < len(s); i++ {
    if s[i] != '/' || s[i-1] != '/' {
      chars = append(chars, s[i])
    }
  }
  if len(chars) > 1 && chars[len(chars)-1] == '/' {
    chars = chars[:len(chars)-1]
  }
  writer.WriteString(fmt.Sprintf("%s\n", string(chars)))
}


package main

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

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

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

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

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

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

func solve(n int) {
	var m int
	I(&m, "\n")
	mm := map[int]int{
		1:  31,
		2:  28,
		3:  31,
		4:  30,
		5:  31,
		6:  30,
		7:  31,
		8:  31,
		9:  30,
		10: 31,
		11: 30,
		12: 31,
	}
	ans := (mm[n] + m - 1) / 7
	if (mm[n]+m-1)%7 != 0 {
		ans++
	}
	O(ans, "\n")
}


package main

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

func solve() {
	daysInMonths := []int{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
	m := readInt()
	d := readInt()
	days := daysInMonths[m-1] + d - 1
	weeks := days / 7
	if days%7 != 0 {
		weeks++
	}
	fmt.Println(weeks)
}

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

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

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

var scanner *bufio.Scanner

func init() {
	scanner = bufio.NewScanner(bufio.NewReader(os.Stdin))
	//scanner.Buffer(make([]byte, 311000), 311000)
	scanner.Split(bufio.ScanWords)
}

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

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

func main() {
	N := nextInt()
	data := make([]int, N)
	for i := 0; i < N; i++ {
		data[i] = nextInt()
	}

	del := 0
	start := 0
	for cur := 0; cur < N; cur++ {
		if cur+1 == N || data[cur]+1 != data[cur+1] {
			rem := cur - start - 1
			if start == 0 && cur > 0 && data[1] == 2 {
				rem++
			}

			if cur == N-1 && rem >= 0 && len(data) > 1 && data[len(data)-2] == 999 {
				rem++
			}
			if rem > del {
				//fmt.Println("st", start, "cur", cur, "rem", rem)
				del = rem
			}
			start = cur + 1
		}
	}
	//fmt.Println("xx", del)
	fmt.Println(del)
}


// Group the consecutive elements
// When a group start with 1 or end with 1000, it can contribute "length - 1" items.
// "length - 2" otherwise.
package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	g, cur := [][]int{[]int{-1}}, 0

	for i := 0; i < n; i++ {
		scanner.Scan()
		num, _ := strconv.Atoi(scanner.Text())
		if g[cur][len(g[cur])-1] == num-1 {
			g[cur] = append(g[cur], num)
		} else {
			g = append(g, []int{num})
			cur++
		}
	}

	// sum := 0
	// for _, v := range g {
	// 	if len(v) < 2 {
	// 		continue
	// 	}
	// 	if (v[0] == 1) || (v[len(v)-1] == 1000) {
	// 		sum += len(v) - 1
	// 	} else {
	// 		sum += len(v) - 2
	// 	}
	// }
	// fmt.Println(sum)

	max := 0
	for _, v := range g {
		if len(v) < 2 {
			continue
		}
		l := 0
		if (v[0] == 1) || (v[len(v)-1] == 1000) {
			l = len(v) - 1
		} else {
			l = len(v) - 2
		}
		if l > max {
			max = l
		}
	}
	fmt.Println(max)
}


package main

import (
	"fmt"
	"os"
	"io"
	"bufio"
)
var input io.Reader

func main() {
	var n, k int
	input = bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &n, &k)
	l, r := 0, n
	for l < r {
		mid := l + (r - l) / 2
		d := k
		lines := mid
		for lines < n && mid / d > 0 {
			lines += mid/d
			d *= k
		}
		if lines < n {
			l = mid + 1
		} else {
			r = mid
		}
	}

	fmt.Println(r)
}


package main

import "fmt"

func main(){

	var n int64
	var k int64
	fmt.Scan(&n)
	fmt.Scan(&k)
	var l int64 = 0
	var r int64 = 1000000000
	var good int64 = -1
	for{
		mid := l + (r-l)/2
		cop := mid
		var sum int64 = 0
		for{
			sum += cop
			cop = cop/k
			if cop == 0 {
				break
			}
		}
		if sum >= n {
			good = mid
			r = mid-1
		} else {
			l = mid+1
		}
		if l > r {
			break
		}
	}
	fmt.Print(good,"\n")

}


package main
import (
	"fmt"
)
func main() {
	var n,k,l,h,m,t,ans,s int
	fmt.Scan(&n,&k)
	l=0
	h=n
	for l<=h {
		m=(l+h)>>1
		t=m
		ans=m
		for t!=0 {
			if t<k {
				break
			}
			t/=k
			ans+=t
		}
		if ans<n {
			l=m+1
		} else {
			h=m-1
			s=m
		}
	}
	fmt.Println(s)
}


package main

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

type position struct {
	x, y int
}

func solve() {
	m := readString()
	pos := position{0, 0}
	badpos := make(map[position]bool)

	for _, c := range m {
		if badpos[pos] {
			fmt.Println("BUG")
			return
		}
		badpos[pos] = true

		up := position{pos.x, pos.y + 1}
		down := position{pos.x, pos.y - 1}
		right := position{pos.x + 1, pos.y}
		left := position{pos.x - 1, pos.y}

		switch c {
		case 'U':
			badpos[down] = true
			badpos[left] = true
			badpos[right] = true
			pos = up
			break
		case 'D':
			badpos[up] = true
			badpos[left] = true
			badpos[right] = true
			pos = down
			break
		case 'L':
			badpos[up] = true
			badpos[down] = true
			badpos[right] = true
			pos = left
			break
		case 'R':
			badpos[up] = true
			badpos[down] = true
			badpos[left] = true
			pos = right
			break
		}
	}
	if badpos[pos] {
		fmt.Println("BUG")
		return
	}
	fmt.Println("OK")
}

var scanner *bufio.Scanner

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

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

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

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


package main

import (
	"strings"
	"fmt"
	"strconv"
	"errors"
	"io"
	"unicode/utf8"
	"bytes"
	"os"
)

func main() {
	path := []rune(nextWord())
	x, y := 0, 0
	visited := make(map[int64]bool)
	visited[0] = true
	for _, c := range path {
		switch c {
		case 'U':
			y--
		case 'D':
			y++
		case 'L':
			x--
		case 'R':
			x++
		}
		if _, ok := visited[int64(x * 1000 + y)]; ok {
			printf("BUG\n")
			return
		}
		count := 0
		if _, ok := visited[int64((x - 1) * 1000 + y)]; ok {
			count++
		}
		if _, ok := visited[int64((x + 1) * 1000 + y)]; ok {
			count++
		}
		if _, ok := visited[int64(x * 1000 + y - 1)]; ok {
			count++
		}
		if _, ok := visited[int64(x * 1000 + y + 1)]; ok {
			count++
		}
		if count > 1 {
			printf("BUG\n")
			return
		}
		visited[int64(x * 1000 + y)] = true
	}
	printf("OK\n")
}

var lineScanner *Scanner
var wordScanner *Scanner

func init() {
	lineScanner = NewScanner(os.Stdin)
	wordScanner = NewScanner(strings.NewReader(""))
	wordScanner.Split(ScanWords)
}

func printf(format string, a ...interface{}) {
	fmt.Printf(format, a...)
}
func nextLine() (string, error) {
	if !lineScanner.Scan() {
		if err := lineScanner.Err(); err != nil {
			panic(err)
		}
		return "", errors.New("nextLine: EOF reached")
	}
	return lineScanner.Text(), nil
}

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

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

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

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

// Scanner provides a convenient interface for reading data such as
// a file of newline-delimited lines of text. Successive calls to
// the Scan method will step through the 'tokens' of a file, skipping
// the bytes between the tokens. The specification of a token is
// defined by a split function of type SplitFunc; the default split
// function breaks the input into lines with line termination stripped. Split
// functions are defined in this package for scanning a file into
// lines, bytes, UTF-8-encoded runes, and space-delimited words. The
// client may instead provide a custom split function.
//
// Scanning stops unrecoverably at EOF, the first I/O error, or a token too
// large to fit in the buffer. When a scan stops, the reader may have
// advanced arbitrarily far past the last token. Programs that need more
// control over error handling or large tokens, or must run sequential scans
// on a reader, should use bufio.Reader instead.
//
type Scanner struct {
	r            io.Reader // The reader provided by the client.
	split        SplitFunc // The function to split the tokens.
	maxTokenSize int       // Maximum size of a token; modified by tests.
	token        []byte    // Last token returned by split.
	buf          []byte    // Buffer used as argument to split.
	start        int       // First non-processed byte in buf.
	end          int       // End of data in buf.
	err          error     // Sticky error.
	empties      int       // Count of successive empty tokens.
	scanCalled   bool      // Scan has been called; buffer is in use.
	done         bool      // Scan has finished.
}

// SplitFunc is the signature of the split function used to tokenize the
// input. The arguments are an initial substring of the remaining unprocessed
// data and a flag, atEOF, that reports whether the Reader has no more data
// to give. The return values are the number of bytes to advance the input
// and the next token to return to the user, plus an error, if any. If the
// data does not yet hold a complete token, for instance if it has no newline
// while scanning lines, SplitFunc can return (0, nil, nil) to signal the
// Scanner to read more data into the slice and try again with a longer slice
// starting at the same point in the input.
//
// If the returned error is non-nil, scanning stops and the error
// is returned to the client.
//
// The function is never called with an empty data slice unless atEOF
// is true. If atEOF is true, however, data may be non-empty and,
// as always, holds unprocessed text.
type SplitFunc func(data []byte, atEOF bool) (advance int, token []byte, err error)

// Errors returned by Scanner.
var (
	ErrTooLong = errors.New("bufio.Scanner: token too long")
	ErrNegativeAdvance = errors.New("bufio.Scanner: SplitFunc returns negative advance count")
	ErrAdvanceTooFar = errors.New("bufio.Scanner: SplitFunc returns advance count beyond input")
)

const (
	// MaxScanTokenSize is the maximum size used to buffer a token
	// unless the user provides an explicit buffer with Scan.Buffer.
	// The actual maximum token size may be smaller as the buffer
	// may need to include, for instance, a newline.
	MaxScanTokenSize = 2 * 1024 * 2014

	startBufSize = 4096 // Size of initial allocation for buffer.
)

// NewScanner returns a new Scanner to read from r.
// The split function defaults to ScanLines.
func NewScanner(r io.Reader) *Scanner {
	return &Scanner{
		r:            r,
		split:        ScanLines,
		maxTokenSize: MaxScanTokenSize,
	}
}

// Err returns the first non-EOF error that was encountered by the Scanner.
func (s *Scanner) Err() error {
	if s.err == io.EOF {
		return nil
	}
	return s.err
}

// Bytes returns the most recent token generated by a call to Scan.
// The underlying array may point to data that will be overwritten
// by a subsequent call to Scan. It does no allocation.
func (s *Scanner) Bytes() []byte {
	return s.token
}

// Text returns the most recent token generated by a call to Scan
// as a newly allocated string holding its bytes.
func (s *Scanner) Text() string {
	return string(s.token)
}

// ErrFinalToken is a special sentinel error value. It is intended to be
// returned by a Split function to indicate that the token being delivered
// with the error is the last token and scanning should stop after this one.
// After ErrFinalToken is received by Scan, scanning stops with no error.
// The value is useful to stop processing early or when it is necessary to
// deliver a final empty token. One could achieve the same behavior
// with a custom error value but providing one here is tidier.
// See the emptyFinalToken example for a use of this value.
var ErrFinalToken = errors.New("final token")

// Scan advances the Scanner to the next token, which will then be
// available through the Bytes or Text method. It returns false when the
// scan stops, either by reaching the end of the input or an error.
// After Scan returns false, the Err method will return any error that
// occurred during scanning, except that if it was io.EOF, Err
// will return nil.
// Scan panics if the split function returns 100 empty tokens without
// advancing the input. This is a common error mode for scanners.
func (s *Scanner) Scan() bool {
	if s.done {
		return false
	}
	s.scanCalled = true
	// Loop until we have a token.
	for {
		// See if we can get a token with what we already have.
		// If we've run out of data but have an error, give the split function
		// a chance to recover any remaining, possibly empty token.
		if s.end > s.start || s.err != nil {
			advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)
			if err != nil {
				if err == ErrFinalToken {
					s.token = token
					s.done = true
					return true
				}
				s.setErr(err)
				return false
			}
			if !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				if s.err == nil || advance > 0 {
					s.empties = 0
				} else {
					// Returning tokens not advancing input at EOF.
					s.empties++
					if s.empties > 100 {
						panic("bufio.Scan: 100 empty tokens without progressing")
					}
				}
				return true
			}
		}
		// We cannot generate a token with what we are holding.
		// If we've already hit EOF or an I/O error, we are done.
		if s.err != nil {
			// Shut it down.
			s.start = 0
			s.end = 0
			return false
		}
		// Must read more data.
		// First, shift data to beginning of buffer if there's lots of empty space
		// or space is needed.
		if s.start > 0 && (s.end == len(s.buf) || s.start > len(s.buf) / 2) {
			copy(s.buf, s.buf[s.start:s.end])
			s.end -= s.start
			s.start = 0
		}
		// Is the buffer full? If so, resize.
		if s.end == len(s.buf) {
			// Guarantee no overflow in the multiplication below.
			const maxInt = int(^uint(0) >> 1)
			if len(s.buf) >= s.maxTokenSize || len(s.buf) > maxInt / 2 {
				s.setErr(ErrTooLong)
				return false
			}
			newSize := len(s.buf) * 2
			if newSize == 0 {
				newSize = startBufSize
			}
			if newSize > s.maxTokenSize {
				newSize = s.maxTokenSize
			}
			newBuf := make([]byte, newSize)
			copy(newBuf, s.buf[s.start:s.end])
			s.buf = newBuf
			s.end -= s.start
			s.start = 0
			continue
		}
		// Finally we can read some input. Make sure we don't get stuck with
		// a misbehaving Reader. Officially we don't need to do this, but let's
		// be extra careful: Scanner is for safe, simple jobs.
		for loop := 0; ; {
			n, err := s.r.Read(s.buf[s.end:len(s.buf)])
			s.end += n
			if err != nil {
				s.setErr(err)
				break
			}
			if n > 0 {
				s.empties = 0
				break
			}
			loop++
			if loop > 10 {
				s.setErr(io.ErrNoProgress)
				break
			}
		}
	}
}

// advance consumes n bytes of the buffer. It reports whether the advance was legal.
func (s *Scanner) advance(n int) bool {
	if n < 0 {
		s.setErr(ErrNegativeAdvance)
		return false
	}
	if n > s.end - s.start {
		s.setErr(ErrAdvanceTooFar)
		return false
	}
	s.start += n
	return true
}

// setErr records the first error encountered.
func (s *Scanner) setErr(err error) {
	if s.err == nil || s.err == io.EOF {
		s.err = err
	}
}

// Buffer sets the initial buffer to use when scanning and the maximum
// size of buffer that may be allocated during scanning. The maximum
// token size is the larger of max and cap(buf). If max <= cap(buf),
// Scan will use this buffer only and do no allocation.
//
// By default, Scan uses an internal buffer and sets the
// maximum token size to MaxScanTokenSize.
//
// Buffer panics if it is called after scanning has started.
func (s *Scanner) Buffer(buf []byte, max int) {
	if s.scanCalled {
		panic("Buffer called after Scan")
	}
	s.buf = buf[0:cap(buf)]
	s.maxTokenSize = max
}

// Split sets the split function for the Scanner.
// The default split function is ScanLines.
//
// Split panics if it is called after scanning has started.
func (s *Scanner) Split(split SplitFunc) {
	if s.scanCalled {
		panic("Split called after Scan")
	}
	s.split = split
}

// Split functions

// ScanBytes is a split function for a Scanner that returns each byte as a token.
func ScanBytes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	return 1, data[0:1], nil
}

var errorRune = []byte(string(utf8.RuneError))

// ScanRunes is a split function for a Scanner that returns each
// UTF-8-encoded rune as a token. The sequence of runes returned is
// equivalent to that from a range loop over the input as a string, which
// means that erroneous UTF-8 encodings translate to U+FFFD = "\xef\xbf\xbd".
// Because of the Scan interface, this makes it impossible for the client to
// distinguish correctly encoded replacement runes from encoding errors.
func ScanRunes(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}

	// Fast path 1: ASCII.
	if data[0] < utf8.RuneSelf {
		return 1, data[0:1], nil
	}

	// Fast path 2: Correct UTF-8 decode without error.
	_, width := utf8.DecodeRune(data)
	if width > 1 {
		// It's a valid encoding. Width cannot be one for a correctly encoded
		// non-ASCII rune.
		return width, data[0:width], nil
	}

	// We know it's an error: we have width==1 and implicitly r==utf8.RuneError.
	// Is the error because there wasn't a full rune to be decoded?
	// FullRune distinguishes correctly between erroneous and incomplete encodings.
	if !atEOF && !utf8.FullRune(data) {
		// Incomplete; get more bytes.
		return 0, nil, nil
	}

	// We have a real UTF-8 encoding error. Return a properly encoded error rune
	// but advance only one byte. This matches the behavior of a range loop over
	// an incorrectly encoded string.
	return 1, errorRune, nil
}

// dropCR drops a terminal \r from the data.
func dropCR(data []byte) []byte {
	if len(data) > 0 && data[len(data) - 1] == '\r' {
		return data[0 : len(data) - 1]
	}
	return data
}

// ScanLines is a split function for a Scanner that returns each line of
// text, stripped of any trailing end-of-line marker. The returned line may
// be empty. The end-of-line marker is one optional carriage return followed
// by one mandatory newline. In regular expression notation, it is `\r?\n`.
// The last non-empty line of input will be returned even if it has no
// newline.
func ScanLines(data []byte, atEOF bool) (advance int, token []byte, err error) {
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	if i := bytes.IndexByte(data, '\n'); i >= 0 {
		// We have a full newline-terminated line.
		return i + 1, dropCR(data[0:i]), nil
	}
	// If we're at EOF, we have a final, non-terminated line. Return it.
	if atEOF {
		return len(data), dropCR(data), nil
	}
	// Request more data.
	return 0, nil, nil
}

// isSpace reports whether the character is a Unicode white space character.
// We avoid dependency on the unicode package, but check validity of the implementation
// in the tests.
func isSpace(r rune) bool {
	if r <= '\u00FF' {
		// Obvious ASCII ones: \t through \r plus space. Plus two Latin-1 oddballs.
		switch r {
		case ' ', '\t', '\n', '\v', '\f', '\r':
			return true
		case '\u0085', '\u00A0':
			return true
		}
		return false
	}
	// High-valued ones.
	if '\u2000' <= r && r <= '\u200a' {
		return true
	}
	switch r {
	case '\u1680', '\u2028', '\u2029', '\u202f', '\u205f', '\u3000':
		return true
	}
	return false
}

// ScanWords is a split function for a Scanner that returns each
// space-separated word of text, with surrounding spaces deleted. It will
// never return an empty string. The definition of space is set by
// unicode.IsSpace.
func ScanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	// Skip leading spaces.
	start := 0
	for width := 0; start < len(data); start += width {
		var r rune
		r, width = utf8.DecodeRune(data[start:])
		if !isSpace(r) {
			break
		}
	}
	// Scan until space, marking end of word.
	for width, i := 0, start; i < len(data); i += width {
		var r rune
		r, width = utf8.DecodeRune(data[i:])
		if isSpace(r) {
			return i + width, data[start:i], nil
		}
	}
	// If we're at EOF, we have a final, non-empty, non-terminated word. Return it.
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	// Request more data.
	return start, nil, nil
}


// Author: sighduck
// URL: https://codeforces.com/contest/8/problem/B

package main

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

type Node struct {
	X int
	Y int
}

func getAdjacentNodes(n Node) []Node {
	return []Node{
		Node{X: n.X - 1, Y: n.Y},
		Node{X: n.X + 1, Y: n.Y},
		Node{X: n.X, Y: n.Y - 1},
		Node{X: n.X, Y: n.Y + 1},
	}
}

func Solve(path string) string {
	currentPosition := Node{X: 0, Y: 0}
	visited := make(map[Node]int)
	visited[currentPosition] = 0
	for index, char := range path {
		currentTime := index + 1
		for _, node := range getAdjacentNodes(currentPosition) {
			_, ok := visited[node]
			if !ok {
				visited[node] = currentTime
			}
		}
		s := string(char)
		if s == "L" {
			currentPosition.X -= 1
		} else if s == "R" {
			currentPosition.X += 1
		} else if s == "U" {
			currentPosition.Y += 1
		} else if s == "D" {
			currentPosition.Y -= 1
		}
		time, ok := visited[currentPosition]
		if ok && time < currentTime {
			return "BUG"
		} else if !ok {
			visited[currentPosition] = currentTime + 1
		}
	}
	return "OK"
}

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

	var path string
	fmt.Fscanf(reader, "%s\n", &path)
	fmt.Fprintf(writer, "%s\n", Solve(path))
}


package main

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

var re *regexp.Regexp = regexp.MustCompile("^[0-9a-zA-Z_]{1,16}$")

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var s string
	fmt.Fscanf(reader, "%s", &s)

	segs := strings.Split(s, "@")
	if len(segs) != 2 || !re.Match([]byte(segs[0])) {
		fmt.Printf("NO")
		return
	}
	segs = strings.Split(segs[1], "/")
	if len(segs) > 2 {
		fmt.Printf("NO")
		return
	} else {
		if len(segs[0]) < 1 || len(segs[0]) > 32 {
			fmt.Printf("NO")
			return
		}
		hostnameSegs := strings.Split(segs[0], ".")
		for i := 0;i < len(hostnameSegs);i ++ {
			if !re.Match([]byte(hostnameSegs[i])) {
				fmt.Printf("NO")
				return
			}
		}
		if len(segs) == 2 && !re.Match([]byte(segs[1])) {
			fmt.Printf("NO")
			return
		}
	}
	fmt.Printf("YES")
	return
}


package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin);
	for scanner.Scan() {
		if do_str(scanner.Text()) {
			fmt.Println("YES");
		} else {
			fmt.Println("NO");
		}
	}

}

func isalpha(c rune) bool {
	if c >= 'a' && c <= 'z' {
		return true;
	}
	if c >= 'A' && c <= 'Z' {
		return true;
	}
	return false;
}

func isdigit(c rune) bool {
	if c >= '0' && c <= '9' {
		return true;
	}
	return false;
}

func do_str(s string) bool {
	idx := strings.Index(s, "@");
	if idx == -1 {
		// No "@"
		return false;
	}

	username := s[0:idx];
	if len(username) > 16 || len(username) < 1 {
		return false;
	}

	for _, c := range(username) {
		if isalpha(c) { continue }
		if isdigit(c) { continue }
		if c == '_' { continue }
		return false
	}

	if len(s[idx:]) == 1 {
		return false;
	}
	var resource string;
	var hostname string;

	rest := s[idx+1:]
	idx = strings.Index(rest, "/");
	if idx == -1 {
		resource = "";
		hostname = rest;
	} else {
		resource = rest[idx:];
		if len(resource) == 1 {
			return false;
		}
		resource = rest[idx+1:];
		hostname = rest[0:idx];
	}

	if len(hostname) < 1 || len(hostname) > 32 {
		return false
	}
	for _, c := range(hostname) {
		if isalpha(c) { continue }
		if isdigit(c) { continue }
		if c == '_' { continue }
		if c == '.' { continue }
		return false
	}
	words := strings.Split(hostname, ".");
	for _, word := range(words) {
		if len(word) < 1 || len(word) > 16 {
			return false;
		}
	}
	if len(resource) > 16 {
		return false;
	}
	for _, c := range(resource) {
		if isalpha(c) { continue }
		if isdigit(c) { continue }
		if c == '_' { continue }
		return false
	}

	return true
}


package main

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

var scanner *bufio.Scanner

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

var validChars = "_0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"

func valid(s string) bool {
  if len(s) < 1 || len(s) > 16 {
    return false
  }
  for _, ch := range s {
    if strings.IndexRune(validChars, ch) == -1 {
      return false
    }
  }
  return true
}

func validate(s string) bool {
  if strings.Count(s, "@") != 1 || strings.Count(s, "/") > 1 {
    return false
  }

  parts := strings.Split(s, "@")
  username, hostname := parts[0], parts[1]
  if !valid(username) {
    return false
  }

  if strings.Count(hostname, "/") == 1 {
    parts = strings.Split(hostname, "/")
    hostname = parts[0]
    resource := parts[1]
    if !valid(resource) {
      return false
    }
  }

  parts = strings.Split(hostname, ".")
  for _, part := range parts {
    if !valid(part) {
      return false
    }
  }

  return true
}

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

  s := getS()
  result := "YES"
  if !validate(s) {
    result = "NO"
  }
  writer.WriteString(fmt.Sprintf("%s\n", result))
}


package main

import (
	"fmt"
	"math"
)

func countDivisor(a, b int) int {
	q := a - b
	ret := 0
	sqrtQ := math.Sqrt(float64(q))
	for i := 1; float64(i) < sqrtQ; i++ {
		if q%i != 0 || q/i < b {
			continue
		}
		ret++
		if i <= b {
			continue
		}
		ret++
	}
	if sqrtQ > float64(b) && int(sqrtQ)*int(sqrtQ) == q {
		ret++
	}
	return ret
}

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

	if a < b || (a != b && a-b <= b) {
		fmt.Println(0)
	} else if a == b {
		fmt.Println("infinity")
	} else {
		fmt.Println(countDivisor(a, b))
	}
}


package main

import . "fmt"

// github.com/EndlessCheng/codeforces-go
func main() {
	var a, b, c int
	if Scan(&a, &b); a == b {
		Print("infinity")
		return
	}
	a -= b
	for d := 1; d*d <= a; d++ {
		if a%d == 0 {
			if d > b {
				c++
			}
			if d*d < a && a/d > b {
				c++
			}
		}
	}
	Print(c)
}


package main

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

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

	a      int64
	b      int64
	result int64
)

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

	a = readInt64()
	b = readInt64()
}

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

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

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

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

// Read.

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

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

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

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

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

// Write.

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

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

func printSpace() {
	printString(" ")
}

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

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

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


package main

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

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

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

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

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

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

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

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

}


package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	c := make([]int, n)
	for i, _ := range c {
		fmt.Scan(&c[i])
	}

	min_price := a
	if b < min_price {
		min_price = b
	}
	//fmt.Println(c)
	ans := 0
	for i, _ := range c {
		ri := n - 1 - i
		if i > ri {
			break
		} else if i == ri {
			if c[i] == 2 {
				ans += min_price
			}
		} else {
			if c[i] != 2 && c[ri] != 2 {
				if c[i] != c[ri] {
					ans = -1
					break
				}
			} else if c[i] == 2 && c[ri] != 2 {
				if c[ri] == 0 {
					ans += a
				} else {
					ans += b
				}
			} else if c[ri] == 2 && c[i] != 2 {
				if c[i] == 0 {
					ans += a
				} else {
					ans += b
				}
			} else {
				ans += (min_price * 2)
			}
		}
	}

	fmt.Println(ans)
}


package main

import (
	"fmt"
)

func main() {

	var row int
	var col int

	fmt.Scanln(&row, &col)

	count := (col-1) * row
	if col == 1 {
		count = row-1
	}

	fmt.Println(count)

}


package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	dims := strings.Split(scanner.Text(), " ")
	m, _ := strconv.Atoi(dims[0])
	n, _ := strconv.Atoi(dims[1])
	if n == 1 {
		fmt.Println(m - 1)
	} else {
		fmt.Println(m * (n - 1))
	}
}


package main

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

func main() {
	defer writer.Flush()
	solve()
}

func solve() {
	var n, m int
	scanws(&n, &m)
	if m == 1 {
		printf("%d\n", n-1)
	} else {
		printf("%d\n", n*(m-1))
	}
}

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


package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	scanner.Scan()
	a, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	for i := int64(1); ; i++ {
		s := strconv.FormatInt(a+i, 10)
		for _, ch := range s {
			if ch == '8' {
				writer.WriteString(fmt.Sprintf("%d\n", i))
				return
			}
		}
	}
}


package main

import "fmt"

func main() {
	isHappy := func(x int64) bool {
		if x < 0 {
			x = -x
		}
		for x > 0 {
			if x%10 == 8 {
				return true
			}
			x /= 10
		}
		return false
	}

	var x int64
	fmt.Scan(&x)
	i := int64(1)
	for {
		if isHappy(x + i) {
			break
		}
		i++
	}
	fmt.Println(i)
}


package main

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

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

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

	a := nextInt()

	for i := a + 1; i <= 1000000008; i++ {
		if has8(i) {
			println(i - a)
			break
		}
	}

}

func has8(n int) bool {
	for n > 0 {
		if n % 10 == 8 {
			return true
		}

		n /= 10
	}

	for n < 0 {
		if n % 10 == -8 {
			return true
		}

		n /= 10
	}

	return false
}

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

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

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

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


package main

import (
	"fmt"
	"math"
)

func main() {
	var n, i, j float64
	fmt.Scan(&n)
	for i = 1; i*(i+1)/2 <= n; i++ {
		j = math.Sqrt(n*2 - i*(i+1))
		x := int64(j)
		if x > 0 && x*(x+1)+int64(i)*(int64(i)+1) == int64(n)*2 {
			fmt.Print("YES")
			return
		}
	}
	fmt.Print("NO")
	return
}


//rextester.com:1.6.2--codeforces.com:1.7.3
package main
import("fmt";"math")
func main(){
    var a float64;fmt.Scan(&a);a*=2;b:=false
    for i:=1;i<int(math.Sqrt(a));i++{
        c:=int(a)-i*i-i;d:=int(math.Sqrt(float64(c)))
        if(d*(d+1)==c){b=true}
    }
    if(b){fmt.Print("YES")}else{fmt.Print("NO")}
}


// 192A-ahalim,dikai,eric
package main

import (
	"fmt"
	"math"
)

func main() {
	var i,n,m,k,l,p int64
	fmt.Scan(&n)
	if n==1 {
		fmt.Println("NO")
		return
	}
	l = int64(math.Sqrt(float64(n*2)))
	m = 0
	for i=1;i<=l;i++{
		p = n-i*(i+1)/2
		k = int64((math.Sqrt(float64(8*p+1))-1)/2)
		if k > 0 {
			if k*(k+1)+i*(i+1)== 2*n{
				m =1
				fmt.Println("YES")
				break
			}
		}
	}
	if m == 0{
		fmt.Println("NO")
	}
}


package main

import "fmt"

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

    res := int64(1)
    acum := int64(0)
    first := true
    ones := 0
    for i := 0; i < n; i++ {
        fmt.Scan(&a)
        if a == 1 {
            ones++
            if !first {
                res *= acum + 1
            }
            first = false
            acum = 0
        } else {
            acum++
        }
    }

    if ones == 0 {
        res = 0
    }
    fmt.Println(res)
}


package main

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

const (
	MAXN = 110
)

var N int
var A [MAXN]int

func f(left int) int {
	for i := left; i < N; i++ {
		// fmt.Print(i, A[i])
		if A[i] == 1 {
			return i
		}
	}
	return -1
}
func main() {
	fsc := NewFastScanner()
	N = fsc.NextInt()
	ok := false
	for i := 0; i < N; i++ {
		A[i] = fsc.NextInt()
		if A[i] == 1 {
			ok = true
		}
	}
	var result int64
	result = 1
	var left, right int
	left, right = 0, 0

	for {
		left = f(left)
		right = f(left + 1)
		// fmt.Println(left, right)
		if left == -1 || right == -1 {
			break
		}
		// fmt.Println(left, right)

		result *= int64((right - left))

		left = right
	}
	if ok == false {
		result = 0
	}
	fmt.Println(result)
}

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


package main

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

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

	combination := int64(1)
	gap := 1
	met_first_nut := false
	met_nut := false

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	for i := 0; scanner.Scan(); i++ {
		a, err := strconv.Atoi(scanner.Text())
		if err != nil {
			return
		}

		if a == 0 {
			gap += 1
		} else if a == 1 {
			if !met_first_nut {
				met_first_nut = true
			} else {
				combination *= int64(gap)
			}
			met_nut = true
			gap = 1
		}
	}

	if met_nut {
		fmt.Println(combination)
	} else {
		fmt.Println(0)
	}
}


package main

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

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

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

	n := nextInt()
	a := make([]int, n)
	bribe := 0

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

	idx := max(a[1:]) + 1

	for a[0] <= a[idx] {
		a[0]++
		a[idx]--
		bribe++
		// println(idx, a, bribe)
		idx = max(a[1:]) + 1
	}

	println(bribe)
}

func max(a []int) int {
	idx := 0

	for i := range a {
		if a[i] > a[idx] {
			idx = i
		}
	}

	return idx
}

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

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

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

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

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

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


package main

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

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

	votes := make([]int, n)

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

	bubble_sort(votes, 1, n)

	bribing := 0
	for votes[0] <= votes[1] {
		votes[0]++
		votes[1]--
		bribing++
		if len(votes) > 2 {
			for i := 2; i < n && votes[i-1] < votes[i]; i++ {
				swap(i-1, i, votes)
			}
		}
	}
	fmt.Println(bribing)
}

func swap(a, b int, array []int) {
	array[a], array[b] = array[b], array[a]
}

func bubble_sort(array []int, start, end int) {
	for i := start; i < end; i++ {
		for j := start; j < end; j++ {
			if array[i] > array[j] {
				swap(i, j, array)
			}
		}
	}
}


package main

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

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

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

	n := nextInt()
	s := next()
	// println(s)

	for i := 0; i < n; i++ {
		if s[i] == '*' {
			length := 0

			for j := i + 1; j < n; j++ {
				if s[j] == '*' {
					length = j - i
					// println(i, length)

					if i+length*4 < n &&
						s[i+length*2] == '*' &&
						s[i+length*3] == '*' &&
						s[i+length*4] == '*' {
						println("yes")
						return
					}
				}
			}
		}
	}

	println("no")
}

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

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

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

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

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

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

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


package main

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

var scanner *bufio.Scanner

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

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

  n := getI()
  s := getS()
  for i := range s {
    if s[i] == '.' {
      continue
    }
    jump := 0
    for {
      jump++
      if i + 4*jump >= n {
        break
      }
      okay := true
      for j := 1; j <= 4; j++ {
        if s[i+j*jump] == '.' {
          okay = false
          break
        }
      }
      if okay {
        writer.WriteString("yes\n")
        return
      }
    }
  }
  writer.WriteString("no\n")
}


package main

import (
	"fmt"
)

func main() {
	var n int
	_, err := fmt.Scanf("%d\n", &n)
	var level string
	_, err = fmt.Scanf("%s\n", &level)
	var found = false
	if err == nil {
		for i := 0; i < n && !found; i++ {
			for j := 1; j < n && !found; j++ {
				if i+4*j < n {
					if level[i] == '*' && level[i+1*j] == '*' && level[i+2*j] == '*' && level[i+3*j] == '*' && level[i+4*j] == '*' {
						found = true
					}
				}
			}
		}
	}

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


package main

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

func getInts() []int64 {
	//assumes POSITIVE INTEGERS. Check v for '-' if you have negative.
	var buf []byte
	buf, _ = ioutil.ReadAll(os.Stdin)
	var ints []int64
	num := int64(0)
	found := false
	for _, v := range buf {
		if '0' <= v && v <= '9' {
			num = 10*num + int64(v-'0') //could use bitshifting here.
			found = true
		} else if found {
			ints = append(ints, num)
			found = false
			num = 0
		}
	}
	if found {
		ints = append(ints, num)
		found = false
		num = 0
	}
	return ints
}

const mod = 998244353

func binpow(a, n uint64) (res uint64) {
	res = 1
	for n != 0 {
		if (n & 1) != 0 {
			res *= a
			res %= mod
		}
		a *= a
		a %= mod
		n >>= 1
	}
	return res
}

// http://e-maxx.ru/algo/reverse_element
func inv(a uint64) uint64 {
	return binpow(a, mod-2)
}

func main() {
	ints := getInts()

	n := uint64(ints[0])
	m := uint64(ints[1])

	if n-1 > m {
		fmt.Println(0)
		return
	}

	if n == 2 {
		fmt.Println(0)
		return
	}

	ans := uint64(1)

	// C(m, n-1)
	for i := m; i > n-1; i-- {
		ans *= uint64(i)
		ans %= mod
	}
	for i := m - (n - 1); i > 1; i-- {
		ans *= inv(i)
		ans %= mod
	}

	// * 2^(n-3)
	ans *= binpow(2, n-3)
	ans %= mod

	// * (n-2)
	ans *= n - 2
	ans %= mod

	fmt.Println(ans)
}


package main

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

func main() {
    var n, k int
    var baloons string
    var m = make(map[string]int)

    stdin := bufio.NewReader(os.Stdin)
    fmt.Fscanf(stdin, "%d %d\n", &n, &k)
    fmt.Fscanf(stdin, "%s\n", &baloons)

    // count number of baloon based on color
    for i := 0; i < n; i++ {
        m[string(baloons[i])]++
    }

    isPossible := true
    for _, v := range m {
        if v > k {
            isPossible = false
            break
        }
    }

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


package main

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

const maxInputSize = 512 * 1024 //bytes

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

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

	scanner.Scan()
	k, _ := strconv.Atoi(scanner.Text())
	scanner.Scan()
	s := scanner.Text()

	yes := true
	l := make([]int, 26)

	for i := 0; i < n; i++ {
		l[s[i]-97]++
		if l[s[i]-97] > k {
			yes = false
		}
	}

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


package main

/*
    The idea to solve this problem is by noticing that we need to make sure
    that each friends given baloon by Kefa doesn't get same color more than once.
    Which means the number of baloon of for each color must be the same number
    of Kefa friends or less (because his friends won't be angry if they do not get
    baloon)
*/

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

func main() {
    var n, k int
    var baloons string
    var m = make(map[string]int)

    stdin := bufio.NewReader(os.Stdin)
    fmt.Fscanf(stdin, "%d %d\n", &n, &k)
    fmt.Fscanf(stdin, "%s\n", &baloons)

    // count number of baloon based on color
    for i := 0; i < n; i++ {
        m[string(baloons[i])]++
    }

    isPossible := true
    for _, v := range m {
        if v > k {
            isPossible = false
            break
        }
    }

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


package main

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

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1<<13)
	writer := bufio.NewWriterSize(os.Stdout, 1<<13)
	scn := bufio.NewScanner(reader)
	scn.Scan()
	line := scn.Text()
	n := len(line)

	col := line[n-1]
	row, _ := strconv.ParseInt(line[:n-1], 10, 64)
	row--

	total := (row / 4) * 16

	// Adding the count for the column
	switch col {
	case 'f':
		total++
	case 'e':
		total += 2
	case 'd':
		total += 3
	case 'a':
		total += 4
	case 'b':
		total += 5
	case 'c':
		total += 6
	}

	// Check if it is the second columns to be served in this
	// group:
	if (row%4)&1 == 1 {
		total += 6 + 1
	}

	fmt.Fprintln(writer, total)

	writer.Flush()
}

func ReadInt(reader *bufio.Reader) int {
	b, err := reader.ReadByte()
	for !isValid(b, err) {
		b, err = reader.ReadByte()
	}
	res := 0
	for isValid(b, err) {
		res = res*10 + int(b-'0')
		b, err = reader.ReadByte()
	}
	return res
}

func isValid(b byte, err error) bool {
	return err == nil && '0' <= b && b <= '9'
}


// http://acm.timus.ru/problem.aspx?space=1&num=1741
package main

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

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

const (
	MOD = 1e9 + 7
)

type (

)

func main () {
	var (
		n int64
		place string
	)

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)

	fmt.Fscan(input, &n, &place)

	pcost := map[rune]int64{'f': 1, 'e': 2, 'd': 3, 'a': 4, 'b': 5, 'c': 6}

	n--
	ans := (n / 4) * 16
	ost := (n % 4)

	if ost % 2 != 0 {
		ans += 7 + pcost[rune(place[0])]
	} else {
		ans += pcost[rune(place[0])]
	}

	fmt.Println(ans)
}


package main

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

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

func pos(c byte) int64 {
	s := "fedabc"
	for i := 0; i < 6; i++ {
		if s[i] == c {
			return int64(i)
		}
	}
	return -1
}

func main() {
	bufin = bufio.NewReader(os.Stdin)
	bufout = bufio.NewWriter(os.Stdout)
	defer bufout.Flush()

	var n int64
	var s string

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

	n--
	k := n / 4
	t := k*16 + 1
	if (n%4 == 1) || (n%4 == 3) {
		t += 7
	}
	t += pos(s[0])

	fmt.Fprintf(bufout, "%d\n", t)
}


package main
import (
	"fmt"
)
func main() {
	var n,i int
	fmt.Scan(&n)
	flag:=false
	for i=1;i<=n;i++ {
		if i*(i+1)/2==n {
			flag=true
		}
	}
	if flag==true {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}

}


package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    ans := false
    for i := 1; i <= n; i++ {
        t := (i*(i+1))/2
        if t == n {
            ans = true
            break
        } else if t > n {
            break
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}


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


package main
import (
	"fmt"
)
func main() {
	var n int64
	fmt.Scan(&n)
	for ;n%3==0; {
		n/=3
	}
	fmt.Println(n/3+1)
}


package main

import "fmt"

func main() {
    var n int64
    fmt.Scan(&n)
    for a := int64(1); ; a *= 3 {
        if (n%a) != 0 {
            fmt.Println((n/a)+1)
            break
        }
    }
}


package main

import "fmt"

func Max( x, y int ) int { // math.Max() は問題を起こすらしい。。。
  if x > y {
    return x
  }
  return y
}

func main() {
	var N, K int
	fmt.Scan( &N, &K )
	var S string
	fmt.Scan( &S )
	ypfx := make( []int, N + 1, N + 1 ); // type, length, capacity
	npfx := make( []int, N + 1, N + 1 );
	qpfx := make( []int, N + 1, N + 1 );
	for i := 0; i < N; i++ { // seems like go does not support ++i.....
	  ypfx[ i + 1 ] = ypfx[ i ];
	  npfx[ i + 1 ] = npfx[ i ];
	  qpfx[ i + 1 ] = qpfx[ i ];
	  if( S[ i ] == 'Y' ) {
	    ypfx[ i + 1 ]++;
	  } else if( S[ i ] == 'N' ) {
	    npfx[ i + 1 ]++;
	  } else {
	    qpfx[ i + 1 ]++;
	  }
	}
	original_max := 0;
	for i := 0; i < N; i++ {
	  if( S[ i ] != 'N' ) { // syntax error: missing { after if clause えええええ
	    continue;
	  }
	  j := i;
	  for j < N && S[ j ] == 'N' { // while() はだめなんかい！！
	    j++;
	  }
	  original_max = Max( original_max, j - i );
	  i = j;
	}
	if( original_max > K ) {
	  fmt.Println( "NO" );
	  return;
	}
	for i := 0; i + K <= N; i++ { // i を左界とする長さ K の区間を調べる
	  if( ypfx[ i + K ] - ypfx[ i ] > 0 ) { // ええええ -> line: 34
	    continue;
	  }
	  if( i - 1 >= 0 && S[ i - 1 ] == 'N' ) {
	    continue;
	  }
	  if( i + K < N && S[ i + K ] == 'N' ) {
	    continue;
	  }
	  fmt.Println( "YES" );
	  return;
	}
	fmt.Println( "NO" );
}


package main

import "fmt"

func main() {
	var n, k int
	fmt.Scan(&n, &k)
	var s string
	fmt.Scan(&s)
	ans := 0
	just_max := 0
	for i := 0; i + k  - 1 < n; i++ {
	  was := 0
	  for j := i; j < i + k; j++ {
	    if s[j] == 'Y' {
	      was = 1
	    }
	  }
	  if was == 0 {
	    if i + k >= n || s[i + k] != 'N' {
	      if i - 1 < 0 || s[i - 1] != 'N' {
	        ans = 1
	      }
	    }
	  }
	}
	if ans == 0 {
	  fmt.Println("NO")
	} else {
	  for i := 0; i < n; i++ {
	    cur := 0
	    for j := i; j < n; j++ {
	      if s[j] == 'N' {
	        cur++
	        if just_max < cur {
	          just_max = cur
	        }
	      } else {
	        cur = 0
	      }
	    }
	  }
	  if just_max > k {
	    fmt.Println("NO")
	  } else {
	    fmt.Println("YES")
	  }
	}
}


package main

import "fmt"

func main() {
    var s string
    var n, k int
	fmt.Scan(&n)
	fmt.Scan(&k)
	fmt.Scan(&s)
	var ans = "NO"
	for i := 0; i+k <= n; i++ {
	    var ok = 1
	    for j := 0; j<k; j++{
	        if s[i+j]=='Y'{
	            ok = 0
	        }
	    }
	    if ok==1 {
	        if (i==0 || s[i-1]!='N') && (i==n-k || s[i+k]!='N'){
	            var l = 0
	            for h:=0; h<i; h++{
	                if s[h]=='N'{
	                    l++
	                }else{
	                    l = 0
	                }
	                if l>k{
	                    ok = 0
	                }
	            }
	            l = 0
	            for h:=i+k; h<n; h++{
	                if s[h]=='N'{
	                    l++
	                }else{
	                    l = 0
	                }
	                if l>k{
	                    ok = 0
	                }
	            }
	        }else{
	            ok = 0
	        }
	    }
	    if ok==1{
	        ans = "YES"
	    }
	}

    fmt.Println(ans)
}


package main

import "fmt"

// Retorna slice de slices com as duplas retiradas.
func possiveisJogadas(row []int, num int, x int) [][]int {
	duplas := make([][2]int, 0)

	for i := 0; i+1 <= num-1; i++ {
		if row[i] == x && row[i] == row[i+1] {
			duplas = append(duplas, [2]int{i, i + 1})
		}
	}

	possibilidades := make([][]int, len(duplas))

	for i, v := range duplas {
		copia := make([]int, num)
		copy(copia, row)
		x, y := v[0], v[1]

		possibilidades[i] = append(copia[:x], copia[y+1:]...)

	}

	return possibilidades
}

// Remove um range de um array. [x, y] != [x, y)
func removerElementos(row *[]int, x, y int) {
	*row = append((*row)[:x], (*row)[y+1:]...)
}

func limparRow(row []int) []int {
	i := 1
	grupo := 1
	grupoAchado := false
	for {
		if i >= len(row) {
			if grupo >= 3 {
				removerElementos(&row, i-grupo, i-1)
			}
			break
		}

		if row[i] == row[i-1] {
			grupo++
			if grupo >= 3 {
				grupoAchado = true
			}
		} else {
			if grupoAchado {
				removerElementos(&row, i-grupo, i-1)
				i = 0
				grupoAchado = false

			}
			grupo = 1
		}

		i++
	}

	return row
}

func main() {
	// len(row), num de cores, cor escolhida pelo player.
	var num, k, x int
	fmt.Scan(&num, &k, &x)

	// Criar slice que representa a row.
	row := make([]int, num)
	for i := 0; i < num; i++ {
		fmt.Scan(&row[i])
	}

	// Copia e algoritmos.
	jogadas := possiveisJogadas(row, num, x)

	maior := 0
	for _, jogada := range jogadas {
		cont := num - len(limparRow(jogada))
		if cont > maior {
			maior = cont
		}
	}
	fmt.Println(maior)
}


package main

import "fmt"

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

func score(p, t int) int {
	return max(3*p/10, p-p/250*t)
}

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	m := score(a, c)
	v := score(b, d)
	if m > v {
		fmt.Println("Misha")
	} else if m < v {
		fmt.Println("Vasya")
	} else {
		fmt.Println("Tie")
	}
}


package main

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

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

func score(p, t int) int {
  x, y := 3*p, 10*p - p/25*t
  if x > y {
    return x
  } else {
    return y
  }
}

func main() {
  scanner := bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()
  a := scanInt(scanner)
  b := scanInt(scanner)
  c := scanInt(scanner)
  d := scanInt(scanner)
  misha, vasya := score(a, c), score(b, d)
  if misha > vasya {
    writer.WriteString("Misha\n")
  } else if misha < vasya {
    writer.WriteString("Vasya\n")
  } else {
    writer.WriteString("Tie\n")
  }
}


package main

import (
    "fmt"
)

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

func score(p int, t int) int {
	return max(3 * p / 10, p - p * t / 250)
}

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

	score1 := score(a, c)
	score2 := score(b, d)
	switch {
	case score1 > score2:
		fmt.Printf("Misha\n")
	case score1 < score2:
		fmt.Printf("Vasya\n")
	default:
		fmt.Printf("Tie\n")
	}
}


package main

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

var inf int = 0x3f3f3f3f
var reader *bufio.Reader

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

var s string

func main() {
	fmt.Fscan(reader, &s)
	m := make(map[string]int)
	for i := 0; i <= len(s); i++ {
		for j := 0; j < 26; j++ {
			t := s[0:i] + string(j+'a') + s[i:len(s)]
			m[t] = 1
		}
	}
	fmt.Println(len(m))
}


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)

	s := next()
	m := map[string]bool{}
	cnt := 0

	for i := 0; i <= len(s); i++ {
		for c := 'a'; c <= 'z'; c++ {
			t := s[0:i] + string(c) + s[i:len(s)]

			if checked, haveValue := m[t]; !haveValue && !checked {
				m[t] = true
				cnt++
			}
		}
	}

	println(cnt)
}

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

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

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

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

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

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


package main

import (
	"fmt"
	"math"
)

func min(nums ...int) int {
	res := math.MaxInt32
	for _, num := range nums {
		if num < res {
			res = num
		}
	}
	return res
}

func main() {
	n, m, a, b, countMap := 0, 0, 0, 0, map[int]int{}
	fmt.Scan(&n, &m)

	for i := 0; i < m; i++ {
		fmt.Scan(&a, &b)
		countMap[b] += a
	}

	pointer, result := 10, 0
	for (n > 0) && (pointer > 0) {
		steal := min(n, countMap[pointer])
		result, n, pointer = result+steal*pointer, n-steal, pointer-1
	}

	fmt.Println(result)
}


package main

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

func main() {
	bs, _ := ioutil.ReadAll(os.Stdin)
	reader := bytes.NewBuffer(bs)

	var a, b, f, k int64
	fmt.Fscanf(reader, "%d %d %d %d", &a, &b, &f, &k)

	gas := make([]int64, k+2)
	gas[0], gas[1], gas[k+1] = 0, f, a*k
	for i := int64(2); i <= k; i++ {
		if i%2 == 0 {
			gas[i] = gas[i-1] + (a-f)*2
		} else {
			gas[i] = gas[i-1] + f*2
		}
	}
	pos := int64(0)
	ans := 0
	for pos != k+1 {
		if gas[pos+1]-gas[pos] > b {
			fmt.Printf("-1")
			return
		}
		oil := int64(0)
		for ; pos != k+1; pos++ {
			if oil+gas[pos+1]-gas[pos] > b {
				ans++
				break
			} else {
				oil = oil + gas[pos+1] - gas[pos]
			}
		}
	}
	fmt.Printf("%d", ans)
}


package main

import "fmt"

func main() {
	var a, b, f, k int64
	fmt.Scan(&a, &b, &f, &k)
	start := true
	fue := b
	stops := 0
	for i := 0; i < int(k); i++ {
		dist := f
		if !start {
			dist = a - f
		}
		if fue < dist {
			fmt.Println(-1)
			return
		}
		if fue < a || fue < a+(a-dist) && i+1 != int(k) {
			fue = b - (a - dist)
			stops++
		} else {
			fue -= a
		}
		if fue < 0 {
			fmt.Println(-1)
			return
		}
		start = !start
	}
	fmt.Println(stops)
}


package main

import "fmt"

func main() {
	var a, b, f, k int
	fmt.Scan(&a, &b, &f, &k)
	curFuel := b
	refuelsNeeded := 0
	isInA := false
	for i := k; i > 0; i-- {
		var fuelNeeded int
		if isInA {
			curFuel -= a - f
			if curFuel < 0 {
				fmt.Println("-1")
				return
			}
			if i == 1 {
				fuelNeeded = f
			} else {
				fuelNeeded = 2 * f
			}
			if curFuel < fuelNeeded {
				curFuel = b
				refuelsNeeded++
			}
			if curFuel < fuelNeeded {
				fmt.Println("-1")
				return
			}
			curFuel -= f
			if curFuel < 0 {
				fmt.Println("-1")
				return
			}
		} else {
			curFuel -= f
			if curFuel < 0 {
				fmt.Println("-1")
				return
			}
			if i == 1 {
				fuelNeeded = a - f
			} else {
				fuelNeeded = 2 * (a - f)
			}
			if curFuel < fuelNeeded {
				curFuel = b
				refuelsNeeded++
			}
			if curFuel < fuelNeeded {
				fmt.Println("-1")
				return
			}
			curFuel -= a - f
			if curFuel < 0 {
				fmt.Println("-1")
				return
			}
		}
		isInA = !isInA
	}
	fmt.Printf("%d\n", refuelsNeeded)
}


// Author: sighduck
// URL: https://codeforces.com/contest/1136/problem/B

package main

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

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

func Solve(n int, k int) int {
	return 2*n + 1 + min(n-k, k-1) + n - 1
}

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

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

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


package main

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

type input struct {
  scanner *bufio.Scanner
}

func NewInput() input {
  in := input{scanner: bufio.NewScanner(os.Stdin)}
  in.scanner.Split(bufio.ScanWords)
  return in
}

func (in* input) Token() string {
  in.scanner.Scan()
  return in.scanner.Text()
}

func (in* input) IntToken() int {
  result, _ := strconv.Atoi(in.Token())
  return result
}

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

func Calc(N, k int) int {
  return N + (N + 1) + (k + N - 1)
}

func main() {
  in := NewInput()
  N := in.IntToken()
  k := in.IntToken()
  result := min(Calc(N, k - 1), Calc(N, N - k))
  fmt.Println(result)
}


package main

import (
	"fmt"
)

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

	fmt.Scanln(&n, &k)

	if ((n - k) <= (k - 1)) && (n > 2) {
		cnt = (3 * n) + (n - k)
	} else if ((n - k) > (k - 1)) && (n > 2) {
		cnt = (3 * n) + (k - 1)
	} else {
		cnt = 3 * n
	}

	fmt.Println(cnt)
}


package main

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

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

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

		x += dx
		y += dy

		i++
	}

	return true
}

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

	return false
}

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

	}

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

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

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


package main

import (
	"fmt"
)

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

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

func get_type(l1, r1, l2, r2 int) int {
	if r1 < l2 || r2 < l1 {
		return 0 // 相离
	}

	if l1 == l2 && r1 == r2 {
		return 1 // 相等
	}

	if l1 < l2 && r2 < r1 {
		return 2 // 包含
	}

	if l2 <= l1 && r1 <= r2 {
		return 3 // 被包含
	}

	if l2 <= r1 && r1 <= r2 {
		return 4
	}

	return 5 // 相交
}

func intersect(x1, y1, x2, y2, x3, y3, x4, y4 int) (int, int, int, int) {
	x_type := get_type(x1, x2, x3, x4)
	y_type := get_type(y1, y2, y3, y4)

	if x_type == 0 || y_type == 0 {
		return x1, y1, x2, y2
	} else if x_type == 1 || x_type == 3 {
		if y_type == 1 {
			return -1, -1, -1, -1
		} else if y_type == 2 {
			return x1, y2, x2, y2
		} else if y_type == 3 {
			return -1, -1, -1, -1
		} else if y_type == 4 {
			return x1, y1, x2, y3
		} else { // 5
			return x1, y4, x2, y2
		}
	} else if x_type == 2 {
		return x1, y1, x2, y2
	} else if x_type == 4 {
		if y_type == 1 || y_type == 3 {
			return x1, y1, x3, y2
		} else { // 2, 4, 5
			return x1, y1, x2, y2
		}
	} else { // 5
		if y_type == 1 || y_type == 3 {
			return x4, y1, x2, y2
		} else { // 2, 4, 5
			return x1, y1, x2, y2
		}
	}
}

func main() {
	var xi [6]int
	var yi [6]int
	for i:=0; i < 3; i++ {
		_, _ = fmt.Scan(&xi[2*i], &yi[2*i], &xi[2*i+1], &yi[2*i+1])
	}

	x1, y1, x2, y2 := intersect(xi[0], yi[0], xi[1], yi[1], xi[2], yi[2], xi[3], yi[3])
	if x1 == -1 {
		fmt.Printf("NO")
	} else {
		x1, _, _, _ := intersect(x1, y1, x2, y2, xi[4], yi[4], xi[5], yi[5])
		if x1 == -1 {
			fmt.Printf("NO");
		} else {
			fmt.Printf("YES");
		}
	}
}


// Author: sighduck
// URL: https://codeforces.com/contest/1216/problem/C

package main

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

type Point struct {
	X int
	Y int
}

type Rectangle struct {
	BottomLeft Point
	TopRight   Point
}

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

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

func intersection(R1, R2 Rectangle) Rectangle {
	bottomLeft := Point{
		X: max(R1.BottomLeft.X, R2.BottomLeft.X),
		Y: max(R1.BottomLeft.Y, R2.BottomLeft.Y),
	}
	topRight := Point{
		X: min(R1.TopRight.X, R2.TopRight.X),
		Y: min(R1.TopRight.Y, R2.TopRight.Y),
	}
	if topRight.X <= bottomLeft.X || topRight.Y <= bottomLeft.Y {
		return Rectangle{BottomLeft: Point{0, 0}, TopRight: Point{0, 0}}
	}
	return Rectangle{BottomLeft: bottomLeft, TopRight: topRight}
}

func area(R Rectangle) int64 {
	return int64(R.TopRight.X-R.BottomLeft.X) * int64(R.TopRight.Y-R.BottomLeft.Y)
}

func Solve(R1, R2, R3 Rectangle) string {
	R4 := intersection(R1, R2)
	R5 := intersection(R1, R3)
	R6 := intersection(R4, R5)
	coveredArea := area(R4) + area(R5) - area(R6)
	if area(R1) > coveredArea {
		return "YES"
	}
	return "NO"
}

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

	var R1, R2, R3 Rectangle
	fmt.Fscanf(reader, "%d %d %d %d\n", &R1.BottomLeft.X, &R1.BottomLeft.Y, &R1.TopRight.X, &R1.TopRight.Y)
	fmt.Fscanf(reader, "%d %d %d %d\n", &R2.BottomLeft.X, &R2.BottomLeft.Y, &R2.TopRight.X, &R2.TopRight.Y)
	fmt.Fscanf(reader, "%d %d %d %d\n", &R3.BottomLeft.X, &R3.BottomLeft.Y, &R3.TopRight.X, &R3.TopRight.Y)

	fmt.Fprintf(writer, "%s\n", Solve(R1, R2, R3))
}


package main

import (
    "fmt"
    "bufio"
    "os"
)
var input *bufio.Reader

type Rectangle struct {
    left int64
    down int64
    right int64
    up int64
}

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

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

func area(r Rectangle) int64 {
    var (
        height int64
        width int64
    )
    if r.left < r.right {
        width = r.right - r.left
    }
    if r.down < r.up {
        height = r.up - r.down
    }
    //fmt.Println(height,width)
    return height*width
}

func solve() {
    var (
        x1, y1, x2, y2 int64
        x3, y3, x4, y4 int64
        x5, y5, x6, y6 int64
    )
    fmt.Fscanf(input, "%d %d %d %d\n", &x1, &y1, &x2, &y2)
    fmt.Fscanf(input, "%d %d %d %d\n", &x3, &y3, &x4, &y4)
    fmt.Fscanf(input, "%d %d %d %d\n", &x5, &y5, &x6, &y6)
    // w
    var w Rectangle
    w.up = y2
    w.down = y1
    w.left = x1
    w.right = x2
    //fmt.Printf("%+v\n", w)
    // wb1
    var wb1 Rectangle
    wb1.up = Min(y2, y4)
    wb1.down = Max(y1, y3)
    wb1.left = Max(x1, x3)
    wb1.right = Min(x2, x4)
    //fmt.Printf("%+v\n", wb1)
    // wb2
    var wb2 Rectangle
    wb2.up = Min(y2, y6)
    wb2.down = Max(y1, y5)
    wb2.left = Max(x1, x5)
    wb2.right = Min(x2, x6)
    //fmt.Printf("%+v\n", wb2)
    var inter Rectangle
    inter.up = Min(wb1.up, wb2.up)
    inter.down = Max(wb1.down, wb2.down)
    inter.left = Max(wb1.left, wb2.left)
    inter.right = Min(wb1.right, wb2.right)
    //fmt.Printf("%+v\n", inter)
    // calculate area
    area_w := area(w)
    area_wb1 := area(wb1)
    area_wb2 := area(wb2)
    area_inter := area(inter)
    if area_w > area_wb1 + area_wb2 - area_inter {
        fmt.Println("YES")
    } else {
        fmt.Println("NO")
    }
}

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


// 343A-mic_rizal
package main

import (
    "fmt"
)

func main() {
    var u, v, a int64
    fmt.Scan(&u, &v)
    for u > int64(0) && v > int64(0) {
        if u > v {
            a += (u / v)
            u = u % v
        } else {
            a += (v / u)
            v = v % u
        }
    }
    fmt.Println(a)
}


package main

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

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


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

package main

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

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

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

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

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

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


package main

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

func exp(x int64, a int64) int64 {
	const max int64 = 1000000009
	if x == 0 {
		return 1
	}
	var temp int64 = exp(x/2, (a*a)%max)
	if x%2 == 0 {
		return temp%max
	} else {
		return (temp*a)%max
	}
}

func main(){
	var n, m, k 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)
	r.Scan()
	k, _ = strconv.ParseInt(r.Text(), 0, 64)
	const max int64 = 1000000009
	var x int64 = (m-(n-m)*(k-1))/k
	if x < 0 {
		x = 0
	}
	var res int64 = exp(x, 2)
	var final int64 = (2*k*(res-1))%max+m-(k*x)%max
	final = final%max
	w.WriteString(strconv.FormatInt(final, 10)+"\n")
	w.Flush()
}


package main

import (
	"fmt"
	"math/big"
)

const MOD = 1e9 + 9

var n, m, k int

func pow2(d int) int64 {
	return new(big.Int).Exp(big.NewInt(2), big.NewInt(int64(d)), big.NewInt(MOD)).Int64()
}

func solve() int {
	if n-m >= n/k {
		return m
	}
	pnts := (n - m) * (k - 1)
	n -= (n - m) * k
	pnts = (pnts + int(2*int64(k)*(pow2(n/k)-1+MOD)%MOD)) % MOD
	pnts = (pnts + n%k) % MOD
	return pnts
}

func main() {
	fmt.Scan(&n, &m, &k)
	fmt.Println(solve())
}


package main

import "fmt"

const maxn = 51

func main() {
	var n, k int64
	fmt.Scan(&n, &k)
	fib := make([]int64, maxn)
	fib[0], fib[1] = 1, 1
	for i := int64(2); i < maxn; i++ {
		fib[i] = fib[i-1] + fib[i-2]
	}
	sum := int64(1)
	for i := int64(1); i <= n; i++ {
		if n-i >= 0 && sum+fib[n-i] <= k {
			sum += fib[n-i]
			fmt.Printf("%d %d ", i+1, i)
			i++
		} else {
			fmt.Printf("%d ", i)
		}
	}
}


package main

import (
	"fmt"
)

func main() {
	var n uint64
	fmt.Scanf("%d", &n)
	fmt.Println(3*n*(n+1) + 1)
}


package main

import (
	"fmt"
)

func main() {
	var n int64
	fmt.Scan(&n)
	fmt.Println(6*(n*(n+1))/2 + 1)
}


package main

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

func readInt(scanner *bufio.Scanner) int64 {
	scanner.Scan()
	raw := scanner.Text()
	result, _ := strconv.ParseInt(strings.Trim(raw, " \n\r"), 10, 64)
	return result
}
func check(n int64) int64 {
	return int64(1) + int64(3)*(n*(n+1))
}
func solve(in io.Reader, out io.Writer) {
	reader := bufio.NewScanner(in)
	reader.Split(bufio.ScanWords)

	fmt.Fprintln(out, check(readInt(reader)))
}

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


package main

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

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

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


package main

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

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

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

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

	n -= min1 + min2 + min3

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

	println(min1, min2, min3)
}

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

	return n, min
}

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

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

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

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

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

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


package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	var num int
	fmt.Fscanf(r, "%d\n", &num)

	m := [3][2]int{}
	res := [3]int{}
	for i := 0; i < 3; i++ {
		fmt.Fscanf(r, "%d %d\n", &m[i][0], &m[i][1])

		num -= m[i][0]
		res[i] = m[i][0]
	}

	for i := 0; i < 3 && num > 0; i++ {
		diff := m[i][1] - m[i][0]
		num -= diff
		if num < 0 {
			diff += num
		}
		res[i] += diff
	}

	fmt.Println(res[0], res[1], res[2])

}


package main

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

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

func main() {
    bufin = bufio.NewReader(os.Stdin)
    bufout = bufio.NewWriter(os.Stdout)
    defer bufout.Flush()

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

    var a []int = []int{y, y, y}
    res := 0

    i := 0
    j := 1
    k := 2

    for (a[i] < x) || (a[j] < x) || (a[k] < x) {
        res++
        a[k] = a[i] + a[j] - 1
        if a[k] > x {
            a[k] = x
        }
        i, j, k = j, k, i
    }

    fmt.Fprintf(bufout, "%d\n", res)
}


package main

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

import "strings"

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

	x, _ := strconv.ParseInt(s[0], 10, 64)
	y, _ := strconv.ParseInt(s[1], 10, 64)
	if y > x {
		t := x
		x = y
		y = t
	}
	t := []int64{y, y, y}
	sec := 0
	for t[2] != x {
		v := t[0] + t[1] - 1
		if v >= x {
			v = x
		}
		t[2] = t[1]
		t[1] = t[0]
		t[0] = v
		sec += 1
	}
	fmt.Println(sec)
}


// http://codeforces.com/contest/712/problem/C
package main

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

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

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

	return b
}

func check(m [3]int, val int) bool {
	return m[0] >= val && m[1] >= val && m[2] >= val
}

func main() {
	var x, y int

	//f, _ := os.Open("input.txt")
	//input := bufio.NewReader(f)
	input := bufio.NewReader(os.Stdin)
	fmt.Fscanln(input, &x, &y)
	if x == y {
		fmt.Println("0")
		return
	}

	tr := [3]int{y, y, y}

	idx := 0
	ans := 0

	for {
		if tr[idx] >= x {
			idx = (idx + 1) % 3
			continue
		}

		ans++
		tr[idx] = min(int(math.Abs(float64(tr[(idx + 1) % 3] + tr[(idx + 2) % 3]))) - 1, x)
		if tr[idx] >= x {
			if check(tr, x) {
				break
			}
		}

		idx = (idx + 1) % 3

	}

	fmt.Println(ans)
}


package main
import "fmt"
func main(){
    a,m:= 0,1
    ma:=make(map[int]int)
    fmt.Scan(&a,&m)
    for true{
        _,ok:=ma[a];
        if ok{
            break
        }
        ma[a]=1;
        a*=2
        a%=m;
    }
    if _,ok:=ma[0];ok{
        fmt.Println("Yes")
    } else{
        fmt.Println("No")
    }
}


package main

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

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

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

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

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

func main() {
    defer writer.Flush()
    scanner.Split(bufio.ScanWords)
    a := ReadInt32()
    m := ReadInt32()
    f := false
    d := make(map[int]bool)

    for {
        q := a % m
        if q == 0 {
            f = true
            break
        } else if _, r := d[q]; r {
            f = false
            break
        } else {
            d[q] = true
            a += q
        }
    }

    if f {
        writer.WriteString("Yes\n")
    } else {
        writer.WriteString("No\n")
    }
}


package main

import (
	"fmt"
)

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

	check := func() string {
		visited := make(map[int]bool)
		for {
			switch {
			case visited[a%m]:
				return "No"
			case a%m == 0:
				return "Yes"
			default:
				visited[a%m] = true
				a += a % m
			}
		}
	}

	fmt.Println(check())
}


package main

import (
	"fmt"
)

func main() {
	var a, m int
	fmt.Scan(&a, &m)
	var v [100010]bool
	for {
		if v[a] {
			fmt.Println("No")
			return
		}
		if a%m == 0 {
			fmt.Println("Yes")
			return
		}
		v[a] = true
		a = (a + a%m) % m
	}
}


package main

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

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

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

	a, m := int64(nextInt()), int64(nextInt())
	mods := make([]int64, m)
	mod := int64(a % m)

	for {
		if mod == 0 {
			println("Yes")
			break
		}

		if mods[mod] == 1 {
			println("No")
			break
		} else {
			mods[mod] = 1
			a += mod
			mod = a % m
		}
	}
}

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

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

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

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


// MIT License
//
// Copyright (c) 2017 Nobi Hoang <nobi.hoa@gmail.com>
//
// http://codeforces.com/problemset/problem/673/A
//

package main

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

// ReadLine reads a line from the command line.
// It returns the line and an error if that fails.
func ReadLine() (string, error) {
  line, err := bufio.NewReader(os.Stdin).ReadString('\n')
  if err != nil {
    return "", err
  }
  return strings.TrimSpace(string(line)), nil
}

func check(a []int, n int) int {
  if a[0] > 15 {
    return 15
  }

  time := 0
  for i := 0; i < n; i++ {
    if time + 15 < a[i] {
      return time + 15
    }
    time = a[i]
  }

  if time + 15 > 90 {
    time = 90
  } else {
    time += 15
  }

  return time
}

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

  var a = make([]int, n)
  s, _ := ReadLine()
  for i, str := range strings.Split(s, " ") {
    num, _ := strconv.Atoi(str)
    a[i] = num
  }

  fmt.Println(check(a, n))
}

func main() {
  Execute()
}


package main

import "fmt"

func main() {
    var c,p,n,r int
    r=90
    fmt.Scan(&c)
    for i:=0; i<c; i++ {
        fmt.Scan(&n)
        if n-p>15 {
            r=p+15
            break
        } else {
            p=n
        }
    }
    if 90-p>15 {
        r=p+15
    }
    fmt.Println(r)
}


	package main
	import(
		"fmt"
		"bufio"
		"os"
		"strings"
		"strconv"
	)
	func main(){
		scanner := bufio.NewScanner(os.Stdin)
		scanner.Scan()
		times := scanner.Text()
		scanner.Scan()
		m := scanner.Text()
		if times == "1"{
			intminute,_ := strconv.Atoi(m)
			if intminute > 15 {
				fmt.Println(15)
			}else{
				fmt.Println(intminute + 15)
			}
		}else{
			minutes := strings.Split(m," ")
			for i := 1; i < len(minutes); i++{
				a,_ := strconv.Atoi(minutes[i-1])
				b,_ := strconv.Atoi(minutes[i])
				if i == 1{
					if a > 15{
						fmt.Println(15)
						break
					}
				}
				if b - a > 15{
					fmt.Println(a+15)
					break
				}else{
					if i == len(minutes) -1{
						if b + 15 > 90{
							fmt.Println(90)
						}else{
							fmt.Println(b + 15)
						}
					}
				}
			}

		}
	}


package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scanf("%d\n%s", &n, &s)
	b := []byte(s)
	for i := 1;i <= n;i ++ {
		if n % i == 0 {
			for l, r := 0, i - 1;l < r; l, r = l + 1, r - 1 {
				b[l], b[r] = b[r], b[l]
			}
		}
	}
	fmt.Printf("%s", string(b))
}


package main

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

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

func reverse(x int, s []byte) {
	for i, j := 0, x-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
}

func main() {
	defer out.Flush()

	var n int
	var s []byte
	fmt.Fscan(in, &n, &s)

	//TODO: enhancement, sqrt
	for i := 2; i <= n; i++ {
		if n % i == 0 {
			reverse(i, s)
		}
	}
	fmt.Fprintln(out, string(s))
}


// Codeforces 986 B done
package main

import (
	"bufio"
	"fmt"
	"strings"
	"strconv"
	"os"
)
var in *bufio.Reader

func readFive() (int,int,int,int,int) {
	var a [5]int
	s, err := in.ReadString('\n')
	if err != nil {
		fmt.Println("first read failure", err)
		panic(err)
	}
	ss := strings.Split(strings.Trim(s, " \n\r"), " ")
	for i:=0; i<len(ss); i++ {
		a[i], err = strconv.Atoi(ss[i])
		if err != nil {
			fmt.Println("n atoi failure", err)
			panic(err)
		}
	}
	return a[0],a[1],a[2],a[3],a[4]
}

func readLineNumbs(n int) []int {
	a := make([]int, n)
	delim := byte(' ')
	for i:=0; i<n; i++ {
		if i==(n-1) {
			delim = byte('\n')
		}
		s, err := in.ReadString(delim)
		s = strings.Trim(s, " \n\r")
		if err != nil {
			fmt.Println("read failure", err)
			panic(err)
		}
		aa,err := strconv.Atoi(s)
		if err != nil {
			fmt.Println("aa conv failed", err)
			panic(err)
		}
		a[i] = aa
	}
	return a
}

// binary sums structs and functions
var n int
var bt []byte

func readData() {
	in = bufio.NewReader(os.Stdin)
	n, _, _, _, _ = readFive()
	t,_ := in.ReadString('\n')
	t = strings.TrimSpace(t)
	bt = []byte(t)
}

func solve() {
	revb := make([]byte, n)
	for i:=2; i<=n; i++ {
		if (n % i) != 0 {
			continue
		}
		for j:=0; j<i; j++ {
			revb[j] = bt[i-j-1]
		}
		for j:=0; j<i; j++ {
			bt[j] = revb[j];
		}
	}
}

func printRes() {
	fmt.Println(string(bt))
}

func main() {
	readData()
	solve()
	printRes()
}


package main
import "fmt"
func main() {
    var a, b, c, d, e, f int
    fmt.Scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    if ((a * c * e < b * d * f) || ((a == 0) && (b * d > 0)) || (c == 0) && (d > 0)) {
        fmt.Printf("Ron\n");
    } else {
        fmt.Printf("Hermione\n");
    }
}