Polycarpus has postcards and photos hung in a row on the wall. He decided to put them away to the closet and hang on the wall a famous painter's picture. Polycarpus does it like that: he goes from the left to the right and removes the objects consecutively. As Polycarpus doesn't want any mix-ups to happen, he will not carry in his hands objects of two different types. In other words, Polycarpus can't carry both postcards and photos simultaneously. Sometimes he goes to the closet and puts the objects there, thus leaving his hands free. Polycarpus must put all the postcards and photos to the closet. He cannot skip objects. What minimum number of times he should visit the closet if he cannot carry more than 5 items?

The only line of the input data contains a non-empty string consisting of letters "С" and "P" whose length does not exceed 100 characters. If the i-th character in the string is the letter "С", that means that the i-th object (the numbering goes from the left to the right) on Polycarpus' wall is a postcard. And if the i-th character is the letter "P", than the i-th object on the wall is a photo.

Print the only number — the minimum number of times Polycarpus has to visit the closet.

CPCPCPC CCCCCCPPPPPP CCCCCCPPCPPPPPPPPPP CCCCCCCCCC

NoteIn the first sample Polycarpus needs to take one item to the closet 7 times.In the second sample Polycarpus can first take 3 postcards to the closet; then 3 more. He can take the 6 photos that are left in the similar way, going to the closet twice.In the third sample Polycarpus can visit the closet twice, both times carrying 3 postcards. Then he can take there 2 photos at once, then one postcard and finally, he can carry the last 10 photos if he visits the closet twice.In the fourth sample Polycarpus can visit the closet twice and take there all 10 postcards (5 items during each go).

package main

import "fmt"

func main() {
    var s string
    fmt.Scan(&s)
    ans, cnt, prev := 0, 0, '_'
    for _, v := range s {
        if cnt == 5 {
            prev = '_'
        }
        if v == prev {
            cnt++
        } else {
            ans++
            cnt = 1
            prev = v
        }
    }
    fmt.Println(ans)
}

// 284B
package main

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

func main() {
	in := bufio.NewScanner(os.Stdin)
	nm := 3
	st := make([]int, nm)
	var n int
	var ln string
	in.Scan()
	n, _ = strconv.Atoi(in.Text())
	ln = in.Text()
	for i := 0; i < n; i++ {
		if ln[i] == 'F' {
			st[0]++
		}
		if ln[i] == 'I' {
			st[1]++
		}
		if ln[i] == 'A' {
			st[2]++
		}
	}
	var out int
	out = 0
	if st[1] == 0 {
		out = n - (st[0])
	}
	if st[1] == 1 {
		out = 1
	}
	fmt.Println(out)
}


Vasya plays the sleuth with his friends. The rules of the game are as follows: those who play for the first time, that is Vasya is the sleuth, he should investigate a "crime" and find out what is happening. He can ask any questions whatsoever that can be answered with "Yes" or "No". All the rest agree beforehand to answer the questions like that: if the question’s last letter is a vowel, they answer "Yes" and if the last letter is a consonant, they answer "No". Of course, the sleuth knows nothing about it and his task is to understand that.Unfortunately, Vasya is not very smart. After 5 hours of endless stupid questions everybody except Vasya got bored. That’s why Vasya’s friends ask you to write a program that would give answers instead of them.The English alphabet vowels are: A, E, I, O, U, YThe English alphabet consonants are: B, C, D, F, G, H, J, K, L, M, N, P, Q, R, S, T, V, W, X, Z

The single line contains a question represented by a non-empty line consisting of large and small Latin letters, spaces and a question mark. The line length does not exceed 100. It is guaranteed that the question mark occurs exactly once in the line — as the last symbol and that the line contains at least one letter.

Print answer for the question in a single line: YES if the answer is "Yes", NO if the answer is "No". Remember that in the reply to the question the last letter, not the last character counts. I. e. the spaces and the question mark do not count as letters.

Is   it an apple  and a  banana   simultaneouSLY?

package main

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

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

//49A
package main
import (
	"fmt"
	"os"
	"bufio"
)

func main() {
	var q string
	var i int
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanLines)
	r.Scan()
	q=r.Text()
	i=len(q)-2
	for i>=0 {
		if q[i]==' ' {
			i--
		} else if q[i]=='a' || q[i]=='A' || q[i]=='e' || q[i]=='E' || q[i]=='u' || q[i]=='U' || q[i]=='y' || q[i]=='Y' || q[i]=='i' || q[i]=='I' || q[i]=='o' || q[i]=='O' {
		fmt.Println("YES")
			break
		} else {
			fmt.Println("NO")
			break
		}
	}
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Scan()
    for i := len(scanner.Text())-1; i >= 0; i-- {
        c := strings.ToUpper(string(scanner.Text()[i]))[0]
        if (c >= 'A') && (c <= 'Z') {
            if (c == 'A') || (c == 'E') || (c == 'I') || (c == 'O') || (c == 'U') || (c == 'Y') {
                fmt.Println("YES")
            } else {
                fmt.Println("NO")
            }
            break
        }
    }
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin) // variabel scanner adalah bufio yang menunjukan scanner baru
    scanner.Scan() //fungsi scanner scan
    for i := len(scanner.Text())-1; i >= 0; i-- { // lakukan selama kondisi ini
        c := strings.ToUpper(string(scanner.Text()[i]))[0] // variabel c aadlah string yang menunjuk kedalam toupper
        if (c >= 'A') && (c <= 'Z') { //lakukan selam kondisi ini
            if (c == 'A') || (c == 'E') || (c == 'I') || (c == 'O') || (c == 'U') || (c == 'Y') { // lakukan selam kondisi ini
                fmt.Println("YES") // mencetak output
            } else { //
                fmt.Println("NO") //mencetak output
            }
            break // berhenti
        }
    }
}

package main

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

func check(upper string, vowel []string) bool {
	for _, letter := range vowel {
		if upper == letter {
			return true
		}
	}

	return false
}

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

	vowel := []string{ "A", "E", "I", "O", "U", "Y" }

	scanner.Scan()
	for i := len(scanner.Text()) - 1; i >= 0; {
		upper := strings.ToUpper(string(scanner.Text()[i]))
		if upper != " " && upper != "?" {
			checkVowel := check(upper, vowel)
			if checkVowel {
				fmt.Printf("%s", "YES")
				return
			} else {
				fmt.Printf("%s", "NO")
				return
			}
		} else {
			i --;
		}
	}

	// fmt.Println(scanner.Text())
	// fmt.Println(vowel)
}

// 49A-mic
package main

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

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

package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var question string
	var vowel = map[string]bool{
		"a": true,
		"e": true,
		"u": true,
		"o": true,
		"i": true,
		"y": true,
	}

	scanner.Scan()
	question = scanner.Text()

	question = question[0 : len(question)-1]
	question = strings.TrimSpace(question)

	if _, ok := vowel[strings.ToLower(string(question[len(question)-1]))]; ok {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
}

package main

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

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 println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scanln(a ...interface{})           { fmt.Fscanln(reader, a...) }

