package main

import (
	"bufio"
	"bytes"
	"errors"
	"io"
	"math/rand"
	"os"
	"strconv"
	"time"
	"unicode/utf8"
)

// ******************************** CODE STARTS ********************************

const (
	MOD int = 1000 * 1000 * 1000 + 7
)

var (
)

func solve() {
	_ = readInt()
	a := readInt()
	b := readInt()
	movesNum := readInt()

	dp := make([][]int, 2)
	for i := 0; i < len(dp); i++ {
		dp[i] = make([]int, b)
	}

	for i := 1; i < b; i++ {
		dp[0][i] = 1 + dp[0][i - 1]
		if dp[0][i] >= MOD {
			dp[0][i] -= MOD
		}
	}

	for move := 0; move < movesNum; move++ {
		for x := 1; x < b; x++ {
			length := absInt(x - b)
			dp[(move & 1) ^ 1][x] = dp[(move & 1) ^ 1][x - 1]
			if length != 1 {
				left := maxInt(x - (length - 1), 1)
				right := minInt(x + (length - 1), b - 1)
				add := dp[(move & 1)][right] - dp[(move & 1)][left - 1]
				if add < 0 {
					add += MOD
				}
				sub := dp[(move & 1)][x] - dp[(move & 1)][x - 1]
				if sub < 0 {
					sub += MOD
				}
				diff := add - sub
				if diff < 0 {
					diff += MOD
				}
				dp[(move & 1) ^ 1][x] += diff
				if dp[(move & 1) ^ 1][x] >= MOD {
					dp[(move & 1) ^ 1][x] -= MOD
				}
			}
		}
	}
//	logln(dp)
	ans := dp[((movesNum - 1) & 1) ^ 1][a] - dp[((movesNum - 1) & 1) ^ 1][a - 1]
	if ans < 0 {
		ans += MOD
	}
	printInt(ans)
	printLine()

}

// ********************************* CODE ENDS *********************************

// IO.

var (
	scanner *Scanner
	writer  *bufio.Writer
)

func main() {
	input := os.Stdin
	output := os.Stdout
	//	input, _ := os.Open("")
	//	output, _ := os.Create("")

	defer input.Close()
	defer output.Close()

	scanner = NewScanner(input)
	scanner.Split(bufio.ScanWords)

	writer = bufio.NewWriter(output)
	defer writer.Flush()

	rand.Seed(int64(time.Now().Nanosecond()))
	solve()
}

// 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', 20, 64))
}

// Tuple

type Tuple struct {
	a, b int
}

func (p Tuple) Equals(key Key) bool {
	return p.a == key.(Tuple).a
}

func (p Tuple) Less(key Key) bool {
	return p.a < key.(Tuple).a
}

// Sorting

type TupleSlice []Tuple

func (p TupleSlice) Len() int {
	return len(p)
}

func (p TupleSlice) Less(j, i int) bool {
	if p[j].a == p[i].a {
		return p[j].b < p[i].b
	} else {
		return p[j].a < p[i].a
	}
}

func (p TupleSlice) Swap(j, i int) {
	p[j], p[i] = p[i], p[j]
}

// Min, max, abs.

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

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

func absInt(a int) int {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

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

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

func absInt64(a int64) int64 {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a < b {
		return a
	} else {
		return b
	}
}

func absFloat64(a float64) float64 {
	if a > 0 {
		return a
	} else {
		return -a
	}
}

// Set Key interface implementations.

type Int int

func (p Int) Equals(key Key) bool {
	return int(p) == int(key.(Int))
}

func (p Int) Less(key Key) bool {
	return int(p) < int(key.(Int))
}

// Set.

type Key interface {
	Equals(key Key) bool
	Less(key Key) bool
}

type node struct {
	key   Key
	left  *node
	right *node
}

func newNode(key Key) *node {
	return &node{key, nil, nil}
}

type SplayTree struct {
	root *node
	tmp  *node
	len  int
}

func NewSplayTree() *SplayTree {
	return &SplayTree{nil, newNode(nil), 0}
}

func rotateLeft(x, p *node) {
	p.right = x.left
	x.left = p
}

func rotateRight(x, p *node) {
	p.left = x.right
	x.right = p
}

func (p *SplayTree) splay(x *node, key Key) *node {
	if x == nil {
		return nil
	}

	left := p.tmp
	right := p.tmp

	for {
		if key.Less(x.key) {
			y := x.left
			if y == nil {
				break
			}
			if key.Less(y.key) { // zig-zig
				rotateRight(y, x)
				x = y
				if x.left == nil {
					break
				}
			}
			// link right
			right.left = x
			right = x
			// move left
			x = x.left
		} else if x.key.Less(key) {
			y := x.right
			if y == nil {
				break
			}
			if y.key.Less(key) { // zig-zig
				rotateLeft(y, x)
				x = y
				if x.right == nil {
					break
				}
			}
			// link left
			left.right = x
			left = x
			// move right
			x = x.right
		} else {
			break
		}
	}

	left.right = x.left
	right.left = x.right
	x.left = p.tmp.right
	x.right = p.tmp.left

	return x
}

// left <= key < right
func (p *SplayTree) split(key Key) (left, right *node) {
	p.root = p.splay(p.root, key)
	if p.root.key.Equals(key) || p.root.key.Less(key) {
		right := p.root.right
		p.root.right = nil
		return p.root, right
	} else {
		left := p.root.left
		p.root.left = nil
		return left, p.root
	}
}

// keys from left tree must be less then keys from right tree
func (p *SplayTree) join(left, right *node) *node {
	if left == nil {
		return right
	} else if right == nil {
		return left
	}
	left = p.splay(left, right.key)
	left.right = right
	return left
}

type Set interface {
	Len() int
	Insert(key Key) error
	Find(key Key) bool
	Remove(key Key) error
}

func NewSet() Set {
	return Set(NewSplayTree())
}

func (p *SplayTree) Len() int {
	return p.len
}

func (p *SplayTree) Insert(key Key) error {
	if p.root == nil {
		p.root = newNode(key)
		p.len++
	} else {
		p.root = p.splay(p.root, key)
		if p.root.key.Equals(key) {
			return errors.New("Such key already exists")
		} else {
			left, right := p.split(key)
			p.root = newNode(key)
			p.root.left = left
			p.root.right = right
			p.len++
		}
	}
	return nil
}

func (p *SplayTree) Find(key Key) bool {
	if p.root == nil {
		return false
	}
	p.root = p.splay(p.root, key)
	return p.root.key.Equals(key)
}

func (p *SplayTree) Remove(key Key) error {
	p.root = p.splay(p.root, key)
	if p.root == nil || !p.root.key.Equals(key) {
		return errors.New("Such key doesn't exist")
	}
	p.root = p.join(p.split(key))
	return nil
}

// Copied scan.go
// 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.
}

// 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 (
	// Maximum size used to buffer a token. The actual maximum token size
	// may be smaller as the buffer may need to include, for instance, a newline.
	MaxScanTokenSize = 1 << 20
)

// 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,
		buf:          make([]byte, 4096), // Plausible starting size; needn't be large.
	}
}

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

// 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.
func (s *Scanner) Scan() bool {
	// Loop until we have a token.
	for {
		// See if we can get a token with what we already have.
		if s.end > s.start {
			advance, token, err := s.split(s.buf[s.start:s.end], s.err != nil)
			if err != nil {
				s.setErr(err)
				return false
			}
			if !s.advance(advance) {
				return false
			}
			s.token = token
			if token != nil {
				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 neded.
		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) {
			if len(s.buf) >= s.maxTokenSize {
				s.setErr(ErrTooLong)
				return false
			}
			newSize := len(s.buf) * 2
			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 {
				break
			}
			loop++
			if loop > 100 {
				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
	}
}

// Split sets the split function for the Scanner. If called, it must be
// called before Scan. The default split function is ScanLines.
func (s *Scanner) Split(split SplitFunc) {
	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', '\u180e', '\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
		}
	}
	if atEOF && len(data) == 0 {
		return 0, nil, nil
	}
	// 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 0, nil, nil
}


package main

import (
        "fmt"
        "sort"
        )

var a [100000]int
var l, r int
var ans, ans1, j int64

func main() {
	fmt.Scanf("%d %d", &l, &r)
	num:=0
	ans=1
    for i:=0; i<=30; i++{
        a[num]=int(ans)
        num++
        ans1=ans
        for (ans1<int64(2000000000)){
            ans1=ans1*int64(3)
            if (ans1<int64(2000000000)){
              a[num]=int(ans1)
              num++
            }
        }
        ans*=int64(2)
    }
    sort.Ints(a[:])
    i:=0
    for i<100000 && a[i]<l{
        i++
    }
    j:=0
    for j<100000 && a[j]<r{
        j++
    }
    if (j>=i){
      fmt.Printf("%d", j-i)

    } else{
      fmt.Printf("%d", 0)
    }
}


package main

import (
      "fmt"
      "math"
    )

var log3 = math.Log2(3.0)
var l,r float64
func find_divs(upper float64, num float64) int {
    var total_num int
    for i := int(upper); i>0; i-- {
        d := num/math.Pow(3,float64(i))
        total_num += int(math.Log2(d))
    }
    return total_num
}
func main(){
	fmt.Scanf("%f %f", &l, &r)
	r2max := math.Log2(r)
    r3max := r2max/log3
    r2min := math.Log2(l)
    r3min := r2min/log3
    var extra int
    if l == 1 {
        extra = 1
    } else {
        extra = 0
    }
    var total23divs int
    total23divs = find_divs(r3max, r) - find_divs(r3min, l)
    total := int(r2max) + int(r3max) - int(r2min) - int(r3min)  + total23divs + extra
	fmt.Println( total)
}


Rashidov_Anis
package main

import "fmt"

func main() {
    var afl int64
    var bfa int64
    var lrt int64
    var rgh int64
    var cnt int64
    afl = 1
    bfa = 1
    cnt = 0
	fmt.Scan(&lrt)
	fmt.Scan(&rgh)
	for it := 0; it <= 19; it++ {
	    bfa = 1
	    for jt := 0; jt <= 30; jt ++ {
	        if afl * bfa >= lrt {
	            if afl * bfa <= rgh {
	                cnt = cnt + 1
	            }
	        }
	        bfa = bfa * 2
	    }
	    afl = afl * 3
	}
	fmt.Printf( "%d", cnt )
}


package main

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

type Node struct {
	sta int
	ele int
	sum int
}

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

	return y
}

func main() {

	reader := bufio.NewReader(os.Stdin)
	var n, k int

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

	g := [200][200]int{}
	a := make([]int, n+1)

	for i := 0; i < n; i++ {
		if i+1 != n {
			fmt.Fscanf(reader, "%d", &a[i])
		} else {
			fmt.Fscanf(reader, "%d\n", &a[i])
		}
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			g[i][j] = 100000
			if i == j {
				g[i][j] = 0
			}
		}
	}

	x, y := 0, 0
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(reader, "%d %d\n", &x, &y)
		x--
		y--
		g[x][y] = 1
		g[y][x] = 1
	}

	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if j == i {
				continue
			}

			for k := 0; k < n; k++ {
				g[i][j] = min(g[i][j], g[i][k]+g[k][j])
			}
		}
	}

	// for i := 0; i < n; i++ {
	// 	for j := 0; j < n; j++ {
	// 		fmt.Printf("%6d ", g[i][j])
	// 	}

	// 	fmt.Println()
	// }
	ans := make(map[int]map[int]bool)
	ans[0] = make(map[int]bool)
	for i := 0; i < n; i++ {
		tmp := make(map[int]map[int]bool)

		for w, v := range ans {
			ok := true
			set := make(map[int]bool)
			for p, _ := range v {
				if g[i][p] <= k {
					ok = false
					break
				}
				set[p] = true
			}

			if ok {
				set[i] = true
				tmp[w+a[i]] = set
			}
		}

		for w, v := range tmp {
			ans[w] = v
		}
	}

	ansans := 0
	for w, _ := range ans {
		if w > ansans {
			ansans = w
		}
	}

	fmt.Println(ansans)
}