func main() {
	defer writer.Flush()
	s,_ := reader.ReadString('\n')
	s = strings.Replace(s, " ", "", -1)
	s = strings.Replace(s, "?", "", -1)
	s = strings.ToUpper(s)

	flag := true
	for _, a := range []byte{'A', 'E', 'I', 'O', 'U', 'Y'} {
		if a == s[len(s)-3] {
			flag = false
			break
		}
	}
	if flag {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

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

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

package main

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

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

package main

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

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 println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scanln(a ...interface{})           { fmt.Fscanln(reader, a...) }

func main() {
	defer writer.Flush()
	s,_ := reader.ReadString('\n')
	s = strings.Replace(s, " ", "", -1)
	s = strings.Replace(s, "?", "", -1)
	s = strings.ToUpper(s)

	flag := true
	for _, a := range []byte{'A', 'E', 'I', 'O', 'U', 'Y'} {
		if a == s[len(s)-1] {
			flag = false
			break
		}
	}
	if flag {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}

package main

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

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 println(a ...interface{})          { fmt.Fprintln(writer, a...) }
func scanln(a ...interface{})           { fmt.Fscanln(reader, a...) }

func main() {
	defer writer.Flush()
	s,_ := reader.ReadString('\n')
	s = strings.Replace(s, " ", "", -1)
	s = strings.Replace(s, "?", "", -1)
	s = strings.ToUpper(s)

	flag := true
	for _, a := range []byte{'A', 'E', 'I', 'O', 'U', 'Y'} {
		if a == s[len(s)-2] {
			flag = false
			break
		}
	}
	if flag {
		fmt.Println("NO")
	} else {
		fmt.Println("YES")
	}
}


Trouble came from the overseas lands: a three-headed dragon Gorynych arrived. The dragon settled at point C and began to terrorize the residents of the surrounding villages.A brave hero decided to put an end to the dragon. He moved from point A to fight with Gorynych. The hero rode from point A along a straight road and met point B on his way. The hero knows that in this land for every pair of roads it is true that they are either parallel to each other, or lie on a straight line, or are perpendicular to each other. He also knows well that points B and C are connected by a road. So the hero must either turn 90 degrees to the left or continue riding straight ahead or turn 90 degrees to the right. But he forgot where the point C is located.Fortunately, a Brave Falcon flew right by. It can see all three points from the sky. The hero asked him what way to go to get to the dragon's lair.If you have not got it, you are the falcon. Help the hero and tell him how to get him to point C: turn left, go straight or turn right.At this moment the hero is believed to stand at point B, turning his back to point A.

The first input line contains two space-separated integers xa, ya (|xa|, |ya| ≤ 109) — the coordinates of point A. The second line contains the coordinates of point B in the same form, the third line contains the coordinates of point C. It is guaranteed that all points are pairwise different. It is also guaranteed that either point B lies on segment AC, or angle ABC is right.

Print a single line. If a hero must turn left, print "LEFT" (without the quotes); If he must go straight ahead, print "TOWARDS" (without the quotes); if he should turn right, print "RIGHT" (without the quotes).

NoteThe picture to the first sample: The red color shows points A, B and C. The blue arrow shows the hero's direction. The green color shows the hero's trajectory.The picture to the second sample:

package main

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

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

func equal(x, y float64) bool {
	delta := x-y
	if (delta < 0) {
		delta *= -1
	}
	return delta <= 1e-6
}

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

	ax, ay := scanInt(scanner), scanInt(scanner)
	bx, by := scanInt(scanner), scanInt(scanner)
	cx, cy := scanInt(scanner), scanInt(scanner)
	x0, y0 := float64(bx-ax), float64(by-ay)
	l0 := math.Hypot(x0, y0)
	x0 /= l0
	y0 /= l0
	x1, y1 := float64(cx-bx), float64(cy-by)
	l1 := math.Hypot(x1, y1)
	x1 /= l1
	y1 /= l1
	if equal(x1, x0) && equal(y1, y0) {
		writer.WriteString("TOWARDS\n")
	} else if equal(x1, -y0) && equal(y1, x0) {
		writer.WriteString("LEFT\n")
	} else {
		writer.WriteString("RIGHT\n")
	}
}

package main

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

func scanInt64(scanner *bufio.Scanner) int64 {
	scanner.Scan()
	x, _ := strconv.ParseInt(scanner.Text(), 10, 64)
	return x
}

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

	ax, ay := scanInt64(scanner), scanInt64(scanner)
	bx, by := scanInt64(scanner), scanInt64(scanner)
	cx, cy := scanInt64(scanner), scanInt64(scanner)
	x0, y0 := bx-ax, by-ay
	x1, y1 := cx-bx, cy-by
	cross := x0*y1 - x1*y0
	if cross == 0 {
		writer.WriteString("TOWARDS\n")
	} else if cross > 0 {
		writer.WriteString("LEFT\n")
	} else {
		writer.WriteString("RIGHT\n")
	}
}

// 227A
package main

import (
	"fmt"
)

func main() {
	var a1, a2, b1, b2, c1, c2, x, y, z float64
	fmt.Scan(&a1, &a2)
	fmt.Scan(&b1, &b2)
	fmt.Scan(&c1, &c2)
	x = (b1 - a1) * (c2 - b2)
	y = (c1 - b1) * (b2 - a2)
	z = x - y
	if z == 0 {
		fmt.Print("TOWARDS")
	} else if z < 0 {
		fmt.Print("RIGHT")
	} else {
		fmt.Print("LEFT")
	}
}

package main

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

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

func sign(x int) int {
	y := x
	if (y == 0) {
		return 0
	}
	if (y < 0) {
		return -1
	}
	return 1
}

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

	ax, ay := scanInt(scanner), scanInt(scanner)
	bx, by := scanInt(scanner), scanInt(scanner)
	cx, cy := scanInt(scanner), scanInt(scanner)
	x0, y0 := float64(bx-ax), float64(by-ay)
	l0 := math.Hypot(x0, y0)
	x0 /= l0
	y0 /= l0
	x1, y1 := float64(cx-bx), float64(cy-by)
	l1 := math.Hypot(x1, y1)
	x1 /= l1
	y1 /= l1
	//writer.WriteString(fmt.Sprintf("(%.8f, %.8f) (%.8f, %.8f), dot product = %.8f\n",
	//		x0, y0, x1, y1, x0*x1 + y0*y1))
	if x1 == x0 && y1 == y0 {
		writer.WriteString("TOWARDS\n")
	} else if x1 == -y0 && y1 == x0 {
		writer.WriteString("LEFT\n")
	} else {
		writer.WriteString("RIGHT\n")
	}
}

package main

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

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

	ax, ay := scanInt(scanner), scanInt(scanner)
	bx, by := scanInt(scanner), scanInt(scanner)
	cx, cy := scanInt(scanner), scanInt(scanner)
	x0, y0 := bx-ax, by-ay
	x1, y1 := cx-bx, cy-by
	cross := x0*y1 - x1*y0
	if cross == 0 {
		writer.WriteString("TOWARDS\n")
	} else if cross > 0 {
		writer.WriteString("LEFT\n")
	} else {
		writer.WriteString("RIGHT\n")
	}
}


Let's denote a function $$$f(x)$$$ in such a way: we add $$$1$$$ to $$$x$$$, then, while there is at least one trailing zero in the resulting number, we remove that zero. For example,   $$$f(599) = 6$$$: $$$599 + 1 = 600 \rightarrow 60 \rightarrow 6$$$;  $$$f(7) = 8$$$: $$$7 + 1 = 8$$$;  $$$f(9) = 1$$$: $$$9 + 1 = 10 \rightarrow 1$$$;  $$$f(10099) = 101$$$: $$$10099 + 1 = 10100 \rightarrow 1010 \rightarrow 101$$$. We say that some number $$$y$$$ is reachable from $$$x$$$ if we can apply function $$$f$$$ to $$$x$$$ some (possibly zero) times so that we get $$$y$$$ as a result. For example, $$$102$$$ is reachable from $$$10098$$$ because $$$f(f(f(10098))) = f(f(10099)) = f(101) = 102$$$; and any number is reachable from itself.You are given a number $$$n$$$; your task is to count how many different numbers are reachable from $$$n$$$.

The first line contains one integer $$$n$$$ ($$$1 \le n \le 10^9$$$).

Print one integer: the number of different numbers that are reachable from $$$n$$$.

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
    set[N] = true
    for {
        N = f(N)
        if set[N] {
            break
        }
        set[N] = true
        cnt+=1
    }
    fmt.Println(cnt)
}

package main

import (
	"fmt"
)

func Reachable_number(n int) int {
	cnt := 0
	for n > 0 {
		cnt++
		if n < 10 {
			cnt += 8
			break
		} else {
			n++
		}
		for n%10 == 0 {
			n /= 10
		}
	}
	return cnt
}

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

package main

import (
	"fmt"
)

func main() {
	var n int
	cnt := 0
	fmt.Scanf("%d\n", &n)
	for n > 0 {
		cnt++
		if n < 10 {
			cnt += 8
			break
		} else {
			n++
		}
		for n%10 == 0 {
			n /= 10
		}
		// fmt.Printf("%d\n", n)
	}
	fmt.Printf("%d\n", cnt)
}

package main

import "fmt"

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

	res := 1

	numbers := map[int]bool{x: true}

	for {
		x += 1

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

		if _, ok := numbers[x]; ok {
			break
		}

		numbers[x] = true
		res += 1
	}

	fmt.Println(res)
}

package main

import "fmt"

var n int

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

	ans := 0

	for n >= 10 {
		last := 10 - n%10

		ans = (ans + last)
		n = n + last

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

	}

	fmt.Println(ans + 9)
}

// ProblemURL : https://codeforces.com/problemset/problem/1157/A
// ---------------------------------------------
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)
		if _, exists := m[x]; exists {
			break
		}
		m[x] = true
	}
	fmt.Println(len(m))
}

package main

import (
	"fmt"
)

func solve(n int) int {
	m := map[int]bool{}
	m[n] = true

	for ok := false; !ok; {

		n++

		for n > 0 && n%10 == 0 {
			n /= 10
		}

		ok = m[n]
		m[n] = true
	}

	return len(m)
}

func main() {
	var n int

	fmt.Scan(&n)

	ans := solve(n)
	fmt.Println(ans)
}

package main

import "fmt"

func main()  {
	var n int
	fmt.Scanf("%d",&n)
	var i int
	i = n
	m := map[int]bool{}
	for true{
		if(m[i] == false) {
		m[i] = true
		i ++
		for i % 10 == 0{
			i /= 10
		}

		} else {
			break;
		}

	}
	fmt.Println(len(m))

}

package main

import (
	"fmt"
)

func main() {
	var i int
	fmt.Scanf("%d", &i)
	j := i
	m := make(map[int]int)
	for m[1] < 2 {
		i += 1
		for i % 10 == 0 {
			i /= 10
		}
		m[i] += 1
		// fmt.Println(i)
	}
	m[j] += 1
	fmt.Println(len(m))
}

package main

import (
	"fmt"
)

func main() {
	var n int;
	cnt := 0
	fmt.Scanf ( "%d", &n )
	for n % 10 != n {
		cnt++
		n++
		for n % 10 == 0 {
			n /= 10
		}
	}

	cnt += 9;

	fmt.Println ( cnt )
}

package main

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

// var input, inputerr = os.Open("./input")
// var output, outputerr = os.Create("./output")
// var reader = bufio.NewReader(input)
// var writer = bufio.NewWriter(output)

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

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

func min(a ...int) int {
	min := -1
	for _, val := range a {
		if val < min {
			min = val
		}
	}
	return min
}

func max(a ...int) int {
	max := -1
	for _, val := range a {
		if val > max {
			max = val
		}
	}
	return max
}

func tr(n int) int {
	for n%10 == 0 {
		n = n / 10
	}
	return n
}

func main() {
	defer writer.Flush() // STDOUT MUST BE FLUSHED MANUALLY!!!
	var n int
	scan(&n)
	cnt := 0
	m := map[int]bool{}

	for {
		if m[n] == false {
			m[n] = true
			cnt++
		} else {
			break
		}
		n++
		n = tr(n)
	}
	print(cnt)
}

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

	for x != 1 {
		x += 1

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

		res += 1
	}

	fmt.Println(res)
}

package main

import "fmt"

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

	res := 1

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

	for x != 1 {
		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))
}

package main

import "fmt"

func main()  {
	var n int32
	fmt.Scanf("%d",&n)
	var i int32
	i = n
	m := map[int32]bool{}
	m[i] = true
	i ++
	m[1] = true
	for true{
		if(i == 10){
			break
		}
		if i % 10 == 0 {
			for i % 10 == 0{
				i /= 10
			}
		}
		m[i] = true
		i ++

	}
	fmt.Println(len(m))

}

package main

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 main()  {
	var n int32
	fmt.Scanf("%d",&n)
	var i int32
	i = n
	m := map[int32]bool{}
	m[i] = true
	i ++
	for true{
		if(i == 10){
			break
		}
		if i % 10 == 0 {

			for i % 10 == 0{
				m[i] = true
				i /= 10

			}
		}
		m[i] = true
		i ++

	}
	fmt.Println(len(m))

}

package main

import "fmt"

func main()  {
	var n int32
	fmt.Scanf("%d",&n)
	var i int32
	i = n
	m := map[int32]bool{}
	m[i] = true
	i ++
	for true{
		if(i == 10){
			break
		}
		if i % 10 == 0 {

			for i % 10 == 0{
				i /= 10
			}
		}
		m[i] = true
		i ++

	}
	fmt.Println(len(m) + 1)

}

package main

import (
	"fmt"
)

func main() {
	var i int
	fmt.Scanf("%d", &i)
	j := i
	m := make(map[int]int)
	for m[1] == 0 || i == 1 {
		i += 1
		for i % 10 == 0 {
			i /= 10
		}
		m[i] += 1
	}
	m[j] += 1
	fmt.Println(len(m))
}


You are given a string $$$s$$$ consisting of lowercase Latin letters. Let the length of $$$s$$$ be $$$|s|$$$. You may perform several operations on this string.In one operation, you can choose some index $$$i$$$ and remove the $$$i$$$-th character of $$$s$$$ ($$$s_i$$$) if at least one of its adjacent characters is the previous letter in the Latin alphabet for $$$s_i$$$. For example, the previous letter for b is a, the previous letter for s is r, the letter a has no previous letters. Note that after each removal the length of the string decreases by one. So, the index $$$i$$$ should satisfy the condition $$$1 \le i \le |s|$$$ during each operation.For the character $$$s_i$$$ adjacent characters are $$$s_{i-1}$$$ and $$$s_{i+1}$$$. The first and the last characters of $$$s$$$ both have only one adjacent character (unless $$$|s| = 1$$$).Consider the following example. Let $$$s=$$$ bacabcab.  During the first move, you can remove the first character $$$s_1=$$$ b because $$$s_2=$$$ a. Then the string becomes $$$s=$$$ acabcab.  During the second move, you can remove the fifth character $$$s_5=$$$ c because $$$s_4=$$$ b. Then the string becomes $$$s=$$$ acabab.  During the third move, you can remove the sixth character $$$s_6=$$$'b' because $$$s_5=$$$ a. Then the string becomes $$$s=$$$ acaba.  During the fourth move, the only character you can remove is $$$s_4=$$$ b, because $$$s_3=$$$ a (or $$$s_5=$$$ a). The string becomes $$$s=$$$ acaa and you cannot do anything with it. Your task is to find the maximum possible number of characters you can remove if you choose the sequence of operations optimally.

The only line of the input contains one integer $$$|s|$$$ ($$$1 \le |s| \le 100$$$) — the length of $$$s$$$. The second line of the input contains one string $$$s$$$ consisting of $$$|s|$$$ lowercase Latin letters.

Print one integer — the maximum possible number of characters you can remove if you choose the sequence of moves optimally.

NoteThe first example is described in the problem statement. Note that the sequence of moves provided in the statement is not the only, but it can be shown that the maximum possible answer to this test is $$$4$$$.In the second example, you can remove all but one character of $$$s$$$. The only possible answer follows.  During the first move, remove the third character $$$s_3=$$$ d, $$$s$$$ becomes bca.  During the second move, remove the second character $$$s_2=$$$ c, $$$s$$$ becomes ba.  And during the third move, remove the first character $$$s_1=$$$ b, $$$s$$$ becomes a.

package main

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

var reader io.Reader
var scanner *bufio.Scanner

func Init(io io.Reader, max_token_size int) {
	reader = bufio.NewReader(io)
	scanner = bufio.NewScanner(reader)
	// max token size
	scanner.Split(bufio.ScanWords)
	scanner.Buffer([]byte{}, max_token_size)
}

func stderr(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
}

func die(v ...interface{}) {
	fmt.Fprintln(os.Stderr, v...)
	os.Exit(1)
}

func NextInt() int {
	bytes := NextBytes()
	i, err := Atoi(bytes)
	if err != nil {
		die(err)
	}
	return i
}

func NextBytes() []byte {
	if !scanner.Scan() {
		die(scanner.Err())
	}
	bytes := scanner.Bytes()
	copied := make([]byte, len(bytes))
	copy(copied, bytes)
	return copied
}