package main

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

func main() {

	reader := bufio.NewReader(os.Stdin)
	var n, p int64

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

	a := make([]int64, 0, 32)
	for i := 0; i < 32; i++ {
		t := (1 << uint(i)) + p
		if t >= n+1000 {
			break
		}
		if t != 0 {
			a = append(a, t)
		}
	}

	ans := make(map[int64]int)
	ans[0] = 0

	for {
		tmp := make(map[int64]int, 2*len(ans))
		for k, v := range ans {
			for i := 0; i < len(a); i++ {
				if k+a[i] == n {
					fmt.Println(v + 1)
					return
				}

				if k+a[i] <= n+1000 {
					tmp[k+a[i]] = v + 1
				}
			}
		}

		ans = tmp
		if len(ans) == 0 {
			fmt.Println(-1)
			return
		}

		//fmt.Println(ans)
	}
}


// 265A-mic
package main

import (
    "fmt"
)

func main() {
    var s, inst string
    pos := 1
    r := 0
    fmt.Scan(&s)
    fmt.Scan(&inst)
    for i := 0; i < len(inst); i++ {
        if inst[i] == s[r] {
            if pos != len(s)-1 {
                r++
                pos++
            }
        }
    }
    fmt.Println(pos)
}


package main

import "fmt"

func main() {
	var a, b, c , d int
	fmt.Scanf("%d\n%d\n%d\n%d\n", &a, &b, &c, &d);
	if c != 0{
		a--
		d--
	}
	if a > 0 && d > 0 && a == d{
		fmt.Println(1)
	}else{
		fmt.Println(0)
	}
}


package main

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

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

	var a, b, c, d int
	Fscan(in, &a, &b, &c, &d)
	if a != d || a+d < c {
		Fprint(out, 0)
	} else {
		Fprint(out, 1)
	}
}

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


package main

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

// github.com/EndlessCheng/codeforces-go
const mod int64 = 1e9 + 7

type matrix [][]int64

func newMatrix(n int) matrix {
	mat := make(matrix, n)
	for i := range mat {
		mat[i] = make([]int64, n)
	}
	return mat
}

func newMatrixI(n int) matrix {
	mat := make(matrix, n)
	for i := range mat {
		mat[i] = make([]int64, n)
		mat[i][i] = 1
	}
	return mat
}

func (a matrix) mul(b matrix) matrix {
	c := newMatrix(len(a))
	for i := range a {
		for j := range b[0] {
			for k, aik := range a[i] {
				c[i][j] += aik * b[k][j] % mod
			}
			c[i][j] %= mod
		}
	}
	return c
}

func (a matrix) pow(k int64) matrix {
	res := newMatrixI(len(a))
	for ; k > 0; k >>= 1 {
		if k&1 == 1 {
			res = res.mul(a)
		}
		a = a.mul(a)
	}
	return res
}

func CF1117D(in io.Reader, out io.Writer) {
	var n, m int64
	Fscan(in, &n, &m)
	if n < m {
		Fprint(out, 1)
		return
	}
	a := newMatrix(int(m))
	a[0][0] = 1
	a[0][m-1] = 1
	a[m-1][0] = 1
	Fprint(out, a.pow(n)[0][0])
}

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


package main

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

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

func count(n int64) int64 {
	if n < 10 {
		return int64(n)
	}
	var l, p int64 = 1, 1
	for p * 10 <= n {
		l++
		p *= 10
	}

	return l * (n / p) * (n % p + 1) + count(p - 1)
}

func main() {

	defer out.Flush()
	in.Split(bufio.ScanWords)

	fmt.Fprintln(out, count(NextInt64()))
}

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

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

func NextInt64() int64 {
	ret, _ := strconv.ParseInt(Next(), 10, 64)
	return ret
}


package main

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

func main() {
    //io
    scanner := bufio.NewReader(os.Stdin)
    writer := bufio.NewWriter(os.Stdout)
    //---
    var n, d, c, ans int

    fmt.Fscan(scanner, &n)
    for c = 1; c <= n; c *= 10 {
        d++
    }
    //writer.WriteString(strconv.Itoa(c))
    c /= 10
    b := d
    ans = (n - c) * d;
    for d > 0 {
        ans += (c - c / 10) * (b-d+1);
        d--
        c /= 10
    }

    writer.WriteString(strconv.Itoa(ans))
    writer.Flush()
}


package main

import (
	"fmt"
)

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

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

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


package main

import (
	"bufio"
	"bytes"
	"fmt"
	"io"
	"io/ioutil"
	"os"
	"path/filepath"
	"runtime"
	"strings"
)

func main() {
	b, _ := ioutil.ReadAll(os.Stdin)
	if len(b) == 0 {
		test()
	} else {
		solve(bytes.NewReader(b), os.Stdout)
	}
}

func solve(r io.Reader, w io.Writer) {
	var n int
	fmt.Fscanln(r, &n)

	cs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &cs[i])
	}

	fmt.Fprintln(w, f(cs))
}

func f(cs []int) int {
	gs := graphs(cs)

	if len(gs) == 0 {
		return -1
	}

	if len(gs) == 1 {
		return gs[0]
	}

	for i, g := range gs {
		if g%2 == 0 {
			gs[i] = g / 2
		}
	}

	return lcmm(gs...)
}

func graphs(cs []int) []int {
	seen := make(map[int]bool, len(cs))

	var ls []int

	for j, c := range cs {
		i := j + 1

		if seen[i] {
			continue
		}

		if cs[i-1] == i {
			seen[i] = true
			seen[cs[i-1]] = true
			ls = append(ls, 1)
			continue
		}

		l := 2

		for ; ; l++ {
			seen[c] = true
			next := cs[c-1]
			if next == i {
				break
			}
			if seen[next] {
				return nil
			}
			c = next
		}
		seen[i] = true
		ls = append(ls, l)
	}
	return ls
}

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

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

func lcmm(xs ...int) int {
	r := 1
	for _, x := range xs {
		r = lcm(r, x)
	}
	return r
}

func test() {
	tests := []struct {
		in   string
		want string
	}{
		{
			in: `
4
2 3 1 4
`,
			want: `3`,
		},
		{
			in: `
4
4 4 4 4
`,
			want: `-1`,
		},
		{
			in: `
4
2 1 4 3
`,
			want: `1`,
		},
		{
			in: `
5
2 3 1 5 4
`,
			want: `3`,
		},
		{
			in: `
7
2 3 1 5 6 7 4
`,
			want: `6`,
		},
		{
			in: `
5
2 4 3 1 2
`,
			want: `-1`,
		},
		{
			in: `
10
8 10 4 3 2 1 9 6 5 7
`,
			want: `15`,
		},
	}
	for i, tt := range tests {
		fmt.Printf("=== TEST %d\n", i)
		buf := new(bytes.Buffer)
		solve(strings.NewReader(chomp(tt.in)), buf)
		if got, want := chomp(buf.String()), chomp(tt.want); got != want {
			fmt.Printf("%d: got %v, want %v\n", i, got, want)
		}
	}
}

func chomp(s string) string {
	return strings.Trim(s, "\n")
}

func assert(b bool) {
	if !b {
		_, file, line, ok := runtime.Caller(1)
		if ok {
			f, _ := os.Open(file)
			defer f.Close()
			s := bufio.NewScanner(f)
			lnum := 0
			for s.Scan() {
				lnum++
				if lnum == line {
					wd, _ := os.Getwd()
					fname, _ := filepath.Rel(wd, file)
					fmt.Printf("assertion fails: %s:%d: %v\n", fname, line, s.Text())
					break
				}
			}
		}
	}
}

func pow(a, b int) int {
	r := 1
	for i := 0; i < b; i++ {
		r *= a
	}
	return r
}


package main

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

func check(num, i int64) int64 {
	var count, divider int64 = 0, 5

	for (i / divider) > 0 {
		count += i / divider
		divider *= 5
	}

	return count
}

func main() {
	reader := bufio.NewReader(os.Stdin)
	n, _ := reader.ReadString('\n')
	var num, result, flag int64
	fmt.Sscanf(n, "%d", &num)
	var i int64 = 1

	for {

		result = check(num, i)

		if result > num {
			if flag == 0 {
				fmt.Print(0)
			}
			break
		} else if result == num {

			if flag == 0 {
				fmt.Println(i)
				flag = 1
			}

			fmt.Printf("%d ", i)
		}

		i++
	}

	fmt.Println()
}


n := 0
fmt.Scanf("%d", &n)
for i := 0; i <= 1e5; i++ {
    tmp := i
    c := 0
    for {
        if tmp % 5 {
            break
        }
        tmp /= 5
        c ++
    }
    if c < n {
        continue
    }
    if c == n {
        fmt.Println("5")
        for j := i; j < i + 5; j++ {
            fmt.Print(j, " ")
        }
    }
    if c > n {
        break
    }
}


package main

import "fmt"

func main() {
	n := 0
	fmt.Scanf("%d", &n)
	c := 0
	for i := 0; i <= 1e5; i+=5 {
		tmp := i
		for {
			if tmp%5 != 0 {
				break
			}
			tmp /= 5
			c++
		}
		if c < n {
			continue
		}
		if c == n {
			fmt.Println("5")
			for j := i; j < i+5; j++ {
				fmt.Print(j, " ")
			}
			break
		}
		if c > n {
		    fmt.Println("0")
			break
		}
	}
}


package main

import "fmt"

func main() {
	n := 0
	fmt.Scanf("%d", &n)
	c := 0
	for i := 5; i <= 1e5; i += 5 {
		tmp := i
		for {
			if tmp%5 != 0 {
				break
			}
			tmp /= 5
			c++
		}
		if c < n {
			continue
		}
		if c == n {
			fmt.Println("5")
			for j := i; j < i+5; j++ {
				fmt.Print(j, " ")
			}
			break
		}
		if c > n {
			fmt.Println("0")
			break
		}
	}
}


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 a int
	for I(&a, " ") == nil {
		solve(a)
	}
}

func solve(a int) {
	var in [3][3]int
	in[0][0] = a
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			if i != 0 || j != 0 {
				o := " "
				if j == 2 {
					o = "\n"
				}
				I(&in[i][j], o)
			}
		}
	}
	var x [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			x[i][j] = 1
		}
	}
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			for in[i][j] > 0 {
				x[i][j] ^= 1
				for ii := 0; ii < 3; ii++ {
					if ii != i && ii != j {
						x[ii][j] ^= 1
						x[i][ii] ^= 1
					}
				}
				in[i][j]--
			}
		}
	}
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			O(x[i][j], "")
		}
		O("", "\n")
	}
}


package main
import (
	"fmt"
	//"unicode/utf8"
)

func main() {
	var a1,a2,a3,b1,b2,b3,c1,c2,c3 int
	fmt.Scan(&a1,&a2,&a3)
	fmt.Scan(&b1,&b2,&b3)
	fmt.Scan(&c1,&c2,&c3)
	if (a1+a2+b1)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	if (a1+a2+a3+b2)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	if (a2+a3+b3)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	fmt.Println()
	if (a1+b1+b2+c1)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	if (a2+b1+b3+c2)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	if (a3+b2+b3+c3)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	fmt.Println()
	if (b1+c1+c2)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	if (b2+c1+c2+c3)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	if (b3+c2+c3)%2==0 {
		fmt.Print("1")
	} else {fmt.Print("0")}
	fmt.Println()
}


package main

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

const GRID_SIZE = 3

type Grid [][]bool

func main() {
	grid := createSquareGrid(GRID_SIZE)
	for i := 0; i < GRID_SIZE; i++ {
		for j := 0; j < GRID_SIZE; j++ {
			var n int
			fmt.Fscan(os.Stdin, &n)
			grid.toggleNTimes(i, j, n)
		}
	}
	fmt.Print(grid)
}

func createSquareGrid(size int) Grid {
	grid := make(Grid, size)
	for rowIdx := range grid {
		grid[rowIdx] = make([]bool, size)
		for colIdx := range grid[rowIdx] {
			grid[rowIdx][colIdx] = true
		}
	}
	return grid
}

func (grid Grid) toggleNTimes(i, j, n int) {
	if n <= 0 { return }
	toggle := func(i, j int) { grid[i][j] = !grid[i][j] }
	toggle(i, j)
	n = n % 2
	if (n > 0) {
		if i > 0 { toggle(i-1, j) }
		if j > 0 { toggle(i, j-1) }
		if i < GRID_SIZE-1 { toggle(i+1, j) }
		if j < GRID_SIZE-1 { toggle(i, j+1) }
	}
}

func (grid Grid) String() string {
	var buffer bytes.Buffer
	for rowIdx := range grid {
		buffer.WriteString(boolAsString(grid[rowIdx][0]))
		for colIdx := 1; colIdx < len(grid[rowIdx]); colIdx++ {
			buffer.WriteString(boolAsString(grid[rowIdx][colIdx]))
		}
		buffer.WriteString("\n")
	}
	return buffer.String()
}

func boolAsString(b bool) string {
	if b { return "1" }
	return "0"
}


package main

import "fmt"

func main() {
	var x1, y1, x2, y2 int64
	fmt.Scanf("%d %d %d %d", &x1, &y1, &x2, &y2)

	var dx, dy, num_prim_cols, num_sec_cols, len_prim_cols, len_sec_cols int64
	dx = x2 - x1
	dy = y2 - y1
	num_prim_cols = dx / 2 + 1 //dx guaranteed to be divisible by 2
	num_sec_cols = num_prim_cols - 1
	len_prim_cols = dy / 2 + 1
	len_sec_cols = 0
//	fmt.Printf("dx=\t%d\ndy=\t%d\nprim_cols=\t%d\nsec_cols=\t%d\n", dx, dy, num_prim_cols, num_sec_cols)

	if ( dy % 2 == 0) {
		len_sec_cols = dy / 2
	} else {
		len_sec_cols = dy / 2 + 1
	}
//	fmt.Printf("\nlen_prim_cols=\t%d\nlen_sec_cols=\t%d\n", len_prim_cols, len_sec_cols)

	fmt.Println("Total cells = ", num_prim_cols * len_prim_cols + num_sec_cols * len_sec_cols)
}


package main

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

func main() {
	var a int
	in := bufio.NewReader(os.Stdin)
	fmt.Fscan(in, &a)
	for sumdigit(a)%4 != 0 {
		a += 4 - sumdigit(a)%4
	}
	fmt.Println(a)
}
func sumdigit(a int) int {
	sum := 0
	for a > 0 {
		sum += a % 10
		a /= 10
	}
	return sum
}


package main

import (
	"fmt"
)

func sum(a int) int {
	var d, s int
	for a > 0 {
		d = a % 10
		s = s + d
		a = a / 10
	}
	return s
}

func main() {
	var a, s, x, n int
	fmt.Scan(&a)
	s = sum(a)
	if s%4 == 0 {
		fmt.Println(a)
	} else {
		x = 4 - (s % 4)
		n = a + x
		for sum(n)%4 != 0 {
			n = n + x
		}
		fmt.Println(n)
	}
}


package main

import(
	"fmt"
)

func chk(a int) (bool){
	sum :=0 ;
	for; a!=0 ; a/=10{24
		sum+=a%10
	}
	if(sum%4==0){
		return true;
	}
	return false;
}

func main(){
	var a int
	fmt.Scanf("%d",&a)
	for ;!chk(a); a++{}
	fmt.Printf("%d",a)
}


package main

import (
	"fmt"
)

func check ( n int ) bool {
	res := 0
	for n != 0 {
		res += n % 10
		n /= 10
	}

	return n % 4 == 0
}

func main() {
	var n int
	fmt.Scanf ( "%d", &n )
	for !check ( n ) {
		n++;
	}
	fmt.Println ( n )
}


package main

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

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	writer := bufio.NewWriter(os.Stdout)
	defer writer.Flush()
	a, b, x, y := scanInt(scanner), scanInt(scanner), scanInt(scanner), scanInt(scanner)
	low, high := 1, 2*1000*1000*1000
	for low != high {
		k := (low+high)/2
		writer.WriteString(fmt.Sprintf("low = %d, high = %d, k = %d\n", low, high, k))
		div_xy := k/(x*y)
		div_x, div_y := k/x - div_xy, k/y - div_xy
		div_neither := k - div_x - div_y - div_xy
		need_a, need_b := a - div_y, b - div_x
		if need_a < 0 {
			need_a = 0
		}
		if need_b < 0 {
			need_b = 0
		}
		if need_a + need_b <= div_neither {
			high = k
		} else {
			low = k+1
		}
	}
	writer.WriteString(fmt.Sprintf("%d\n", low))
}


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()
	ans := scanner.Text()
	return ans
}

func PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		//writer.WriteByte(' ')
	}
}

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

	p1, p2 := ReadInt32(), ReadInt32()

	if p1 == 1 && p2 == 1 {
		PrintInts(0)
		os.Exit(0)
	}

	cnt := 0
	for p1 > 0 && p2 > 0 {
		cnt = cnt + 1
		if p1 > p2 {
			p1 = p1 - 2
			p2 = p2 + 1
		} else {
			p1 = p1 + 1
			p2 = p2 - 2
		}
	}

	PrintInts(cnt)
}


package main

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

func ReadInt(x int) (res int)  {
	scanner.Scan()

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

type building struct
{
	a , b ,c int
}

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

func main()  {
	var n,h,m int
	fmt.Scan(&n)
	fmt.Scan(&h)
	fmt.Scan(&m)
	bl := make([]int,n + 1,n + 1)
	for i := 1 ; i <= n ;i++{
		bl[i] = 100
	}
	var x1,x2,x3 int
	for i := 0 ; i < m ;i ++{
		fmt.Scan(&x1)
		fmt.Scan(&x2)
		fmt.Scan(&x3)
		for i := x1; i <= x2  ; i++{
			bl[i] = min(bl[i],x3);
		}

	}
	var ans int = 0
	for i := 1 ;i  <=  n ;i ++{
		if(bl[i] >= 1){
			ans += bl[i] * bl[i];
		}else{
			if(bl[i] == 100){
			ans += h * h
			}
		}
	}
	fmt.Println(ans)

}


package main

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

func I(i interface{}, delim string) {
	fmt.Fscanf(r, "%v"+delim, i)
}

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

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

var in [4]string

func check() bool {
	for i := 0; i < 4; i++ {
		for j := 0; j < 4; j++ {
			if in[i][j] == 'x' {
				if strings.Contains(in[i], "xxx") ||
					(i+2 < 4 && ((in[i+1][j] == 'x' && in[i+2][j] == 'x') ||
						(j+2 < 4 && in[i+1][j+1] == 'x' && in[i+2][j+2] == 'x') ||
						(i-2 >= 0 && in[i+1][j-1] == 'x' && in[i+2][j-2] == 'x'))) {
					O("YES", "\n")
					return true
				}
			}
		}
	}
	return false
}

func main() {
	r = bufio.NewReader(os.Stdin)
	w = bufio.NewWriter(os.Stdout)
	defer w.Flush()
	for i := 0; i < 4; i++ {
		I(&in[i], "\n")
	}
	if check() {
		return
	}
	for i := 0; i < 4; i++ {
		for j := 0; j < 4; j++ {
			if in[i][j] == '.' {
				a := []rune(in[i])
				a[j] = 'x'
				in[i] = string(a)
				if check() {
					return
				}
				a[j] = '.'
				in[i] = string(a)
			}
		}
	}
	O("NO", "\n")
}


package main

import "fmt"

const size = 4
const x = 'x'
const dot = '.'

func checkVertical(table [][]rune) bool {
	for i := 0; i < size; i++ {
		if table[i][0] == x && table[i][1] == x && table[i][2] == x {
			return true
		}

		if table[i][1] == x && table[i][2] == x && table[i][3] == x {
			return true
		}
	}

	return false
}

func checkHorizontal(table [][]rune) bool {
	for j := 0; j < size; j++ {
		if table[j][0] == x && table[j][1] == x && table[j][2] == x {
			return true
		}

		if table[j][1] == x && table[j][2] == x && table[j][3] == x {
			return true
		}
	}

	return false
}

func checkDiagonal(table [][]rune) bool {
	for i := 0; i < size; i++ {
		for j := 0; j < size; j++ {
			var ii, jj int

			ii = i + 2
			jj = j + 2

			if ii < size && jj < size && table[i][j] == x && table[i+1][j+1] == x && table[i+2][j+2] == x {
				return true
			}

			ii = i + 2
			jj = j - 2

			if ii < size && jj >= 0 && table[i][j] == x && table[i+1][j-1] == x && table[i+2][j-2] == x {
				return true
			}
		}
	}

	return false
}

func main() {
	table := make([][]rune, size)

	for i := 0; i < size; i++ {
		table[i] = make([]rune, size)

		var row string
		fmt.Scanf("%s\n", &row)

		for p, s := range row {
			table[i][p] = s
		}
	}

	for i := 0; i < size; i++ {
		for j := 0; j < size; j++ {
			if table[i][j] == dot {
				table[i][j] = x
				if checkHorizontal(table) || checkVertical(table) || checkDiagonal(table) {
					fmt.Println("YES")
					return
				}
				table[i][j] = dot
			}
		}
	}

	fmt.Println("NO")
}


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")
	o := 0
	ans := 1
	for i := 0; i < n; i++ {
		var t int
		s := " "
		if i == n-1 {
			s = "\n"
		}
		I(&t, s)
		if o+t <= m {
			o += t
		} else {
			i--
			ans++
			o = 0
		}
	}
	O(ans, "\n")
}


// cf435a.go
package main

import (
	"fmt"
)