func Atoi(b []byte) (int, error) {
	neg := false
	if b[0] == '+' {
		b = b[1:]
	} else if b[0] == '-' {
		neg = true
		b = b[1:]
	}
	n := 0
	for _, v := range b {
		if v < '0' || v > '9' {
			return 0, strconv.ErrSyntax
		}
		n = n*10 + int(v-'0')
	}
	if neg {
		return -n, nil
	}
	return n, nil
}

func ExtendByteArray(a []byte, size int) []byte {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]byte, size-len(a))...)
	}
}

func ExtendIntArray(a []int, size int) []int {
	if size <= len(a) {
		return a
	} else {
		return append(a, make([]int, size-len(a))...)
	}
}

func canRemove(i int, s []byte, n int) bool {
	ok := false
	if i > 0 && s[i] > 'a' && s[i-1]-'a' == (s[i]-'a'-1) {
		ok = true
	}
	if i+1 < n && s[i] > 'a' && s[i+1]-'a' == (s[i]-'a'-1) {
		ok = true
	}
	return ok
}

func main() {
	inf := os.Stdin
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	// inf, err := os.Open("a.in")
	// if err != nil {
	// 	die(err)
	// }
	// out, err := os.Create("a.out")
	// if err != nil {
	// 	die(err)
	// }
	// defer out.Close()
	Init(inf, 1000010)

	n := NextInt()
	s := NextBytes()
	var removed int
	for {
		removal := -1
		for ch := 26; removal == -1 && ch >= 0; ch-- {
			for i := 0; removal == -1 && i < n; i++ {
				if s[i] == byte(ch+'a') && canRemove(i, s, n) {
					removal = i
				}
			}
		}
		if removal == -1 {
			break
		}
		s = append(s[:removal], s[removal+1:]...)
		removed++
		n--
		// stderr("parti", string(s), n)
	}
	fmt.Fprintln(out, removed)
}