func main() {
	// scan input
	n := 0 // group count
	m := 0 // max load of bus
	fmt.Scanf("%d %d\n", &n, &m)
	var groups []int = make([]int, n)
	for idx := 0; idx < len(groups); idx++ {
		fmt.Scanf("%d", &groups[idx])
	}

	// calc
	killed := 0
	tried := 0
	for killed < len(groups) {
		left := m
		for idx := 0; idx < len(groups) && left > 0; idx++ {
			if groups[idx] > 0 && left >= groups[idx] {
				left -= groups[idx]
				groups[idx] = 0
				killed++
			}
		}
		tried++
	}

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


package main

import (
	"fmt"
)

func main() {
	var tramp, c1, c2 string
	fmt.Scan(&tramp, &c1, &c2)
	if c1[1] == tramp[0] && c2[1] != tramp[0] {
		fmt.Println("YES")
	} else if c1[1] != c2[1] {
		fmt.Println("NO")
	} else if c1[0] > c2[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	fmt.Scan(&n)
	xs := make([]int, n*2)
	ys := make([]int, n*2)
	area := 0
	for i := 0; i < n; i++ {
		fmt.Scan(&xs[2*i], &ys[2*i], &xs[2*i+1], &ys[2*i+1])
		area += (xs[2*i+1] - xs[2*i]) * (ys[2*i+1] - ys[2*i])
	}
	sort.Ints(xs)
	sort.Ints(ys)
	squareArea := (xs[2*n-1] - xs[0]) * (ys[2*n-1] - ys[0])
	if squareArea == area {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}


package main

import (
    "fmt"
    "math"
)

func main() {
    var n,x,y int
    fmt.Scan(&n,&x,&y)
    a := int(math.Ceil(float64(y)*float64(n)/100.0))
    fmt.Println(a-x)
}


// 168A-mic
package main

import (
    "fmt"
    "math"
)

func main() {
    var n, x, y float64
    fmt.Scan(&n, &x, &y)
    fmt.Println(int(math.Ceil((n*y)/100.0 - x)))
}


package main

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

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

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

  adults, children := scanInt(scanner), scanInt(scanner)
  if adults == 0 {
    writer.WriteString("Impossible\n")
  } else {
    minimum, maximum := adults, adults
    if children > adults {
      minimum += children - adults
    }
    if children > 0 {
      maximum += children - 1
    }
    writer.WriteString(fmt.Sprintf("%d %d\n", minimum, maximum))
  }
}


package main

import "fmt"

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


package main

import "fmt"

func intPow(x int64, y int64) (res int64) {
	res = 1
	for i := int64(0); i < y; i++ {
		res *= x
	}
	return
}

func main() {
	var n, x, y, numx, numy, t int64
	fmt.Scanf("%d %d\n", &n, &x)
	numx = 0
	for i := int64(1); i <= n; i++ {
		fmt.Scanf("%d", &t)
		numx += t * intPow(x, (n-i))
	}

	fmt.Scanf("%d %d\n", &n, &y)
	fmt.Println(n, y)
	return
	numy = 0
	for i := int64(1); i <= n; i++ {
		fmt.Scanf("%d", &t)
		numy += t * intPow(y, (n-i))
	}

	if numx == numy {
		fmt.Println("=")
	} else if numx < numy {
		fmt.Println("<")
	} else {
		fmt.Println(">")
	}
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	x := calcNum(reader)
	y := calcNum(reader)
	if x < y {
		print("<")
	} else if x > y {
		print(">")
	} else {
		print("=")
	}
}

func calcNum(reader *bufio.Reader) int64 {
	l1, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}
	l2, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	b, err := strconv.ParseInt(strings.Fields(l1)[1], 10, 64)
	if err != nil {
		panic(err)
	}
	digits := strings.Fields(l2)
	n := int64(0)
	for _, d := range digits {
		dig, err := strconv.ParseInt(d, 10, 64)
		if err != nil {
			panic(err)
		}
		n = n*b + dig
	}
	return n
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	x := calcNum(reader)
	y := calcNum(reader)
	if x < y {
		print("<")
	} else if x > y {
		print(">")
	} else {
		print("=")
	}
}

func calcNum(reader *bufio.Reader) int64 {
	l1, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}
	l2, err := reader.ReadString('\n')
	if err != nil {
		panic(err)
	}

	b, err := strconv.ParseInt(strings.Fields(l1)[1], 10, 64)
	if err != nil {
		panic(err)
	}
	digits := strings.Fields(l2)
	n := int64(0)
	for _, d := range digits {
		dig, err := strconv.ParseInt(d, 10, 64)
		if err != nil {
			panic(err)
		}
		n = n*b + dig
	}
	return n
}


package main;

import ("io"; "bufio"; "os"; "strconv")

var scanner *bufio.Scanner

func nextInt() (num int64) {
    var err error
    scanner.Scan()
    num, err = strconv.ParseInt(scanner.Text(), 10, 64)
    if err != nil {
        panic("failed converting "+scanner.Text())
    }
    return num
}

func readNum(digits, base int64) (result int64) {
    for ; digits>0; digits-- {
        result = result*base + nextInt()
    }
    return
}

func main() {
    var inp io.Reader = bufio.NewReader(os.Stdin)
    scanner = bufio.NewScanner(inp)
    scanner.Split(bufio.ScanWords)

    X := readNum(nextInt(), nextInt())
    Y := readNum(nextInt(), nextInt())
    if X<Y {
        println("<")
    } else if X>Y {
        println(">")
    } else {
        println("=")
    }
}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var v [4]int
	fmt.Scanf("%d %d %d %d", &v[0], &v[1], &v[2], &v[3])
	sort.Ints(v[:])

	if v[0]+v[3] == v[1]+v[2] ||
		v[0]+v[1]+v[2] == v[3] {
		println("YES")
	} else {
		println("NO")
	}
}


package main

import "fmt"

func main() {
	var a1,a2,a3,a4 int
	fmt.Scanf("%d%d%d%d", &a1,&a2,&a3,&a4)

	sum := a1 + a2 + a3 + a4
	if sum % 2 != 0 {
		fmt.Printf("NO")
	} else {
		if a1 + a2 == sum / 2 || a1 + a3 == sum / 2 || a1 + a4 == sum / 2 {
			fmt.Printf("YES")
		} else {
			fmt.Printf("NO")
		}
	}
}


package main

import "fmt"

func main() {
	var a1,a2,a3,a4 int
	fmt.Scanf("%d%d%d%d", &a1,&a2,&a3,&a4)

	sum := a1 + a2 + a3 + a4
	if sum % 2 != 0 {
		fmt.Printf("NO")
	} else {
		if a1 + a2 == sum / 2 || a1 + a3 == sum / 2 || a1 + a4 == sum / 2
		|| a1 == sum / 2 || a2 == sum / 2 || a3 == sum / 2 || a4 == sum / 2 {
			fmt.Printf("YES")
		} else {
			fmt.Printf("NO")
		}
	}
}


package main

import(
    "fmt"
    "os"
)

var print = fmt.Println

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

    fmt.Fscan(os.Stdin, &a,&b,&c,&d);

    if(a + b == c + d || a + c == d + b || a + d == b + c){
        print("YES");
    }else {
        print("NO");
    }
}


package main
import "fmt"

func main() {
      var n, m, k int32;
      fmt.Scan(&n, &m);

      for n > 0 {
            k++;
            if !(k % m) {
                  k++;
            }
            n--;
      }

      fmt.Print(k);
}


package main
import "fmt"

func main() {
      var n, m, k int32;
      fmt.Scan("%d%d", &n, &m);

      for (n > 0) {
            k++;
            if (k % m == 0) {
                  k++;
            }
            n--;
      }

      fmt.Print(k);
}


package main
import "fmt"

var (
      n int32
      m int 32
      k int32

)

func in() {
      fmt.Scanf("%d%d", &n, &m)

}

func out() {
      fmt.Println(k)
}

func run() {
      for n > 0 {
            k++
            if k % m == 0 {
                  k++
            }
            n--
      }
}

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


package main

import "fmt"

func main() {
	var n, m int
	fmt.Scanf("%d", &n)
	fmt.Scanf("%d", &m)
	res := n
	for n > 0 {
		n = n / m
		res += n
	}
	fmt.Println(res)
}


package main
import (
	"fmt"
	"math"
	"os"
)

func main(){
	var a, b float64
	fmt.Scan(&a)
	fmt.Scan(&b)
	if a == b {
		fmt.Println("=")
		os.Exit(0)
	}
	if a > b {
		var x, y float64
		x = b
		y = a
		x = (x * math.Log(a)) / math.Log(b)
		if x > y {
			fmt.Println(">")
		} else{
			fmt.Println("<")
		}
	} else {
		var x, y float64
		x = b
		y = a
		y = (y * math.Log(b)) / math.Log(a)
		if x > y {
			fmt.Println(">")
		} else{
			fmt.Println("<")
		}
	}
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var x, y int
	fmt.Fscan(reader, &x, &y)

	if x == y {
		fmt.Println("=")
		return
	} else if x > y {
		fmt.Println("<")
	} else if x < y {
		fmt.Println(">")
	}
}


package main

import (
	"fmt"
	"math"
)

var pos [40000001]int

func main() {
	var n int64
	fmt.Scanf("%d", &n)
	ans := 4
	for x := int64(1); x < n; x++ {
		pos[x] = int(math.Sqrt(float64(n*n - x*x)))
	}
	for x := int64(1); x < n; x++ {
		if int(x) != pos[pos[x]] {
			ans += 8
		} else {
			ans += 4
		}
	}
	fmt.Printf("%d", ans)
}


package main

import (
	"fmt"
)

const SIDES int64 = 6

func main() {
	var n, total int64

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

	for i := 0; i < n; i++ {
		total += (i + 1) * SIDES
	}
	fmt.Println(total + 1)
}


package main

import (
	"fmt"
)

func count(n int64) int64 {
	if n < 1 {
		return 1
	}
	return 6*n + count(n-1)
}

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


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

var n, m, k int64

func solve(n int64) {
	I(&m, " ")
	I(&k, "\n")
	p := k - (n - k)
	o := (k * (k + 1) / 2) + (k*(k-1))/2 - (p * (p - 1) / 2)
	ans := k
	if o < m {
		ans += (m - o) / n
	} else if o > m {
		ans -= (o-m)/n + 1
	}
	O(ans, "\n")
}


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

var n, m, k int64

func solve(n int64) {
	I(&m, " ")
	I(&k, "\n")
	p := k - (n - k)
	o := (k * (k + 1) / 2) + (k*(k-1))/2 - (p * (p - 1) / 2)
	ans := k
	if o < m {
		for o+n <= m {
			o += n
			ans++
		}
	} else if o > m {
		var q int64
		for o >= m {
			o--
			if q == 0 || q == n {
				ans--
				q = 0
			}
			q++
		}
	}
	O(ans, "\n")
}


package main

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

func solve() {
	people := readInt()
	pillow := readInt()
	k := readInt()
	if people == 1 {
		fmt.Println(pillow)
		return
	}
	pillow -= people
	left := int64(k - 1)
	right := int64(people - k)
	lo := 0
	hi := pillow
	best := 0
	for lo <= hi && pillow > 0 {
		mi := lo + (hi-lo)/2
		rest := int64(pillow - mi)
		step := int64(mi - 1)
		var sum1 int64
		var sum2 int64
		if left > 0 && step > 0 {
			if step < left {
				left = step
			}
			sum1 = int64(step-left+1+step) * left / 2
		}
		if right > 0 && step > 0 {
			if step < right {
				right = step
			}
			sum2 = int64(step-right+1+step) * right / 2
		}
		if sum1+sum2 <= rest {
			lo = mi + 1
			if best < mi {
				best = mi
			}
		} else {
			hi = mi - 1
		}
	}
	fmt.Println(best + 1)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

import "fmt"

func main() {
    var m, n uint64
    fmt.Scan(&n, &m)
    if n > 32 {
        fmt.Print(m)
        return
    }
    var exp uint64 = 1
    for i:=uin64(0); i<n; i++ {
        exp *= 2
    }
    fmt.Print(m % exp)
}


package main

import "fmt"

func result(m, n uint64) uint64 {
	var s uint64 = 1

	for ; n > 0 && s <= m; n-- {
		s = s << 1
	}

	return m % s
}

func main() {
	var n, m uint64
	fmt.Scanf("%d %d", &n, &m)

	fmt.Println(result(m, n))
}


package main

import "fmt"

func main() {
	var n, a, b int
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}
		rest := a - b
		if rest < 0 {
			rest = -rest
		}
		if n/rest <= 2 {
			fmt.Println("Final!")
		} else {
			cnt := 0
			for rest > 0 {
				rest >>= 1
				cnt++
			}
			fmt.Println(cnt)
		}
	}
}