/*
URL:
https://codeforces.com/problemset/problem/1321/C
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n int
	S []rune
)

func main() {
	n = ReadInt()
	S = ReadRuneSlice()

	ans := 0
	for len(S) > 1 {
		next := false
		maxR := rune(0)
		idx := -1

		for i := 0; i < len(S); i++ {
			if i == 0 && S[i]-S[i+1] == 1 {
				if ChMax(&maxR, S[i]) {
					idx = i
				}

				next = true
				continue
			}
			if i == len(S)-1 && S[i]-S[i-1] == 1 {
				if ChMax(&maxR, S[i]) {
					idx = i
				}

				next = true
				continue
			}

			if 0 < i && i < len(S)-1 && (S[i]-S[i-1] == 1 || S[i]-S[i+1] == 1) {
				if ChMax(&maxR, S[i]) {
					idx = i
				}

				next = true
			}
		}

		if next {
			ans++
			tmp := []rune{}
			for i := 0; i < len(S); i++ {
				if i == idx {
					continue
				}

				tmp = append(tmp, S[i])
			}

			S = tmp
		} else {
			break
		}
	}

	fmt.Println(ans)
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

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

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

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

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

	deleted := make(map[int]bool)

	count := 0
	for ch := byte('z'); ch >= 'a'; ch-- {
		for i, _ := range s {
			cur := s[i]
			if cur != ch {
				continue
			}

			can := false

			j := i
			for j >= 0 && (deleted[j] || s[j] == cur) {
				j--
			}
			if j >= 0 && s[j]+1 == cur {
				can = true
			}

			j = i
			for j < n && (deleted[j] || s[j] == cur) {
				j++
			}
			if j < n && s[j]+1 == cur {
				can = true
			}

			if can {
				deleted[i] = true
				count++
			}
		}
	}

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

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

package main

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

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

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

	if n == 1 {
		Fprintln(out, 0)
		return
	}
	s = append([]byte{0}, s...)
	s = append(s, 0)

	ans := 0
	//s2 := []byte{}
	//for i := byte('z'); i >= 'a'; i-- {
	//	lp := 0
	//	for j, b := range s {
	//		//if j > 0 && lc == 0 {
	//		//	lc = s[j-1]
	//		//}
	//		if b == i && (s[j]-1 == s[lp] || s[j]-1 == s[j+1]) {
	//			ans++
	//
	//		} else {
	//			s2 = append(s2, b)
	//			lp = j
	//		}
	//	}
	//	s = s2
	//	s2 = []byte{}
	//}

	for curB := byte('z'); curB >= 'a'; curB-- {
		for {
			del := false
			for i, b := range s {
				if b == curB && (s[i]-1 == s[i-1] || s[i]-1 == s[i+1]) {
					ans++
					del = true
					s = append(s[:i], s[i+1:]...)
				}
			}
			if !del {
				break
			}
		}
	}

	Fprintln(out, ans)
}

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

package main

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

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

	var n, ans int
	var s []byte
	Fscan(in, &n, &s)
	s = append([]byte{0}, s...)
	s = append(s, 0)
	for curB := byte('z'); curB >= 'a'; curB-- {
	outer:
		for {
			for i, b := range s {
				if b == curB && (b-1 == s[i-1] || b-1 == s[i+1]) {
					ans++
					s = append(s[:i], s[i+1:]...)
					continue outer
				}
			}
			break
		}
	}
	Fprint(out, ans)
}

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

package main

import "fmt"

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	rls := solve(n, s)
	fmt.Println(rls)
}

func solve(n int, s string) int {
	chs := []rune(s)
	for ch := 'z'; ch > 'a'; ch-- {
		for i := 1; i < len(chs); i++ {
			for i < len(chs) && chs[i] == ch && chs[i-1] == ch-1 {
				chs = append(chs[:i], chs[i+1:]...)
			}
		}
		for i := len(chs) - 2; i >= 0; i-- {
			if i+1 < len(chs) && chs[i] == ch && chs[i+1] == ch-1 {
				chs = append(chs[:i], chs[i+1:]...)
			}
		}
	}
	return len(s) - len(chs)
}

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

package main

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

func Solve(n int, s string) int {
	c := 0
	letters := "abcdefghijklmnopqrstuvwxyz"
	a := []byte(s)
	i := 25
	flag := false
	for i > 0 {
		l := letters[i]
		p := letters[i-1]
		for j, elem := range a {
			if elem == l && ((j-1 >= 0 && a[j-1] == p) || (j+1 < len(a) && a[j+1] == p)) {
				a = append(a[:j], a[j+1:]...)
				c += 1
				flag = true
				break
			}
		}
		if !flag {
			i -= 1
		}
		flag = false
	}
	return c
}

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

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

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

package main

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

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

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

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

	count := 0

	redo := true
	for redo {
		redo = false
		mp := make(map[int]bool)
		for i := 0; i < len(s)-1; i++ {
			if s[i] == s[i+1]+1 {
				for i < len(s)-1 && s[i] == s[i+1]+1 {
					mp[i] = true
					redo = true
					count++
					i++
				}
			} else if s[i] == s[i+1]-1 {
				for i < len(s)-1 && s[i] == s[i+1]-1 {
					mp[i+1] = true
					redo = true
					count++
					i++
				}
			}
		}

		b := new(strings.Builder)
		for i := 0; i < len(s); i++ {
			if !mp[i] {
				fmt.Fprintf(b, "%c", s[i])
			}
		}

		s = b.String()
	}

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

package main

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

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

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

	if n == 1 {
		Fprintln(out, 0)
		return
	}

	dp := make([][][26][26]int, n)
	for _i := range dp {
		dp[_i] = make([][26][26]int, n)
		for _j := range dp[_i] {
			for i := range dp[_i][_j] {
				for j := range dp[_i][_j][i] {
					dp[_i][_j][i][j] = -1
				}
			}
		}
	}

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

	var f func(l, r int, lc, rc byte) int
	f = func(l, r int, lc, rc byte) (_ans int) {
		if l == 0 &&r==1 {
			print()
		}

		dv := &dp[l][r][lc-'a'][rc-'a']
		if *dv >= 0 {
			return *dv
		}
		defer func() { *dv = _ans }()

		if l == r {
			if s[l]-1 == lc || s[l]-1 == rc {
				return 1
			}
			return 0
		}

		for i := l; i <= r; i++ {
			if i == l {
				if s[l]-1 == lc || s[l]-1 == s[l+1] {
					v := f(l+1, r, lc, rc)
					_ans = max(_ans, v+1)
				}
			} else if i == r {
				if s[r]-1 == rc || s[r]-1 == s[r-1] {
					v := f(l, r-1, lc, rc)
					_ans = max(_ans, v+1)
				}
			} else {
				if s[i]-1 == s[i-1] || s[i]-1 == s[i+1] {
					v1 := f(l, i-1, lc, s[i+1])
					v2 := f(i+1, r, s[i-1], rc)
					_ans = max(_ans, v1+v2+1)
				}
			}
		}

		return
	}

	ans := f(0, n-1, 'z', 'z')
	Fprintln(out, ans)

}

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

package main

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

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

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

	if n == 1 {
		Fprintln(out, 0)
		return
	}
	s = append([]byte{0}, s...)
	s = append(s, 0)

	ans := 0
	s2 := []byte{}
	for i := byte('z'); i >= 'a'; i-- {
		lp := 0
		for j, b := range s {
			//if j > 0 && lc == 0 {
			//	lc = s[j-1]
			//}
			if b == i && (s[j]-1 == s[lp] || s[j]-1 == s[j+1]) {
				ans++

			} else {
				s2 = append(s2, b)
				lp = j
			}
		}
		s = s2
		s2 = []byte{}
	}

	Fprintln(out, ans)

}

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

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

package main

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

func Range(arr []int) (int, int) {
	max := arr[0]
	min := arr[0]
	for _, elem := range arr {
		if elem > max {
			max = elem
		}
		if elem < min {
			min = elem
		}
	}
	return min, max
}

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

func _Solve(arr []int, moves int, min int, max int, current int, n int) int {
	if n == 1 || current == min-1 {
		return moves
	}
	newArr := []int{}
	removed := false
	for i := 0; i < n; i++ {
		if removed && arr[i] == current {
			moves += 1
			removed = true
		} else if arr[i] == current && i+1 < n && Abs(arr[i+1]-current) == 1 {
			moves += 1
			removed = true
		} else if arr[i] == current && i-1 >= 0 && Abs(arr[i-1]-current) == 1 {
			moves += 1
			removed = true
		} else {
			newArr = append(newArr, arr[i])
			removed = false
		}
	}
	return _Solve(newArr, moves, min, max, current-1, len(newArr))
}

func Solve(n int, s string) int {
	arr := make([]int, n)
	for i, elem := range s {
		arr[i] = int(elem)
	}
	min, max := Range(arr)
	return _Solve(arr, 0, min, max, max, n)
}

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

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

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

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

package main

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

func Solve(n int, s string) int {
	a := make([]int, n)
	for i, elem := range s {
		a[i] = int(elem)
	}
	for i := 122; i >= 97; i-- {
		for j := 0; j < len(a); j++ {
			if a[j] == i && ((j+1 < len(a) && a[j+1] == i-1) || (j-1 >= 0 && a[j-1] == i-1)) {
				a = append(a[:j], a[j+1:]...)
				j -= 1
			}
		}
	}
	return n - len(a)
}

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

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

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

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

package main

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

type Group struct {
	count int
	elem  int
}

func group(a []int) []Group {
	groups := []Group{}
	for i, elem := range a {
		if i == 0 {
			groups = append(groups, Group{count: 1, elem: elem})
		} else if groups[len(groups)-1].elem == elem {
			groups[len(groups)-1].count += 1
		} else {
			groups = append(groups, Group{count: 1, elem: elem})
		}
	}
	return groups
}

func _Solve(groups []Group, current int, min int, moves int) int {
	if current == min-1 {
		return moves
	}
	newGroups := []Group{}
	for i, group := range groups {
		if group.elem == current && i+1 < len(groups) && groups[i+1].elem == current-1 {
			moves += group.count
		} else if group.elem == current && i-1 >= 0 && groups[i-1].elem == current-1 {
			moves += group.count
		} else {
			newGroups = append(newGroups, group)
		}
	}
	return _Solve(newGroups, current-1, min, moves)
}

func Solve(n int, s string) int {
	a := make([]int, n)
	for i, elem := range s {
		a[i] = int(elem)
	}
	groups := group(a)
	return _Solve(groups, 122, 97, 0)
}

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

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

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


The input contains a single integer a (0 ≤ a ≤ 1 000 000).

package main

import "fmt"

func main() {
	var a, b int
	fmt.Scanln(&a)
	b = 0
	for a != 0 {
		if a%8 == 1 {
			b++
		}
		a /= 8
	}
	fmt.Println(b)
}


Top-model Izabella participates in the competition. She wants to impress judges and show her mathematical skills.Her problem is following: for given string, consisting of only 0 and 1, tell if it's possible to remove some digits in such a way, that remaining number is a representation of some positive integer, divisible by 64, in the binary numerical system.

In the only line given a non-empty binary string s with length up to 100.

Print «yes» (without quotes) if it's possible to remove digits required way and «no» otherwise.

NoteIn the first test case, you can get string 1 000 000 after removing two ones which is a representation of number 64 in the binary numerical system.You can read more about binary numeral system representation here: https://en.wikipedia.org/wiki/Binary_system

package main

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

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

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

func readInt() int {
	var o, neg bool
	var i int
	b, err := r.ReadByte()
	for err == nil {
		if b != ' ' && b != '\n' && b != '\r' {
			if b == '-' {
				neg = true
			} else {
				i = i*10 + int(b) - 48
				o = true
			}
		} else if o {
			break
		}
		b, err = r.ReadByte()
	}
	if neg {
		return -i
	}
	return i
}

func writeInt(i int) {
	if i < 0 {
		w.WriteByte('-')
		i = -i
	}
	if i < 10 {
		w.WriteByte(byte(i + 48))
		return
	}
	var tmp, count int
	tmp = i
	for tmp%10 == 0 {
		tmp /= 10
		count++
	}
	tmp = 0
	for i != 0 {
		tmp = tmp*10 + (i % 10)
		i /= 10
	}
	for tmp != 0 {
		w.WriteByte(byte((tmp % 10) + 48))
		tmp /= 10
	}
	for count > 0 {
		count--
		w.WriteByte('0')
	}
}

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

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

func main() {
	var s string
	for I(&s) == nil {
		solve(s)
	}
	w.Flush()
}

func solve(s string) {
	for i := range s {
		if s[i] == '1' && strings.Count(s[i:], "0") > 5 {
			O("yes\n")
			return
		}
	}
	O("no\n")
}

package main

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

var local = false
var scanner *bufio.Scanner

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

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

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

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

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

package main

import (
	"fmt"
)

func main() {
	var (
		str string
		cnt int
	)
	found := false
	fmt.Scanf("%s", &str)
	for i := range str {
		if str[i] == '1' {
			found = true
		} else if str[i] == '0' && found {
			cnt++
		}
	}
	if cnt >= 6 {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}

package main

import (
	"fmt"
)

func main() {
	var input string
	fmt.Scanln(&input)
	var count0, i int
	for count0, i = 0, len(input)-1; i>=0; i-- {
		if input[i] == '0' {
			count0++
		}
		if count0 == 6 {
			break
		}
	}
	for i = i-1; i>=0; i-- {
		if input[i] == '1' {
			fmt.Println("yes")
			return
		}
	}
	fmt.Println("no")
}

package main

import (
	"fmt"
)

func main() {
	var input string
	fmt.Scanf("%s\n", &input)

	can := false

	zeros := 0
	for i := len(input) - 1; i >= 0; i-- {
		if input[i] == '0' {
			zeros++
		} else if zeros >= 6 {
			can = true

			break
		}
	}

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

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

package main

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

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

	if strings.Count(in, "0") >= 6 && strings.Count(in[:len(in)-6], "1") > 0 {
	}

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

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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

package main

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

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

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

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

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

package main

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

func solve() {
	a := readString()
	cnt := 0
	for i := len(a) - 1; i >= 0; i-- {
		if a[i] == '0' {
			cnt++
			if cnt == 6 {
				for j := i - 1; j >= 0; j-- {
					if a[j] == '1' {
						fmt.Println("yes")
						return
					}
				}
				fmt.Println("no")
				return
			}
		}
	}
	fmt.Println("no")
}

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 abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

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

// IO

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

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

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

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

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

package main

import (
	"fmt"
)

func main() {
	var input string
	fmt.Scanf("%s\n", &input)

	if len(input) >= 7 {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}
}

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

package main

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

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

	if strings.Count(in, "0") < 6 {
		fmt.Println("no")
	} else {
		fmt.Println("yes")
	}

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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

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

package main

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

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

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

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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

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

package main

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

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

	if strings.Count(in, "0") < 6 && strings.Count(in, "0") > 0 {
		fmt.Println("no")
	} else {
		fmt.Println("yes")
	}

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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

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

package main

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

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

	if strings.Count(in, "0") >= 6 && strings.Count(in, "1") > 0 && strings.Index(in, "1") <= len(in)-6 {
		fmt.Println("yes")
	} else {
		fmt.Println("no")
	}

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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

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

package main

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

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

	if strings.Count(in, "0") < 6 || strings.Count(in, "1") == 0 {
		fmt.Println("no")
	} else {
		fmt.Println("yes")
	}

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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

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

package main

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

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

	if strings.Count(in, "0") < 6 && strings.Count(in, "1") > 0 {
		fmt.Println("no")
	} else {
		fmt.Println("yes")
	}

}

// Input helpers

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

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

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

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

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

	return
}

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

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

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

	return
}

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

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

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

	return
}

// Math helpers

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

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

package main

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

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

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

package main

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

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

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

package main

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

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

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


Little Joty has got a task to do. She has a line of n tiles indexed from 1 to n. She has to paint them in a strange pattern.An unpainted tile should be painted Red if it's index is divisible by a and an unpainted tile should be painted Blue if it's index is divisible by b. So the tile with the number divisible by a and b can be either painted Red or Blue.After her painting is done, she will get p chocolates for each tile that is painted Red and q chocolates for each tile that is painted Blue.Note that she can paint tiles in any order she wants.Given the required information, find the maximum number of chocolates Joty can get.

The only line contains five integers n, a, b, p and q (1 ≤ n, a, b, p, q ≤ 109).

Print the only integer s — the maximum number of chocolates Joty can get. Note that the answer can be too large, so you should use 64-bit integer type to store it. In C++ you can use the long long integer type and in Java you can use long integer type.

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	// "sort"
	// "strings"
)

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	log.SetOutput(ioutil.Discard)
	// log.SetOutput(os.Stderr)

	n, a, b, p, q := nextInt64(), nextInt64(), nextInt64(), nextInt64(), nextInt64()
	log.Print(n*gcd(a, b)/(a*b), min(p, q))
	println(n/a*p + n/b*q - n*gcd(a, b)/(a*b)*min(p, q))
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

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

	return b
}

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

/*
URL:
https://codeforces.com/problemset/problem/678/C
*/