package main

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

func Init() {
}

func Solve(io *FastIO) {
  N := io.NextInt()
	A := io.NextInt()
	B := io.NextInt()

	rounds := 0
	rem := N
	for rem > 1 {
	  rounds++
	  rem >>= 1
	}

	which := 0
	for i := uint(0); ; i++ {
	  bitA := (A >> i) & 1
	  bitB := (B >> i) & 1
	  if bitA != bitB {
	    which = int(i + 1)
	    break
	  }
	}

	if which == rounds {
	  io.Println("Final!")
	} else {
	  io.Println(which)
	}
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


package main

import "fmt"

func main() {
	var n, a, b, ans int
	fmt.Scanf("%d%d%d", &n, &a, &b)
	ans = (a+b)%n + n
	if ans <= 0 {
		ans += n
	}
	fmt.Println(ans)
}


package main

import "fmt"

func main() {
	var n, a, b, ans int
	fmt.Scan("%d%d%d", &n, &a, &b)
	ans = (a+b)%n + n
	if ans <= 0 {
		ans += n
	}
	fmt.Println(ans)
}


package main

import "fmt"

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

	fmt.Printf("%d\n", (a + b + n - 1) % n + 1)
}


package main

import "fmt"

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

	var ret int
	if b == 0 {
		ret = a
	} else {
		if b < 0 {
			b = n - (-b % n)
		}

		ret = ((b % n) + a)
	}

	fmt.Printf("%d", ret)
}


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

package main

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

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

func Solve(n int, L int64, c []int64) int64 {
	for i := 1; i < n; i++ {
		if c[i] > 2*c[i-1] {
			c[i] = 2 * c[i-1]
		}
	}
	ans := int64(math.MaxInt64)
	sum := int64(0)
	for i := n - 1; i >= 0; i-- {
		liters := int64(1 << i)
		if liters <= L {
			bottles := L / liters
			L -= bottles * liters
			sum += bottles * c[i]
		} else {
			ans = min(ans, sum+c[i])
		}
	}
	return min(ans, sum)
}

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

	var n int
	var L int64
	fmt.Fscanf(reader, "%d %d\n", &n, &L)
	c := make([]int64, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &c[i])
	}
	fmt.Fscanf(reader, "\n")

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


package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := strings.TrimSpace(scanner.Text())

	values := make([]int, len(input))
	for i, a := range input {
		values[i] = int(a - '0')
	}

	fmt.Println(makeHappy(values))
}

func makeHappy(values []int) int {
	n := 3
	sumA, sumB := 0, 0
	for i := 0; i < n; i++ {
		sumA += values[i]
		sumB += values[n + i]
	}

	if sumA == sumB {
		return 0
	}

	diff := sumA - sumB

	for i := 0; i < n; i++ {
		a := values[i] - diff
		if a > 0 && a <= 9 {
			return 1
		}
		a = values[n + i] + diff
		if a > 0 && a <= 9 {
			return 1
		}
	}

	valsA := values[:n]
	valsB := values[n:]
	sort.Ints(valsA)
	sort.Ints(valsB)

	if diff > 0 {
		diff -= valsA[2]
		valsA[2] = 0

		diff -= 9 - valsB[0]
		if diff < 0 {
			return 2
		}

		return 3
	}

	diff += valsB[2]
	valsB[2] = 0

	diff += 9 - valsA[0]
	if diff > 0 {
		return 2
	}

	return 3
}


package main

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