package main

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

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

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

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

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

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

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

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

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

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

var (
	n, a, b, p, q int64
)

func main() {
	n = ReadInt64()
	a, b, p, q = ReadInt64_4()

	red := n / a
	red *= p

	blue := n / b
	blue *= q

	ans := red + blue

	c := Lcm(a, b)
	tmp := n / c
	tmp *= Min(p, q)

	ans -= tmp
	fmt.Println(ans)
}

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

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

	if a == 0 {
		return b
	}
	if b == 0 {
		return a
	}

	if a < b {
		a, b = b, a
	}

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

	return a
}

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

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

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

// NegativeMod can calculate a right residual whether value is positive or negative.
func NegativeMod(val, m int64) int64 {
	res := val % m
	if res < 0 {
		res += m
	}
	return res
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

	return res
}

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

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

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

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

	return string(res)
}

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

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

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

	return string(res)
}

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

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

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	// "sort"
	// "strings"
)

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	log.SetOutput(ioutil.Discard)
	// log.SetOutput(os.Stderr)

	n, a, b, p, q := nextInt64(), nextInt64(), nextInt64(), nextInt64(), nextInt64()

	println(n/a*p + n/b*q - n/(a*b)*gcd(a, b)*min(p, q))
}

func gcd(x, y int64) int64 {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

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

	return b
}

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

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

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

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

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

package main

import (
	"bufio"
	"fmt"
	"io/ioutil"
	"log"
	"os"
	"strconv"
	// "sort"
	// "strings"
)

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

//Wrong
func main() {
	defer writer.Flush()
	scanner.Split(bufio.ScanWords)
	log.SetOutput(ioutil.Discard)
	// log.SetOutput(os.Stderr)

	n, a, b, p, q := nextInt64(), nextInt64(), nextInt64(), nextInt64(), nextInt64()

	println(n/a*p + n/b*q - n/(a*b)*min(p, q))
}

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

	return b
}

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


A positive integer is called a 2-3-integer, if it is equal to 2x·3y for some non-negative integers x and y. In other words, these integers are such integers that only have 2 and 3 among their prime divisors. For example, integers 1, 6, 9, 16 and 108 — are 2-3 integers, while 5, 10, 21 and 120 are not.Print the number of 2-3-integers on the given segment [l, r], i. e. the number of sich 2-3-integers t that l ≤ t ≤ r.

The only line contains two integers l and r (1 ≤ l ≤ r ≤ 2·109).

Print a single integer the number of 2-3-integers on the segment [l, r].

NoteIn the first example the 2-3-integers are 1, 2, 3, 4, 6, 8 and 9.In the second example the 2-3-integers are 108, 128, 144, 162 and 192.

package main

import (
    "fmt"
)

func main() {
    var l, r, ans, a, b int64
    fmt.Scanf("%d %d", &l, &r)
    ans  = 0
    a = 1
    b = 1
    for i := 0; i < 33; i++ {
        b = 1
        for j := 0; j < 24; j++ {
            if a * b > r {
                break
            }
            if (l <= a * b) && (a * b <= r) {
                ans++
            }
            b *= 3
        }
        a *= 2
    }
    fmt.Println(ans)
}

package main
import	(
		"fmt"
		"bufio"
		"os"
		"strconv"
		_"math"
		_"math/big"
		_"math/rand"
		_"io/ioutil"
		_"io"
		)
var M map[int]bool
const oo = 2 * 1000 * 1000 * 1000
func main() {
	var l,r int
	M = make(map[int]bool,0)
	dfs(1)
	ans := 0
	fmt.Scanf("%d%d",&l,&r)
	for v,_ := range(M) {
		if l <= v && v <= r {
			ans += 1
		}
	}
	fmt.Println(ans)
}
func dfs(node int) {
	M[node] = true
	if node <= oo / 2 && M[node * 2] != true {
		dfs(node * 2)
	}
	if node <= oo / 3 && M[node * 3] != true {
		dfs(node * 3)
	}
}
func gcd(x,y int) int {
	if y == 0 {
		return x
	} else {
		return gcd(y,x % y)
	}
}
func abs(x int) int {
	if x < 0 {
		return -x
	} else {
		return x
	}
}
func max(x,y int) int {
	if x > y {
		return x
	} else {
		return y
	}
}

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

var scanner *bufio.Scanner

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

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

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b float64
	fmt.Scanln(&a, &b)
	sum := 0
	for i := 0; i <= 31; i++ {
	    for j := 0; j<=19; j++{
	        foo:=math.Pow(2, float64(i))
	        bar:=math.Pow(3, float64(j))
	        if foo*bar>=a && foo*bar<=b{
	            //fmt.Println(foo*bar)
	            sum++;
	        }
	    }
	}
	fmt.Println(sum)
}

package main

import "fmt"
var l, r int64
var ans int64 = 0
func dfs(x int64,y int64) {
    if x >= l {
        ans += 1
    }
    if y == 0 {
        if x*2<=r {
            dfs(x*2,0)
        }
    }
    if x*3<=r {
        dfs(x*3,1)
    }
}
func main() {
	fmt.Scan(&l, &r)
	dfs(1,0)
	fmt.Println(ans)
}