func main() {
 reader := bufio.NewReader(os.Stdin)
 arr1 := make([]int, 3)
 arr2 := make([]int, 3)
 for {
  line, _, err := reader.ReadLine()
  if err != nil {
   break
  }
  sum1 := 0
  for i := 0; i < 3; i++ {
   arr1[i] = int(line[i] - '0')
   sum1 += arr1[i]
  }
  sum2 := 0
  for i := 3; i < 6; i++ {
   arr2[i-3] = int(line[i] - '0')
   sum2 += arr2[i-3]
  }
  if sum1 == sum2 {
   fmt.Printf("0\n")
   continue
  }
  if sum1 < sum2 {
   arr1, arr2 = arr2, arr1
   sum1, sum2 = sum2, sum1
  }
  delta := sum1 - sum2
  count := 0
  for {
   sort.Sort(sort.IntSlice(arr1))
   sort.Sort(sort.IntSlice(arr2))
   count++
   if arr1[2] > 9-arr2[0] {
    if arr1[2] > delta {
     break
    }
    delta -= arr1[2]
    arr1[2] = 0
   } else {
    if 9-arr2[0] > delta {
     break
    }
    delta -= (9 - arr2[0])
    arr2[0] = 9
   }

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

 }
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	arr1 := make([]int, 3)
	arr2 := make([]int, 3)
	for {
		line, _, err := reader.ReadLine()
		if err != nil {
			break
		}
		sum1 := 0
		for i := 0; i < 3; i++ {
			arr1[i] = int(line[i] - '0')
			sum1 += arr1[i]
		}
		sum2 := 0
		for i := 3; i < 6; i++ {
			arr2[i-3] = int(line[i] - '0')
			sum2 += arr2[i-3]
		}
		if sum1 == sum2 {
			fmt.Printf("0\n")
			continue
		}
		if sum1 < sum2 {
			arr1, arr2 = arr2, arr1
			sum1, sum2 = sum2, sum1
		}
		delta := sum1 - sum2
		count := 0
		for {
			sort.Sort(sort.IntSlice(arr1))
			sort.Sort(sort.IntSlice(arr2))
			count++
			if arr1[2] > 9-arr2[0] {
				if arr1[2] > delta {
					break
				}
				delta -= arr1[2]
				arr1[2] = 0
			} else {
				if 9-arr2[0] > delta {
					break
				}
				delta -= (9 - arr2[0])
				arr2[0] = 9
			}

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

	}
}


// A. Love "A"
/*
Alice has a string 𝑠. She really likes the letter "a".
She calls a string good if strictly more than half of the characters in
that string are "a"s. For example "aaabb", "axaa" are good strings,
and "baca", "awwwa", "" (empty string) are not.

Alice can erase some characters from her string 𝑠. She would like to know
what is the longest string remaining after erasing some characters
(possibly zero) to get a good string. It is guaranteed that the string has
at least one "a" in it, so the answer always exists.

Input
The first line contains a string 𝑠(1≤|𝑠|≤50) consisting of lowercase
English letters. It is guaranteed that there is at least one "a" in 𝑠.

Output
Print a single integer, the length of the longest good string
that Alice can get after erasing some characters from 𝑠.

Examples
Input
xaxxxxa

Output
3

Input
aaabaa

Output
6

Note
In the first example, it's enough to erase any four of the "x"s.
The answer is 3 since that is the maximum number of characters that can remain.

In the second example, we don't need to erase any characters.
*/
package main

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

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

	sol1146A(strings.TrimSpace(input))
}

func sol1146A(s string) {
	total := len(s)
	m := make(map[rune]int)

	for _, v := range s {
		m[v]++
	}

	for k, v := range m {
		if k != 'a' && m['a'] <= v {
			total -= v - m['a'] + 1
		}
	}
	fmt.Println(total)
}


package main

import "fmt"

func main() {
	var n int
	fmt.Scanf("%d\n", &n)
	res := false
	var c string
	aa := 1234567
	bb := 123456
	cc := 1234
	for i := 0; ; i++ {
		if aa*i > n || res {
			break
		}
		for j := 0; ; j++ {
			if (aa*i+bb*j) > n || res {
				break
			}
			for k := 0; ; k++ {
				if (aa*i+bb*j+cc*k) > n || res {
					break
				}
				res = (aa*i + bb*j + cc*k) == n
			}
		}
	}
	if res {
		c = "YES"
	} else {
		c = "NO"
	}
	fmt.Println(c)
}


package main

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

func main() {
	in, out := bufio.NewReader(os.Stdin), bufio.NewWriter(os.Stdout)
	defer out.Flush()
	a, _ := in.ReadString('\n')
	a = strings.Trim(a, "\r\n")
	n, _ := strconv.ParseInt(string(a), 10, 64)
	for a := int64(0); a <= 1000; a++ {
		for b := int64(0); b <= 1000; b++ {
			if c := (n - a*1234567 + b*123456) / 1234; c >= 0 && a*1234567+b*123456+c*1234 == n {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}


package main

import(
    "fmt"
)

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


package main

import (
    "fmt"
)

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

    var x, y int;
    for x=m/a; x*a < m; x++ {}
    for y=n/a; y*a < n; y++ {}

    fmt.Println(x*y)
}


package main

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

func main() {
  flags := os.Args[1:]

  n, _ := strconv.Atoi(flags[0])
  m, _ := strconv.Atoi(flags[1])
  a, _ := strconv.Atoi(flags[2])

  var ndiva int
  var mdiva int

  if n % a == 0 {
    ndiva = n / a
  } else {
    ndiva = n / a + 1
  }

  if m % a == 0 {
    mdiva = m / a
  } else {
    mdiva = m / a + 1
  }

  //fmt.Println("ndiva: ", ndiva)
  //fmt.Println("mdiva: ", mdiva)

  fmt.Println(ndiva * mdiva)
}


package main

import (
    "fmt"
    "math"
)

func main() {
  var n, m , a, ndiva, mdiva float64

  fmt.Scanf("%f %f %f", &n, &m, &a)

/*
  if n % a == 0 {
    ndiva = n / a
  } else {
    ndiva = n / a + 1
  }

  if m % a == 0 {
    mdiva = m / a
  } else {
    mdiva = m / a + 1
  }
*/

  fmt.Println(math.Ceil(n / a) * math.Ceil(m / a))

  //fmt.Println(ndiva * mdiva)
}


package main

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

func main() {
	n, m, a := s.Next(), s.Next(), s.Next()
	n, m = n / a, m / a
	if n % a != 0 {
		n++
	}
	if m % a != 0 {
	    m++
	}
	s.Println(n * m)
	s.Flush()
}

func init() {
	s := NewInOut(os.Stdin, os.Stdout)
}

var (
	s InOut
)

// IO Lib
type InOut struct {
	*bufio.Reader
	*bufio.Writer
}

func NewInOut(r io.Reader, w io.Writer) *InOut {
	return &InOut{bufio.NewReader(r), bufio.NewWriter(w)}
}

// Get Next Integer
func (s *InOut) Next() (r int) {
	b, _ := s.ReadByte()
	p := 1
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

// Get Next Line String
func (s *InOut) NextLine() (r string) {
	b, _ := s.ReadByte()
	for b == '\n' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\n'; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return string(buf)
}

// Get Next String using delimiter whitespace
func (s *InOut) NextStr() (r string) {
	b, _ := s.ReadByte()
	for b == '\n' || b == ' ' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\n' && b != ' '; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return string(buf)
}

// Print Strings using the suitable way to change type
func (s *InOut) Print(os ...interface{}) {
	for _, o := range os {
		switch o.(type) {
		case byte:
			s.WriteByte(o.(byte))
		case string:
			s.WriteString(o.(string))
		case int:
			s.WriteString(strconv.Itoa(o.(int)))
		case int64:
			s.WriteString(strconv.FormatInt(o.(int64), 10))
		default:
			s.WriteString(fmt.Sprint(o))
		}
	}
}

// Print Strings using the suitable way to change type with new line
func (s *InOut) Println(os ...interface{}) {
	for _, o := range os {
		s.Print(o)
	}
	s.Print("\n")
}

// Print immediately with new line (for debug)
func (s *InOut) PrintlnNow(o interface{}) {
	fmt.Println(o)
}


package main

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

func main() {
	n, m, a := s.NextInt64(), s.NextInt64(), s.NextInt64()
	x, y := n / a, m / a
	if n % a != 0 {
		x++
	}
	if m % a != 0 {
		y++
	}
	s.Println(x * y)
	s.Flush()
}

var (
	s *InOut
)

func init() {
	s = NewInOut(os.Stdin, os.Stdout)
}

type InOut struct {
	*bufio.Reader
	*bufio.Writer
}

func NewInOut(r io.Reader, w io.Writer) *InOut {
	return &InOut{bufio.NewReader(r), bufio.NewWriter(w)}
}

// Get Next Integer
func (s *InOut) Next() (r int) {
	b, _ := s.ReadByte()
	p := 1
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

func (s *InOut) NextInt64() (r int64) {
	b, _ := s.ReadByte()
	p := 1
	for (b < '0' || '9' < b) && b != '-' {
		b, _ = s.ReadByte()
	}
	if b == '-' {
		p = -1
		b, _ = s.ReadByte()
	}
	for '0' <= b && b <= '9' {
		r = 10*r + int64(b-'0')
		b, _ = s.ReadByte()
	}
	return r * p
}

// Get Next Line String
func (s *InOut) NextLine() (r string) {
	b, _ := s.ReadByte()
	for b == '\n' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\n'; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return string(buf)
}

// Get Next String using delimiter whitespace
func (s *InOut) NextStr() (r string) {
	b, _ := s.ReadByte()
	for b == '\n' || b == ' ' {
		b, _ = s.ReadByte()
	}
	buf := make([]byte, 0)
	for ; b != '\n' && b != ' '; b, _ = s.ReadByte() {
		buf = append(buf, b)
	}
	return string(buf)
}

// Print Strings using the suitable way to change type
func (s *InOut) Print(os ...interface{}) {
	for _, o := range os {
		switch o.(type) {
		case byte:
			s.WriteByte(o.(byte))
		case string:
			s.WriteString(o.(string))
		case int:
			s.WriteString(strconv.Itoa(o.(int)))
		case int64:
			s.WriteString(strconv.FormatInt(o.(int64), 10))
		default:
			s.WriteString(fmt.Sprint(o))
		}
	}
}

// Print Strings using the suitable way to change type with new line
func (s *InOut) Println(os ...interface{}) {
	for _, o := range os {
		s.Print(o)
	}
	s.Print("\n")
}

// Print immediately with new line (for debug)
func (s *InOut) PrintlnNow(o interface{}) {
	fmt.Println(o)
}


package main

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

type Scanner struct {
  r            io.Reader
  split        bufio.SplitFunc
  maxTokenSize int
  token, buf   []byte
  start, end   int
}

func NewScanner(r io.Reader) *Scanner {
  return &Scanner{
    r:            r,
    split:        bufio.ScanWords,
    maxTokenSize: 16777216,
    buf:          make([]byte, 4096),
  }
}

func (s *Scanner) advance(n int) bool {
  if n < 0 || n > s.end-s.start {
    return false
  }
  s.start += n
  return true
}

func (s *Scanner) Text() string {
  return string(s.token)
}

func (s *Scanner) Scan() bool {
  for {
    if s.end > s.start {
      advance, token, err := s.split(s.buf[s.start:s.end], false)
      if err != nil || !s.advance(advance) {
        return false
      }
      s.token = token
      if token != nil {
        return true
      }
    }
    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
    }
    if s.end == len(s.buf) {
      if len(s.buf) >= s.maxTokenSize {
        return false
      }
      newSize := len(s.buf) * 2
      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
    }
    for loop := 0; ; {
      n, _ := s.r.Read(s.buf[s.end:len(s.buf)])
      s.end += n
      if n > 0 {
        break
      }
      loop++
      if loop > 100 {
        break
      }
    }
  }
}

func (s *Scanner) Split(split bufio.SplitFunc) {
  s.split = split
}

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

func next() string { sc.Scan(); return sc.Text() }
func nc() byte     { sc.Scan(); return sc.Text()[0] }

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

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

func pri32(i ...int) {
  for _, ii := range i {
    w.WriteString(strconv.Itoa(ii))
    sp()
  }
}
func pri64(i ...int64) {
  for _, ii := range i {
    w.WriteString(strconv.FormatInt(ii, 10))
    sp()
  }
}
func sp()   { w.WriteByte(' ') }
func endl() { w.WriteByte('\n') }

func main() {
  n := ni64()
  if n%3 != 0 {
    pri64(n/3 + 1)
  } else {
    pri64(n / 3)
  }
  endl()
  w.Flush()
}


package main

import (
    "fmt"
    )

func get_weight(piece byte) int {
    reverse := false
    if piece >= 'a' && piece <= 'z' {
        reverse = true
        piece = piece - 'a' + 'A'
    }

    ret := 0
    switch piece {
        case 'Q':
            ret = 9
        case 'R':
            ret = 5
        case 'B':
            ret = 3
        case 'K':
            ret = 3
        case 'P':
            ret = 1
    }

    if reverse {
        return -ret
    }
    return ret
}

func main() {
    var line string
    score := 0
    for i := 0; i < 8; i++ {
        fmt.Scan(&line)
        for j := 0; j < len(line); j++ {
            if (line[j] >= 'a' && line[j] <= 'z') || (line[j] >= 'A' && line[j] <= 'Z') {
                score += get_weight(line[j])
            }
        }
    }

    if score == 0 {
        fmt.Println("Draw")
    } else if score > 0 {
        fmt.Println("White")
    } else {
        fmt.Println("Black")
    }
}


package main

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

func main() {
	reader := bufio.NewReader(os.Stdin)
	var n, m int
	fmt.Fscan(reader, &n, &m)

	var vl int

	if ok := m % n; ok == 0 {
		vl = m / n
	} else {
		fmt.Println(-1)
		return
	}

	var count int
	for vl > 1 {
		if vl%3 == 0 {
			vl /= 3
			count++
		} else if vl%2 == 0 {
			vl /= 2
			count++
		}
	}

	fmt.Println(count)
}


package main

import (
	"fmt"
	"math"
)

func main() {
	var r, h float64
	fmt.Scan(&r, &h)
	h, count := h-r*math.Floor(h/r), 2*int(h/r)
	if h >= r*(math.Sqrt(3)+6)/4 {
		count += 3
	} else if h >= r/2 {
		count += 2
	} else {
		count += 1
	}
	fmt.Println(count)
}


package main

func main() {
    var limak, bob int
    fmt.Scanf("%d %d\n", &limak, &bob)
    var res int
    for {
        if limak > bob {
            break
        }
        limak *= 3
        bob *= 2
        res++
    }
    fmt.Println(res)
}


package main

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

var (
  in *bufio.Reader
  out *bufio.Writer
)

func main() {
  in = bufio.NewReader(os.Stdin)
  out = bufio.NewWriter(os.Stdout)
  var b int64
  fmt.Fscanln(in, &b)
  var count int64 = 0
  for  i:=int64(1);i<=b;i++ {
    if (b%i == 0) {
      count++
    }
  }
  fmt.Println(count)

}


package main

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

var (
  in *bufio.Reader
  out *bufio.Writer
)

func main() {
  in = bufio.NewReader(os.Stdin)
  out = bufio.NewWriter(os.Stdout)
  var b int64
  fmt.Fscanln(in, &b)
  var count int64 = 0
  for  i:=int64(1);i<int64(math.Sqrt(float64(b)));i++ {
    if (b%i == 0) {
      count+=2
    }
  }
  a := math.Sqrt(float64(b))
  if float64(int64(a)) == a {
    count+=1
  }
  fmt.Println(count)
}


package main

import (
	"fmt"
)

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


package main

import (
	"fmt"
)

func main() {
	var b, res int64
	fmt.Scan(&b)
	for i := int64(1); i <= b; i++ {
		if b%i == 0 {

			res++
		}
	}
	fmt.Println(res)
}


package main

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

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

	input, _, _ := reader.ReadLine()
	value, _ := strconv.Atoi(string(input))

	resultNumber := 0

	for i := 1; i <= value; i++ {
		newVal := strconv.Itoa(i)

		result := true

		for j := 0; j < len(newVal); j ++ {
			if string(newVal[j]) != "1" && string(newVal[j]) != "0" {
				result = false
				break
			}
		}

		if result {
			resultNumber++
		}
	}

	fmt.Println(resultNumber)
}


package main

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

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

	input, _, _ := reader.ReadLine()
	value, _ := strconv.Atoi(string(input))

	resultNumber := 0

	for i := 01;true; i++ {
		if value < math.Pow(10, i) {
			break
		} else {
			resultNumber++
		}
	}

	fmt.Println(resultNumber)
}


package main

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

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

	input, _, _ := reader.ReadLine()
	value, _ := strconv.Atoi(string(input))

	resultNumber := 0

	for i := 0;true; i++ {
		if float64(value) < math.Pow(10, float64(i)) {
			break
		} else {
			resultNumber++
		}
	}

	fmt.Println(resultNumber)
}


package main

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

func main() {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n, s string
	fmt.Fscan(in, &n)
	// normalize n: base 10 -> base 2
	for _, d := range n {
		if d >= '1' {
			s += "1"
		} else {
			s += "0"
		}
	}
	ans, _ := strconv.ParseInt(s, 2, 32)
	fmt.Fprintln(out, ans)
}


package main

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

var stdReader *bufio.Reader = bufio.NewReader(os.Stdin)

func readInt() (result int) {
	var negative, started bool
READER_LOOP:
	for {
		char, err := stdReader.ReadByte()
		switch {
		case err != nil:
			break READER_LOOP
		case char == '-':
			negative = true
		case unicode.IsDigit(rune(char)):
			started = true
			result = result*10 + int(char&0xf)
		case started:
			break READER_LOOP
		}
	}
	if negative {
		result = -result
	}
	return
}

func main() {
	n := readInt()

	// dp[][0] - Vasya rested
	// dp[][1] - Vasya wrote contest
	// dp[][2] - Vasya practiced in a gym
	dp := make([][3]int, n+1)
	for i := 1; i <= n; i++ {
		// dp[i][0]
		dp[i][0] = dp[i-1][0]
		if dp[i-1][1] > dp[i][0] {
			dp[i][0] = dp[i-1][1]
		}
		if dp[i-1][2] > dp[i][0] {
			dp[i][0] = dp[i-1][2]
		}

		input := readInt()
		// dp[i][1]
		if input == 1 || input == 3 {
			dp[i][1] = dp[i-1][0]
			if dp[i-1][2]+1 > dp[i][1] {
				dp[i][1] = dp[i-1][2] + 1
			}
		}

		// dp[i][2]
		if input == 2 || input == 3 {
			dp[i][2] = dp[i-1][0]
			if dp[i-1][1]+1 > dp[i][2] {
				dp[i][2] = dp[i-1][1] + 1
			}
		}
	}

	answer := dp[n][0]
	if dp[n][1] > answer {
		answer = dp[n][1]
	}
	if dp[n][2] > answer {
		answer = dp[n][2]
	}
	fmt.Println(n - answer)
}


package main

import (
    "fmt"
)

func toNum(s string) int {
    h := (int(s[0]) - int('0')) * 10 + (int(s[1]) - int('0'))
    m := (int(s[3]) - int('0')) * 10 + (int(s[4]) - int('0'))
    return h * 60 + m
}

func isPalindrome(n int) bool {
    h := n / 60
    m := n % 60

    a := fmt.Sprintf("%02d:%02d", h, m)
    for i := 0; i < len(a); i++ {
        if a[i] != a[len(a) - 1 - i] {
            return false
        }
    }
    return true
}

func main() {
    var s string
    for {
        _, err := fmt.Scan(&s)
        if err != nil { break }

        n := toNum(s)
        t := 0
        for {
            if isPalindrome(n) {
                break
            }
            t++
            n = (n + 1) % (24 * 60)
            if (t > 10) { break }
        }
        fmt.Println(t)
    }
}


package main

import (
	"fmt"
)

func isPalindrome(tt int) bool {
	return tt%60%10 == tt/60/10 && tt%60/10 == tt/60%10
}

func main() {
	var hh, mm int
	for exitCode, err := fmt.Scanf("%d:%d", &hh, &mm); exitCode != -1 && err == nil; {
		tt := hh*60 + mm
		for i := 0; ; i++ {
			if isPalindrome(tt) {
				fmt.Printf("%d\n", i)
				break
			}
			tt = (tt + 1) % (24 * 60)
		}
	}
}


package main

import (
	"bufio"
	"fmt"
	"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 PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		writer.WriteByte(' ')
	}
}