package main
import "fmt"

func main(){
	// your code goes here
	var l, r, ans1, ans2, res int64
	fmt.Scan(&l, &r)
	res = 0;
	for i:=0; i <= 30; i++{
		for j := 0; j <= 20; j++{
			ans1 = 1;
			ans2 = 1;
			for k := 0; k < i; k++{
				ans1 *= 2;
			}
			for k := 0; k < j; k++{
				ans2 *= 3;
			}
			if ans1 * ans2 >= l{
				if ans1 * ans2 <= r{
					res++;
				}
			}
		}
	}
	fmt.Printf("%d", res)
}

package main

import "fmt"

func main() {
	var l int64
    var r int64
	fmt.Scan(&l)
	fmt.Scan(&r)
    var ans = 0
	for i := 0; i < 33; i++ {
        for j := 0; j < 33; j++ {
            var me int64
            me = 1
            for k :=0; k < i; k++ {
                me = me * 2
            }
            for k :=0; k < j; k++ {
                me = me * 3
                if me > r {
                    break
                }
            }
            if me >= l {
                if me <= r{
                    ans = ans + 1
                }
            }
        }
	}
    fmt.Printf("%d\n",ans)
}

package main

import "fmt"

func main() {
    var a int64
    var b int64

    var cap int64
    cap = 2000000001

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

    var cur1 int64
    cur1 = 1

    var answer int
    answer = 0

    for x := 0; x < 32; x++ {
        var cur2 int64
        cur2 = cur1
        for y := 0; y < 20; y++ {
            if cur2 >= cap {
                break
            }
            if cur2 >= a {
                if cur2 <= b {
                    answer++
                }
            }

            cur2 *= 3
        }

        cur1 *= 2
    }

    fmt.Println(answer)
}

package main

import "fmt"

func main() {
	var r uint64
	var l uint64
	fmt.Scan(&l)
	fmt.Scan(&r)
	var ans uint64
	ans=0
	l=l-1
	var ast uint64
	ast=1
	var erkl uint64
	erkl = 1
	var hl uint64
	hl=0
	var hr uint64
	hr = 0
	for ;erkl<=l;erkl=erkl*2{
		hl+=1
	}
	var erkr uint64
	erkr = 1
	for ;erkr<=r;erkr=erkr*2{
		hr+=1
	}

	for i := 0; ast <= r; i++ {
		for ;ast*erkl>l;erkl/=2{
			hl-=1
		}
		for ;ast*erkr>r;erkr/=2{
			hr-=1
		}
		ast = ast*3
		ans=ans+hr-hl
    }
	fmt.Println(ans)

}

package main

import "fmt"

func main() {
  var l, r int64
  fmt.Scan(&l, &r)
  var arr [] int64
  var x int64
  LIM := int64(2000000000)
  var flag int
  for i := 0; i < 32; i++ {
    for j := 0; j < 32; j++ {
      x = 1
      flag = 1
      for pw := 1; pw <= i; pw++ {
        if x * 2 > LIM {
          flag = 0
        }
        x = x * 2
      }
      for pw := 1; pw <= j; pw++ {
        if (x * 3 > LIM) {
          flag = 0
        }
        x = x * 3
      }
      if flag == 1 {
        arr = append(arr, x)
      }
    }
  }
  n := len(arr)
  res := 0
  for i := 0; i < n; i++ {
    if l <= arr[i] {
      if arr[i] <= r {
        res = res + 1
      }
    }
  }
  fmt.Println(res)
}

package main
import "fmt"
func main() {
	var l int64
  var r int64
	var ans int64
	var m int64
	fmt.Scan(&l)
  fmt.Scan(&r)
	ans = 0;
	for i := int64(1); i <= 2000000000; i*=2 {
    for j := int64(1); j <= 2000000000; j*=3 {
			m=i*j
        if l<=m{
            if(m<=r){
                ans++
                }
            }
	       }
    }
fmt.Println(ans)
}

package main

import "fmt"

func main() {
	var l, r, c int64
	fmt.Scan(&l, &r)
	c = 0
	for i := 0; i < 32; i++ {
	    var x int64
	    x = 1
	    for j := 0; j < i; j++ {
	        x = x*2
	    }
	    for j := 0; j < 21; j++ {
	        if x > l - 1 {
	            if x < r + 1 {
	                c = c+1
	            }
	        }
	        x = x*3
	    }
	}
	fmt.Println(c)
}

package main

import "fmt"

func check(n int64, p2 int, p3 int) bool {
    for i := 0; i < p2; i++ {
        n = n / 2
    }
    for i := 0; i < p3; i++ {
        n = n / 3
    }
    return n >= 1
}

func solve(n int64) int {
    c := 0
    for i := 0; i < 32; i++ {
        for j := 0; j < 25; j++ {
            if check(n, i, j) {
                c += 1
            }
        }
    }
    return c
}

func main() {
    var l, r int64
    fmt.Scan(&l, &r)
    ans := solve(r) - solve(l - 1)
	fmt.Println(ans)
}

package main

import "fmt"

func main() {
    var i, j, s, a, b, x, ans int64
    fmt.Scanln(&a, &b)
    ans = 0

    x = 1;
    for i=0; i<31; i++  {
        s = x

        for j=0; j<30; j++ {
            if s > b {
                break
            }

            if s >= a {
                ans++
            }

            s *= 3
        }

        x *= 2
    }

    fmt.Print(ans)
}

package main
import "fmt"

func main() {
   var l int64
   var r int64
   var cur int64
   var res int64
   fmt.Scan(&l)
   fmt.Scan(&r)
   cur = 1
   for i:= 0; i < 33; i++ {
   	var ocur int64
   	ocur = cur
   	for j := 0; j < 20; j++ {
   		if cur >= l {
   			if cur <= r {
   				res = res + 1
   			}
   		}
   		cur = cur * 3
   	}
   	cur = ocur * 2
   }
   fmt.Printf("%d", res)
}

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"
import "math"

func main() {
	var min float64
	var max float64
	fmt.Scan(&min)
	fmt.Scan(&max)
	var res int
	res = 0;
	for i := 0; i < 31; i++ {
	    for y := 0; y < 20; y++ {
	        var x float64
	        x = math.Pow(2,float64(i))*math.Pow(3,float64(y));
	        if x >= min {
	            if x <= max {
	                res++;
	            }
	        }
	    }
	}
	fmt.Println(res);
}

package main

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

var a [100002]int

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

	var l int64
	var r int64
	var ans int64
	ans = 0
	fmt.Fscan(in, &l)
	fmt.Fscan(in, &r)

	var now int64
	now = 1

	for i := 0; i <= 30; i++ {
		var kek int64
		kek = now
		for j := 0; j <= 30; j++ {
			if kek >= l && kek <= r {
				ans += 1
			}
			kek *= 3
			if kek > r {
				break
			}
		}
		now *= 2
		if now > r {
			break
		}
	}

    fmt.Print(ans)
}

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, extra_rem int
    if l == 1 {
        extra = 1
    }
    if l!= 1 && (r2min ==  math.Trunc(r2min) || r3min == math.Trunc(r3min) || int(l)%6 == 0) {
        extra_rem = 1
    }
    var total23divs int
    total23divs = find_divs(r3max, r) - find_divs(r3min, l)
    total := int(r2max) + int(r3max) - int(r2min) - int(r3min)  + total23divs + extra + extra_rem
	fmt.Println( total)
}

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
    power :=  math.Pow(3, math.Trunc(upper))
    d := num/power
    total_num += int(math.Log2(d))
    for i := int(upper)-1; i>0; i-- {
        d *= 3
        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, extra_rem int
    if l == 1 {
        extra = 1
    } else {
      if r2min ==  math.Trunc(r2min) || r3min == math.Trunc(r3min) || int(l)%6 == 0 {
          extra_rem = 1
      }
    }
    var total23divs int

    total23divs = find_divs(r3max, r) - find_divs(r3min, l)
    total := int(r2max) + int(r3max) - int(r2min) - int(r3min)  + total23divs + extra + extra_rem
	fmt.Println( total)
}

package main

import "fmt"