func main() {
	//fmt.Scanf("%d%d",&n, &k)
	scanner.Split(bufio.ScanWords)
	var row string
	var length, index int
	var arr [100]int
	_ = ReadInt32()
	fmt.Scanf("%s", &row)
	for i := 0; i < len(row); i++ {
		if row[i] == 'B' {
			length++
		} else if row[i] != 'B' && length > 0 {
			arr[index] = length
			index++
			length = 0
		}
	}
	if length != 0 {
		arr[index] = length
		index++
	}
	fmt.Println(index)
	for i := 0; i < index; i++ {
		fmt.Println(arr[i], " ")
	}
}


package main

import (
	"bufio"
	"fmt"
	"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 PrintInts(ints ...int) {
	for _, value := range ints {
		writer.WriteString(strconv.Itoa(value))
		writer.WriteByte(' ')
	}
}

func main() {
	//fmt.Scanf("%d%d",&n, &k)
	scanner.Split(bufio.ScanWords)
	var row string
	var length, index int
	var arr [100]int
	n := ReadInt32()
	fmt.Scanf("%s", &row)
	for i := 0; i < n; i++ {
		if row[i] == 'B' {
			length++
		} else if row[i] != 'B' && length > 0 {
			arr[index] = length
			index++
			length = 0
		}
	}
	if length != 0 {
		arr[index] = length
		index++
	}
	fmt.Println(index)
	for i := 0; i < index; i++ {
		fmt.Println(arr[i], " ")
	}
}


package main

import "fmt"

func main() {
    var n int
    fmt.Scan(&n)
    groups := make([]int, n)
    var s string
    fmt.Scan(&s)
    s += 'W'
    var lastRune rune = 'W'
    var groupCnt int
    var curGroup int
    for _, r := range s {
        if r == 'B' {
            curGroup++
            if lastRune == 'W' {
                groupCnt++
            }
            lastRune = 'B'
        } else if r == 'W' {
            if lastRune == 'B' {
                groups[groupCnt-1] = curGroup
            }
            lastRune = 'W'
            curGroup = 0
        }
    }
    fmt.Print(groupCnt, "\n")
    for i:=0; i < groupCnt; i++ {
        fmt.Print(groups[i], " ")
    }
}


package main

import (
	"fmt"
)

func main() {
	var a, b int
	fmt.Scanf("%d %d", &a, &b)
	ans := 0
	for a > 1 || b > 1 {
		if a > b {
			a, b = b, a
		}
		a += 1
		b -= 2
		ans++
	}
	fmt.Println(ans - 1)
}


package main

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

const (
	cha = 2
)

type Joystick struct {
	Charge   int
	Charging bool
}

func main() {

	min := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := scanner.Text()
	charges := strings.Split(input, " ")

	v, _ := strconv.Atoi(charges[0])
	j1 := Joystick{v, false}
	v, _ = strconv.Atoi(charges[1])
	j2 := Joystick{v, false}

	if j1.Charge < j2.Charge {
		j1.Charging = true
	} else {
		j2.Charging = true
	}

	// fmt.Println(j1, j2)

	for {
		if j1.Charge <= 0 || j2.Charge <= 0 {
			break
		}
		min++
		if j1.Charging == true {
			j1.Charge++
			j2.Charge -= 2
		} else {
			j2.Charge++
			j1.Charge -= 2
		}
		if j1.Charge < j2.Charge {
			j1.Charging = true
			j2.Charging = false
		} else {
			j2.Charging = true
			j1.Charging = false
		}

	}
	fmt.Println(min)

}


package main

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

const (
	cha = 2
)

type Joystick struct {
	Charge   int
	Charging bool
}

func main() {

	min := 0

	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	input := scanner.Text()
	charges := strings.Split(input, " ")

	v, _ := strconv.Atoi(charges[0])
	j1 := Joystick{v, false}
	v, _ = strconv.Atoi(charges[1])
	j2 := Joystick{v, false}

	if j1.Charge < j2.Charge {
		j1.Charging = true
	} else {
		j2.Charging = true
	}

	// fmt.Println(j1, j2)

	if j1.Charge == 1 && j2.Chrage == 1 {
		fmt.Println(0)
		return
	}
	for {
		if j1.Charge <= 0 || j2.Charge <= 0 {
			break
		}
		min++
		if j1.Charging == true {
			j1.Charge++
			j2.Charge -= 2
		} else {
			j2.Charge++
			j1.Charge -= 2
		}
		if j1.Charge < j2.Charge {
			j1.Charging = true
			j2.Charging = false
		} else {
			j2.Charging = true
			j1.Charging = false
		}

	}
	fmt.Println(min)

}


package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, a, b int
	fmt.Scanf("%d\n%d\n%d", &n, &a, &b)
	frames := make([]int, 6)
	for i := 0; i < 6; i++ {
		if i < 4 {
			frames[i] = a
		} else {
			frames[i] = b
		}
	}
	sort.Ints(frames)
	count := 0
	leftover := 0

	for i := 0; i < 6; i++ {
		if leftover >= frames[i] {
			leftover -= frames[i]
			continue
		}
		if i > 0 {
			if leftover+frames[i-1]-frames[i] >= 0 {
				count++
				leftover = n - frames[i]
				continue
			}
		}
		count++
		leftover = n - frames[i]
	}
	fmt.Println(count)
}


package main

import (
  "fmt"
)

var n int32
var a int32
var b int32

func ReadData() {
  fmt.Scanf("%d", &n);
  fmt.Scanf("%d", &a);
  fmt.Scanf("%d", &b);
}

func Solve(na int32, nb int32, current int32) int {
  if na == 0 && nb == 0 {
    return 0;
  }

  var r0 int = 1000;
  var r1 int = 1000;
  var r2 int = 1000;

  if 0 < na && a <= current {
    r0 = Solve(na - 1, nb, current - a);
  }
  if 0 < nb && b <= current {
    r1 = Solve(na, nb - 1, current - b);
  }
  if current < a && current < b {
    r2 = 1 + Solve(na, nb, n);
  }
  result := r0
  if r1 < result {
    result = r1
  }
  if r2 < result {
    result = r2
  }

  return result
}

func main() {
  ReadData();
  fmt.Println(Solve(4, 2, 0));
}


package main

import (
	"fmt"
	"strconv"
)

func main() {
	var k string
	fmt.Scan(&k)
	var sum int
	for i := 0; i < len(k); i++ {
		a, _ := strconv.Atoi(string(k[i]))
		sum += a
	}
	var sub int
	sub = 10 - sum
	fmt.Println(k + strconv.Itoa(sub))
}


package main

import "fmt"

func is_perfect_like_mikey(i int) bool{
    s := 0
    for i > 0 {
        s+=(i%10)
        i=i/10
    }
    return(s==10)
}
func main() {
    mike_is_my_daddy := 0
    fmt.Scan(&mike_is_my_daddy)
    cnt := 0
    for i := 0; ; i++ {
        if(is_perfect_like_mikey(i)) {
            cnt++
        }
        if cnt == mike_is_daddy {
            fmt.Println(i)
            break
        }
    }
}


package main

import "fmt"

func main(){
    var x int
    fmt.Scan(&x)
    x=10+x*9
    fmt.Print(x)
}


package main

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

func main() {
	var (
		n     int
		moves string
	)
	stdin := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdin, "%d\n%s", &n, &moves)

	moves = strings.Replace(moves, "RU", "D", -1)
	moves = strings.Replace(moves, "UR", "D", -1)
	fmt.Println(len(moves))
}


package main
import "fmt"

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

    c:=0;
    for i:=0;i<n-1;{
        if s[i]==s[i+1]{
            i+=1;
        } else{
            c+=1;
            i+=2;
        }
    }
    fmt.Println((n-c))
}


package main

import (
  "fmt"
  "strings"
)

var n int
var str string
func main() {
	fmt.Scanf("%d\n", &n)
	fmt.Scanf("%s", &str)
	newStr := strings.Replace(str, "UR", "D", -1)
	newStr = strings.Replace(newStr, "RU", "D", -1)
	fmt.Println(len(newStr))
}


package main
import (
	"fmt"
	"sort"
)

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


package main

import "fmt"

func equal(a, b []byte) bool {
	if len(a) != len(b) {
		return false
	}
	var n = len(a)
	for i := 0; i < n; i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func main() {
	var input, answer []byte
	fmt.Scanf("%s\n%s", &input, &answer)
	var digits [10]int
	var n = len(input)
	for i := 0; i < n; i++ {
		digits[int(input[i]-'0')]++
	}
	var ans = make([]byte, 0)
	for i := 1; i < 10; i++ {
		if digits[i] > 0 {
			for digits[i] > 0 {
				ans = append(ans, byte(i+'0'))
				digits[i]--
			}
			break
		}
	}

	for i := 0; i < 10; i++ {
		for digits[i] > 0 {
			ans = append(ans, byte(i+'0'))
			digits[i]--
		}
	}

	if equal(ans, answer) {
		fmt.Println("OK")
	} else {
		fmt.Println("WRONG_ANSWER")
	}
}


package main

import (
    "fmt"
    "sort"
)

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

    digit := make([]int, 0, 10)
    for tmp:=a; tmp>0; {
        digit = append(digit, tmp%10)
        tmp /= 10
    }
    sort.Ints(digit)

    zeros := 0
    c = 0
    for _, x := range digit {
        if x == 0 {
            zeros++
        }else {
            if zeros > 0 {
                c = x
                for zeros > 0 {
                    c *= 10
                    zeros--
                }
            }else {
                c *= 10
                c += x
            }
        }
    }

    if b == c {
        fmt.Println("OK")
    }else {
        fmt.Println("WRONG_ANSWER")
    }
}


package main

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

func Abs(x int) int {
	switch {
	case x < 0:
		return -x
	case x == 0:
		return 0
	}
	return x
}

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

func Scan(args ...interface{}) (e error)             { _, e = fmt.Fscan(in, args...); return }
func Scanf(ft string, args ...interface{}) (e error) { _, e = fmt.Fscanf(in, ft, args...); return }
func Scanln(args ...interface{}) (e error)           { _, e = fmt.Fscanln(in, args...); return }
func Print(args ...interface{})                      { out.WriteString(fmt.Sprint(args...)) }
func Printf(ft string, args ...interface{})          { out.WriteString(fmt.Sprintf(ft, args...)) }
func Println(args ...interface{})                    { out.WriteString(fmt.Sprintln(args...)) }