func main() {
    var a int64
    var b int64
    var l int64
    var r int64
    var ans int64
    a = 1
    b = 1
    ans = 0
	fmt.Scan(&l)
	fmt.Scan(&r)
	for i := 0; i <= 19; i++ {
	    b = 1
	    for j := 0; j <= 30; j ++ {
	        if a * b >= l {
	            if a * b <= r {
	                ans = ans + 1
	            }
	        }
	        b = b * 2
	    }
	    a = a * 3
	}
	fmt.Printf( "%d", ans )
}

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

func main() {
	var l,r,ot,i,j int64
	ot = 0;
	fmt.Scan(&l,&r)
	j = 1;
	for j <= r {
	    i = j;
    	for i <= r {
	        if (i>=l) {ot++;}
	        i*=2 ;
	    }
	j*=3 ;
	}
	fmt.Printf("%d", ot)

}

package main

import "fmt"

func pwer (a, p int64) int64 {
    var m int64 = 1
    for ; p > 0; p -- {
        m = m * a
    }
    return m
}

func main() {
    var l, r int64
    fmt.Scan(&l, &r)
    var answer, a, b int64 = 0, 0, 0
    for a = 0; a < 39; a ++ {
		for b = 0; b < 39; b ++ {
		    var c int64 = pwer(2, a) * pwer(3, b)
		    if ((l <= c) && (c <= r)) {
		        answer ++
		    }
		}
	}
    fmt.Println(answer)
}

package main

import (
	"fmt"
	"math"
)

func main() {
	var a, b int
	fmt.Scanln(&a, &b)
	sum := 0
	for i := 0; i <= 30; i++ {
	    for j := 0; j<= 19; j++{
	        foo:=int(math.Pow(2, float64(i)))
	        bar:=int(math.Pow(3, float64(j)))
	        if foo*bar>=a && foo*bar<=b{
	            sum++;
	        }
	    }
	}
	fmt.Println(sum)
}

package main
import "fmt"

func main(){
	// your code goes here
	var l, r, ans1, ans2, res int
	fmt.Scan(&l, &r)
	res = 0;
	for i:=0; i <= 30; i++{
		for j := 0; j <= 20; j++{
			ans1 = 1;
			ans2 = 1;
			for k := 0; k < i; k++{
				ans1 *= 2;
			}
			for k := 0; k < j; k++{
				ans2 *= 3;
			}
			if ans1 * ans2 >= l{
				if ans1 * ans2 <= r{
					res++;
				}
			}
		}
	}
	fmt.Printf("%d", res)
}

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++
    }
    fmt.Printf("%d", j-i)
}

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


You are given an integer N. Consider all possible segments on the coordinate axis with endpoints at integer points with coordinates between 0 and N, inclusive; there will be  of them.You want to draw these segments in several layers so that in each layer the segments don't overlap (they might touch at the endpoints though). You can not move the segments to a different location on the coordinate axis. Find the minimal number of layers you have to use for the given N.

The only input line contains a single integer N (1 ≤ N ≤ 100).

Output a single integer - the minimal number of layers required to draw the segments for the given N.

NoteAs an example, here are the segments and their optimal arrangement into layers for N = 4.

package main

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

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

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

func toInt(buf []byte) (o int) {
	for _, v := range buf {
		o = o*10 + int(v-'0')
	}
	return
}

type pair struct {
	first int
	second int
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var dp[5002][5002] int64
var sum[5002] int64
var MD int64 = 1000000007

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	var n int
	ans := 0
	fmt.Fscanf(in, "%d\n", &n)
	for i := 0; i < n; i++ {
		res := 0
		for j :=0; j <= n; j++ {
			for k := j + 1; k <= n; k++ {
				if i >= j && i + 1 <= k {
					res++
				}
			}
		}
		ans = max(ans, res)
	}
	fmt.Println(ans)
}

package main

import "fmt"

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

func main() {
    n := 0
    fmt.Scan(&n)
    l := 1
    for i := 1; i < n; i++ {
        l += min(i, n-i+1)
    }
    fmt.Print(l)
}

package main

import
(
	"fmt"

)

func main() {

	var a int
	fmt.Scanln(&a)
	fmt.Print(((a+1)/2)*((a-(a+1)/2)+1))
	}


Vasya decided to learn to play chess. Classic chess doesn't seem interesting to him, so he plays his own sort of chess.The queen is the piece that captures all squares on its vertical, horizontal and diagonal lines. If the cell is located on the same vertical, horizontal or diagonal line with queen, and the cell contains a piece of the enemy color, the queen is able to move to this square. After that the enemy's piece is removed from the board. The queen cannot move to a cell containing an enemy piece if there is some other piece between it and the queen. There is an n × n chessboard. We'll denote a cell on the intersection of the r-th row and c-th column as (r, c). The square (1, 1) contains the white queen and the square (1, n) contains the black queen. All other squares contain green pawns that don't belong to anyone.The players move in turns. The player that moves first plays for the white queen, his opponent plays for the black queen.On each move the player has to capture some piece with his queen (that is, move to a square that contains either a green pawn or the enemy queen). The player loses if either he cannot capture any piece during his move or the opponent took his queen during the previous move. Help Vasya determine who wins if both players play with an optimal strategy on the board n × n.

The input contains a single number n (2 ≤ n ≤ 109) — the size of the board.

On the first line print the answer to problem — string "white" or string "black", depending on who wins if the both players play optimally.  If the answer is "white", then you should also print two integers r and c representing the cell (r, c), where the first player should make his first move to win. If there are multiple such cells, print the one with the minimum r. If there are still multiple squares, print the one with the minimum c.

NoteIn the first sample test the white queen can capture the black queen at the first move, so the white player wins.In the second test from the statement if the white queen captures the green pawn located on the central vertical line, then it will be captured by the black queen during the next move. So the only move for the white player is to capture the green pawn located at (2, 1). Similarly, the black queen doesn't have any other options but to capture the green pawn located at (2, 3), otherwise if it goes to the middle vertical line, it will be captured by the white queen.During the next move the same thing happens — neither the white, nor the black queen has other options rather than to capture green pawns situated above them. Thus, the white queen ends up on square (3, 1), and the black queen ends up on square (3, 3). In this situation the white queen has to capture any of the green pawns located on the middle vertical line, after that it will be captured by the black queen. Thus, the player who plays for the black queen wins.

package main

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

// Input & Output
var (
	input  = bufio.NewScanner(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func main() {
	var n uint64
	input.Scan()
	n, _ = strconv.ParseUint(input.Text(), 10, 64)
	if n%2 == 1 {
		fmt.Fprintln(output, "black")
	} else {
		fmt.Fprintln(output, "white")
		fmt.Fprintln(output, 1, 2)
	}
	defer output.Flush()
}

package main

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

// Input & Output
var (
	input  = bufio.NewReader(os.Stdin)
	output = bufio.NewWriter(os.Stdout)
)

func main() {
	var n int64
	fmt.Fscan(input, &n)
	if n%2 == 1 {
		fmt.Fprintln(output, "black")
	} else {
		fmt.Fprintln(output, "white")
		fmt.Fprintln(output, 1, 2)
	}
	defer output.Flush()
}

package main

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

// github.com/EndlessCheng/codeforces-go
func CF493D(in io.Reader, out io.Writer) {
	var n int
	Fscan(in, &n)
	if n&1 > 0 {
		Fprint(out, "black")
	} else {
		Fprint(out, "white\n1 2")
	}
}

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

package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	if n%2 == 0 {
		fmt.Println("white")
		fmt.Println(1, 2)
	} else {
		fmt.Println("black")
	}
}

package main
import "fmt"

func main() {
	var x int
	fmt.Scanf("%d", &x)
	if x % 2 == 0 {
		fmt.Println("white")
		fmt.Println(1, 2)
	} else {
		fmt.Println("black")
	}
}

package main

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

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

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

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

func main() {
    defer out.Flush()
    in.Split(bufio.ScanWords)
    n := nextInt()
    if n % 2 == 1 {
        fmt.Fprintln(out, "black")
    } else {
        fmt.Fprintln(out, "white")
        fmt.Fprintln(out, "1 2")
    }
}