var (
	dataIn = "data.in"
	in     = bufio.NewReader(os.Stdin)
	//in, _ = os.Open(dataIn)
	out = bufio.NewWriter(os.Stdout)
)

var n int

func bis(num int) int {
	l := 1
	r := num
	for l <= r {
		mid := (l + r) >> 1
		if mid*(mid+1)/2 > num {
			r = mid - 1
		} else {
			l = mid + 1
		}
	}
	return r
}

func solve() {
	m := bis(n)
	if n == m*(m+1)/2 {
		Println(m)
	} else {
		Println(n - m*(m+1)/2)
	}
}

func main() {
	defer out.Flush()
	for Scan(&n) != io.EOF {
		solve()
		out.Flush()
	}
	return
}


package main

import (
    "fmt"
)

func f(i int) int {
    i += 1
    for i%10 == 0 {
        i /= 10
    }
    return i
}

func main() {
    var N int
    fmt.Scan(&N)
    set := make(map[int]bool)
    cnt := 1
    for {
        N = f(N)
        if set[N] {
            break
        }
        set[N] = true
        cnt+=1
    }
    fmt.Println(cnt)
}


package main

import "fmt"

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

	res := 1

	if x == 1 {
		fmt.Println(9)
		return
	}

	for x != 0 {
		x += 1

		for x % 10 == 0 {
			x = x / 10
		}

		res += 1
	}

	fmt.Println(res)
}


package main

import "fmt"

func main() {
	var x int64
	fmt.Scan(&x)
	m := make(map[int64]bool, 1e5)
	f := func(x int64) int64 {
		x++
		for x%10 == 0 {
			x /= 10
		}
		return x
	}
	m[x] = true
	for {
		x = f(x)
		m[x] = true
		if x == 1 {
			break
		}
	}
	fmt.Println(len(m))
}


import "fmt"

func main()  {
	var n int32
	fmt.Scanf("%d",&n)
	var i int32
	i = n
	var ans int32
	i ++
	ans += 2
	for true{
		if(i == 10){
			break
		}
		if i % 10 == 0 {
			for i % 10 == 0{
				i /= 10
			}
		}
		i ++
		ans ++
	}
	fmt.Println(ans)

}


package main

import "fmt"

func check(x [4]string, a int, b int) bool {
    cnt := 0
    for i := a; i < (a+2); i++ {
        for j := b; j < (b+2); j++ {
            if x[i][j] != x[a][b] { cnt++ }
        }
    }
    if cnt <= 1 { return true } else { return false }
}

func main() {
    var x [4]string
    for i := 0; i < 4; i++ {
        fmt.Scan(&x[i])
    }
    ans := false
    for i := 0; i < 3; i++ {
        for j := 0; j < 3; j++ {
            if check(x,i,j) {
                ans = true
                break
            }
        }
    }
    if ans { fmt.Println("YES") } else { fmt.Println("NO") }
}


package main

import "fmt"

func main() {
	s := make([]string, 4)
	for i := range s {
		fmt.Scanln(&s[i])
	}
	for i := 0; i < 2; i++ {
		for j := 0; j < 2; j++ {
			cnt := 0
			if s[i][j] == '.' {
				cnt++
			}
			if s[i+1][j] == '.' {
				cnt++
			}
			if s[i][j+1] == '.' {
				cnt++
			}
			if s[i+1][j+1] == '.' {
				cnt++
			}
			if cnt <= 1 || cnt >= 3 {
				fmt.Println("YES")
				return
			}
		}
	}
	fmt.Println("NO")
}


package main

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

var n int
var a []int

func main() {
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)
	fmt.Fscanf(reader, "%d%d\n", &n)
	a = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscanf(reader, "%d", &a[i])
	}

	ans := 0
	for i := 2; i <= 100; i++ {
		flag := false

		for j := 0; j < n; j++ {
			if a[j] == -1 {
				continue
			}
			if a[j]%i == 0 {
				a[j] = -1
				flag = true
			}
		}

		if flag {
			ans++
		}
	}

	fmt.Println(ans)
}


package main

import "testing"

func Test_paintTheNumbers(t *testing.T) {
	type args struct {
		n     int
		slice []int
	}
	tests := []struct {
		name string
		args args
		want int
	}{
		{
			name: "TC_01",
			args: args{
				n:     6,
				slice: []int{10, 2, 3, 5, 4, 2},
			},
			want: 3,
		},
	}
	for _, tt := range tests {
		t.Run(tt.name, func(t *testing.T) {
			if got := paintTheNumbers(tt.args.n, tt.args.slice); got != tt.want {
				t.Errorf("paintTheNumbers() = %v, want %v", got, tt.want)
			}
		})
	}
}


package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func main() {
	defer writer.Flush()
	ch := string("")
	scanf("%s", &ch)
	num := []byte(ch)
	s1 := uint64(1)
	for _, char := range num {
		s, _ := strconv.ParseUint(string(char), 10, 64)
		s1 *= s
	}
	for i, char := range num {
		if char == '0' {
			break
		}
		num1 := []byte{}
		num1 = num
		num1[i] = num[i] - 1
		s2 := uint64(1)
		for j, char := range num1 {
			var number uint64
			if j <= i {
				number, _ = strconv.ParseUint(string(char), 10, 64)
				if number == 0 {
					number = 1
				}
			} else {
				number = 9
			}
			s2 *= number
		}
		if s2 > s1 {
			s1 = s2
		}
	}
	printf("%d\n", s1)

}


package main

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

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

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

	mat := make([]int64, 20)
	len := 0
	for n > 0 {
		mat[len] = n % int64(10)
		n /= 10
		len++
	}
	for i := len - 1; i >= 0; i-- {
		if mat[i] == 0 {
			for j := i + 1; j < len; j++ {
				mat[j]--
				if mat[j] > 0 || (mat[j] == 0 && j == len-1) {
					for k := j - 1; k >= 0; k-- {
						mat[k] = 9
					}
					break
				}
			}
			break
		}
	}
	//fmt.Printf("%v\n",mat)
	for i := len; i >= 0; i-- {
		if mat[i] > 0 {
			len = i + 1
			break
		}
	}
	var le int64 = 1
	var ans int64 = 1
	var tmp int64 = 1
	for i := 0; i < len; i++ {
		ans *= mat[i]
		le *= 9
	}
	//fmt.Printf("-%d len=%d %v\n",ans,len,mat)

	for i:=len-1;i>=0;i--{
		le/=9
		if mat[i] > 1{
			if tmp*(mat[i]-1)*le > ans{
				ans=tmp*(mat[i]-1)*le
			}
		}
		tmp *= mat[i]
	}
	fmt.Printf("%d\n",ans)
}


package main

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

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

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

	n, x := nextInt64(), nextInt64()
	cnt := 0
	i := int64(0)

	for i = 1; i <= n && i*i < x; i++ {
		if x%i == 0 && x/i <= n {
			cnt += 2
		}
	}

	if i*i == x {
		cnt += 1
	}

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


import "fmt"
func ptich(x,n int) int{
    dem := 2
    i := 2
    for ; i * i < x; i++{
        if x % i == 0 && i <= n && x / i <= n{
            dem += 2
        }
    }
    if i * i == x{
        dem++
    }
    return dem
}
func main() {
    var n, x int
    fmt.Scanf("%d%d",&n,&x)
    fmt.Println(ptich(x,n))
}


package main

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

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 main() {
	var T, x, result, i, j uint64
	scanf("%d %d\n", &T, &x)

	result = 0

	if x <= 10 {
		result++
	}
	for i=2; i<=T; i++ {
		if x % i == 0 {
			for j=1; j<=T; j++ {
				if x == i * j {
					result++
				}
			}

		}
	}

	fmt.Println(result)

}


package main

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

const INF  = 1000000001

type Pair struct {
	first, second int
}

func sort(arr []Pair) []Pair {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i].first > arr[right].first {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort(arr[:left])
	sort(arr[left+1:])
	return arr
}

func sort2(arr []int) []int {
	if len(arr) < 2 {
		return arr
	}
	left := 0
	right := len(arr) - 1
	pivot := rand.Int() % len(arr)

	arr[pivot], arr[right] = arr[right], arr[pivot]

	for i := 0; i < len(arr); i++ {
		if arr[i] < arr[right] {
			arr[i], arr[left] = arr[left], arr[i]
			left++
		}
	}

	arr[left], arr[right] = arr[right], arr[left]

	sort2(arr[:left])
	sort2(arr[left+1:])
	return arr
}

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

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

func solution(reader io.Reader, writer io.Writer) {
	var n, x, r int64
	fmt.Fscanf(reader, "%d %d\n", &n, &x)
	for i := int64(1); i <= int64(math.Sqrt(float64(x))); i++ {
		if x % i == 0 && x / i <= n {
			r += 2
		}
	}
	fmt.Println(r)
}

func main() {

	//stdin, err := os.Open("file.in")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdin.Close()
	stdin := os.Stdin
	reader := bufio.NewReaderSize(stdin, 1024*1024)

	//stdout, err := os.Create("file.out")
	//if err != nil {
	//	panic(err)
	//}
	//defer stdout.Close()
	stdout := os.Stdout
	writer := bufio.NewWriterSize(stdout, 1024*1024)
	defer writer.Flush()

	solution(reader, writer)
}


package main

import "fmt"

func min(a,b int) int  {
	if(a < b){
		return a
		}
	return b
}
func ab(x int) int {
	if(x <= -1){
		x *= -1
	}
	return x
}
//a b c d e f g h j k l m n o p q r s t u v w x y z
func calc(s string) (res int) {

	res += min(ab(int(s[0]) - int('A')) ,ab(int('Z') - int(s[0])) + 1)
	res += min(ab(int(s[1]) - int('C')),ab(int('Z') - int(s[1])) + 3)
	res += min(ab(int(s[2])- int('T')),min(ab(int('Z') - int(s[2])) + 20,ab(int('A') - int(s[2]))+6))
	res += min(ab(int(s[3])- int('G')),ab(int('Z') - int(s[3])) + 7)
	return
}

func main()  {
	var n int
	var s string
	fmt.Scan(&n)
	fmt.Scan(&s)
	ans := 123456789
	for i := 0 ; i < n - 3;i++{
		temp := ""
		for j := i ; j <= i + 3;j++{
			temp += string(s[j])
		}
		ans = min(ans,calc(temp))
	}
	fmt.Print(ans)
	// 1
	//3
	//6
	//7

}


package main

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

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

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

func getLine() string {
	s, _ := reader.ReadString('\n')
	if strings.HasSuffix(s, "\r\n") {
		s = s[:len(s)-2]
	} else if strings.HasSuffix(s, "\n") {
		s = s[:len(s)-1]
	}
	return s
}
func getLine2Int() (n int) {
	scanf("%d\n", &n)
	return
}
func getLine2Int2() (a, b int) {
	scanf("%d %d\n", &a, &b)
	return
}
func dis(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a

}

var debug = false

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

func main() {
	defer writer.Flush()
	n := getLine2Int()
	s := getLine()
	min := 52
	for i := 3; i < n; i++ {
		tmp := 13 - dis(int(s[i-3]-'A')%26, 13)
		see(tmp)
		tmp += 13 - dis(int(s[i-2]-'C')%26, 13)
		see(tmp)
		tmp += 13 - dis(int(s[i-1]-'T')%26, 13)
		see(tmp)
		tmp += 13 - dis(int(s[i]-'G')%26, 13)
		see(tmp)
		if min > tmp {
			min = tmp
		}
	}
	printf("%d\n", min)
}