// Codeforces 785 B Anton and Classes done
package main

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

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

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

var ax,ay,bx,by,cx,cy int64
var haveSol bool

func readData() {
	in = bufio.NewReader(os.Stdin)
	a := readLineNumbs(6)
	ax = int64(a[0])
	ay = int64(a[1])
	bx = int64(a[2])
	by = int64(a[3])
	cx = int64(a[4])
	cy = int64(a[5])
}

func dist2(ax,ay,bx,by int64) int64 {
	dx := bx-ax
	dx = dx*dx
	dy := by-ay
	dy = dy*dy
	return dx+dy
}

func solve() {
	dab := dist2(ax,ay,bx,by)
	dbc := dist2(bx,by,cx,cy)
	if dab!=dbc {
		haveSol = false
		return
	}
	if ((ax-bx)==(bx-cx)) && ((ay-by)==(by-cy)) {
		haveSol = false
	} else {
		haveSol = true
	}
}

func printRes() {
	if haveSol {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

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

package main

import "fmt"

func main() {
	var ax, ay, bx, by, cx, cy int64
	fmt.Scan(&ax, &ay, &bx, &by, &cx, &cy)
	cx -= bx
	cy -= by
	bx -= ax
	by -= ay
	if bx*bx+by*by == cx*cx+cy*cy && (bx != cx || by != cy) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

import "fmt"

func main() {
	var ax,ay,bx,by,cx,cy int64
	fmt.Scanf("%d%d%d%d%d%d",&ax,&ay,&bx,&by,&cx,&cy)
	ax*=2
	ay*=2
	bx*=2
	by*=2
	cx*=2
	cy*=2
	dx:=(ax+cx)/2
	dy:=(ay+cy)/2
	ux := bx - ax
	uy := by - ay
	vx := bx - cx
	vy := by - cy
	ra := ux * ux + uy * uy;
	rc := vx * vx + vy * vy;
	if !(dx == bx && dy == by) && ra == rc {
		fmt.Printf("Yes")
	}else{
		fmt.Printf("No")
	};
}

package main

import (
        "fmt"
)

var (
        ax int64
        ay int64
        bx int64
        by int64
        cx int64
        cy int64
)

func main() {
        fmt.Scanf("%d %d %d %d %d %d\n", &ax, &ay, &bx, &by, &cx, &cy)
        if ((ax-bx)*(ax-bx)+(ay-by)*(ay-by)) == ((bx-cx)*(bx-cx)+(by-cy)*(by-cy)) && (bx-ax)*(cy-by) != (by-ay)*(cx-bx) {
                fmt.Printf("YES\n")
        } else {
                fmt.Printf("NO\n")
        }
}

package main

import (
        "fmt"
)

var (
        ax int64
        ay int64
        bx int64
        by int64
        cx int64
        cy int64
)

func main() {
        fmt.Scanf("%d %d %d %d %d %d\n", &ax, &ay, &bx, &by, &cx, &cy)
        if ((ax-bx)*(ax-bx)+(ay-by)*(ay-by)) == ((bx-cx)*(bx-cx)+(by-cy)*(by-cy)) && (bx-ax)*(cy-ay) != (by-ay)*(cx-bx) {
                fmt.Printf("YES\n")
        } else {
                fmt.Printf("NO\n")
        }
}

package main

import "fmt"

func main() {
	var ax, ay, bx, by, cx, cy int
	fmt.Scan(&ax, &ay, &bx, &by, &cx, &cy)
	cx -= bx
	cy -= by
	bx -= ax
	by -= ay
	if bx*bx+by*by == cx*cx+cy*cy && bx != cx {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

package main

import "fmt"

func main() {
	var ax, ay, bx, by, cx, cy int64
	fmt.Scan(&ax, &ay, &bx, &by, &cx, &cy)
	cx -= bx
	cy -= by
	bx -= ax
	by -= ay
	if bx*bx+by*by == cx*cx+cy*cy && bx != cx {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


package main

import (
	"fmt"
)

func main() {
    var n,m,b int

    fmt.Scan(&n, &m)
    var light []int = make([]int, n)

    for i := 0; i < n; i++ {
        light[i] = 0
    }

    for l := 0; l < m; l++ {
        fmt.Scan(&b)

        b = b - 1
        for i := b; (i < n) && (light[i] == 0); i++ {
            light[i] = b + 1
        }
    }

    for i := 0; i < n; i++ {
        fmt.Printf("%d", light[i])
        if i == n - 1 {
            fmt.Println()
        } else {
            fmt.Printf(" ")
        }
    }

    return
}

package main

import (
    "fmt"
)

func main() {
    var t, n, m, cnt int
    var light [110]int
    fmt.Scan(&n, &m)
    cnt = 100000
    for i := 0; i < m; i++ {
        fmt.Scan(&t)
        if t < cnt {
            cnt = t
            light[t] = 1
        }
    }
    for i := 1; i <= n; i++ {
        if light[i] == 1 {
            cnt = i
        }
        fmt.Printf("%d ", cnt)
    }
}

package main

import (
    "fmt"
)

func main() {
    var t, n, m, cnt int
    var light [110]int
    fmt.Scanf("%d %d", &n, &m)
    cnt = 100000
    for i := 0; i < m; {
        c, _ := fmt.Scanf("%d", &t)
        if c == 0 {
            continue
        }
        if t < cnt {
            cnt = t
            light[t] = 1
        }
        i++
    }
    for i := 1; i <= n; i++ {
        if light[i] == 1 {
            cnt = i
        }
        fmt.Printf("%d ", cnt)
    }
}

package main

import "fmt"

func main() {
    var n,m,b int
    var a [105]int
    fmt.Scan(&n,&m)
    for i := 0; i < m; i++ {
        fmt.Scan(&b)
        for j := b; j <= n; j++ {
            if a[j] == 0 { a[j] = b }
        }
    }
    for i := 1; i <= n; i++ {
        fmt.Print(a[i])
        if i == n { fmt.Println() } else { fmt.Print(" ") }
    }
}

package main

import (
	"fmt"
)

/*Simulating the problem of mashmokh and the lights
lights array will contain the current state of the light -1 / -2
0 -> ON
if any other number is present, then the light is switched off with that swtich*/
func main() {
    var n,m,b int
    var light [200]int

    fmt.Scan(&n, &m)

    for l := 0; l < m; l++ {
        fmt.Scan(&b)

        b = b - 1
        for i := b; i < n; i++ {
            if light[i] == 0 {
                light[i] = b + 1
            }
        }
    }

    for i := 0; i < n; i++ {
        fmt.Printf("%d", light[i])
        if i == n - 1 {
            fmt.Println()
        } else {
            fmt.Printf(" ")
        }
    }

    return
}

// 415A-mic
package main

import (
    "fmt"
)

func main() {
    var n, m, x int
    fmt.Scan(&n, &m)
    a := make([]int, n+1)
    v := make([]int, n+1)

    for i := 0; i <= n; i++ {
        v[i] = 0
    }
    for i := 0; i < m; i++ {
        fmt.Scan(&x)
        for j := x; j <= n; j++ {
            if v[j] == 0 {
                a[j] = x
                v[j] = 1
            }
        }
    }

    for i := 1; i <= n; i++ {
        fmt.Print(a[i])
        fmt.Print(" ")
    }

    fmt.Println()

}

package main

import (
	"fmt"
)

func main() {
	var light [200]int;
	var n, m, button int;
	fmt.Scanf("%d %d", &n, &m);
	for i := 1; i <= m; {
		retN, _ := fmt.Scanf("%d", &button);
		if retN == 0 {
			continue;
		}
		for j := button; j <= n; j = j + 1 {
			if light[j] == 0 {
				light[j] = button;
			}
		}
		i = i + 1;
	}

	for i := 1; i <= n; i = i + 1 {
		fmt.Printf("%d ", light[i]);
	}
}

package main

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

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

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

	n, m := nextInt(), nextInt()

	lights := make([]int, n)
	buttonOff := 0

	for i:=0; i<m; i++ {
		buttonOff = nextInt()

		for j:= buttonOff-1; j<n && lights[j]==0; j++ {
			lights[j] = buttonOff
		}
	}

	for i:=0; i<n; i++ {
		print(lights[i], " ")
	}
}

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

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

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

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

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

package main

import (
	"fmt"
	//"sort"
)

func main() {
	var n,m,x int
	fmt.Scan(&n,&m)
	a:=make([]int,101)
	for i:=0;i<m;i++ {
		fmt.Scan(&x)
		for j:=x;j<=n;j++ {
			if a[j]==0 {
				a[j]=x
			}
		}
	}
	for i:=1;i<=n;i++ {
		fmt.Print(a[i]," ")
	}
}

package main

import (
    "fmt"
)

func main() {
    var t, n, m, cnt int
    var light [110]int
    fmt.Scanf("%d %d", &n, &m)
    cnt = 100000
    for i := 0; i < m; i++ {
        c, _ := fmt.Scanf("%d", &t)
        if c == 0 {
            continue
        }
        if t < cnt {
            cnt = t
            light[t] = 1
        }
    }
    for i := 1; i <= n; i++ {
        if light[i] == 1 {
            cnt = i
        }
        fmt.Printf("%d ", cnt)
    }
}

package main

import (
    "fmt"
)

func main() {
    var t, n, m, cnt int
    var light [110]int
    fmt.Scanf("%d%d", &n, &m)
    cnt = 100000
    for i := 0; i < m; i++ {
        fmt.Scanf("%d", &t)
        if t < cnt {
            cnt = t
            light[t] = 1
        }
    }
    for i := 1; i <= n; i++ {
        if light[i] == 1 {
            cnt = i
        }
        fmt.Printf("%d ", cnt)
    }
}

package main

import (
	"fmt"
)

func main() {
	var n, m int

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

	pushes := make([]int, m + 10)
	lightstatus := make([] int, n + 10)

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

	for i := 0; i < m; i++ {
		for j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {
			lightstatus[j] = pushes[i]
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Printf("%d ", lightstatus[i])
	}

}

package main

import (
	"fmt"
)

func main() {
	var light [200]int;
	var n, m, button int;
	fmt.Scanf("%d %d", &n, &m);
	for i := 1; i <= m; i = i + 1 {
		fmt.Scanf("%d", &button);
		for j := button; j <= n; j = j + 1 {
			if light[j] == 0 {
				light[j] = button;
			}
		}
	}

	for i := 1; i <= n; i = i + 1 {
		fmt.Printf("%d ", light[i]);
	}
}

package main

import (
	"fmt"
)

func main() {
	var n, m int
	var pushes, lightstatus [200]int

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

//	pushes := make([]int, m + 10)
//	lightstatus := make([] int, n + 10)

	for i := 0; i < m; i++ {
		ret, _ := fmt.Scanf("%d", &pushes[i])
		if ret == 0 {
			continue
		}
	}

	for i := 0; i < m; i++ {
		for j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {
			lightstatus[j] = pushes[i]
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Printf("%d ", lightstatus[i])
	}

}

package main

import (
	"fmt"
)

func main() {
	var n, m int

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

	pushes := make([]int, m + 10)
	lightstatus := make([] int, n + 10)

	for i := 0; i < m; i++ {
		ret, _ := fmt.Scanf("%d", &pushes[i])
		if ret == 0 {
			continue
		}
	}

	for i := 0; i < m; i++ {
		for j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {
			lightstatus[j] = pushes[i]
		}
	}

	for i := 1; i <= n; i++ {
		fmt.Printf("%d ", lightstatus[i])
	}

}

package main

import (
	"fmt"
)

/*Simulating the problem of mashmokh and the lights
lights array will contain the current state of the light -1 / -2
0 -> ON
if any other number is present, then the light is switched off with that swtich*/
func main() {
    var n,m,b int
    fmt.Scanf("%d %d", &n, &m)
    var light []int = make([]int, n)
    for i := 0; i < n; i++ {
        light[i] = -1
    }

    for l := 0; l < m; l++ {
        retN, _ := fmt.Scanf("%d", &b)
        if retN == 0 {
            continue
        }

        b = b - 1
        for i := b; (i < n ) && (light[i] == -1); i++ {
            light[i] = b + 1
        }
    }

    for i := 0; i < n; i++ {
        fmt.Printf("%d ", light[i])
        if i == n {
            fmt.Println()
        } else {
            fmt.Printf(" ")
        }
    }

    return
}

package main

import (
	"fmt"
)

func main() {
	var n, m int

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

	pushes := make([]int, m + 10)
	lightstatus := make([] int, n + 10)

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

	for i := 0; i < m; i++ {
		for j := pushes[i]; j <= n && lightstatus[j] == 0; j ++ {
			lightstatus[j] = pushes[i]
		}
	}

	fmt.Println(lightstatus[1:n + 1])

}


//70A
package main
import (
	"fmt"
	"os"
	"bufio"
	"strconv"
)

func main() {
	var nn, a int64
	a=1
	r := bufio.NewScanner(os.Stdin)
	r.Split(bufio.ScanWords)
	r.Scan()
	nn, _ = strconv.ParseInt(r.Text(), 0, 64)
	if nn==1 {
		a=1
	} else {
		for i:=2; int64(i)<=nn; i++ {
			a=(a*3)%1000003
		}
	}
	fmt.Println(a)
}

// 70A
package main

import (
	"fmt"
)

func main() {
	var m int
	e := 1
	fmt.Scan(&m)
	for j := 1; j <= m-1; j++ {
		e = (3 * e) % 1000003
	}
	fmt.Print(e)
}


package main

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

func Init() {
}

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

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

	teams := make([]int, 0)
	for i := 1; i <= N; i++ {
	  teams = append(teams, i)
	}

	which := -1
	for r := 1; which < 0; r++ {
	  next := make([]int, 0)
	  for i := 0; i < len(teams); i += 2 {
	    if isOr(A, teams[i], teams[i + 1]) && isOr(B, teams[i], teams[i + 1]) {
	      which = r
	      break
	    }
	    if isOr(A, teams[i], teams[i + 1]) {
	      next = append(next, A)
	    } else if isOr(B, teams[i], teams[i + 1]) {
	      next = append(next, B)
	    } else {
	      next = append(next, teams[i])
	    }
	  }
	  teams = next
	}

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

func isOr(x, a, b int) bool {
  return x == a || x == b
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

package main

import "fmt"

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

package main

import "fmt"

func main() {
	var n, a, b int
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}

		if a%2 == 1 {
			a += 1
		}
		if b%2 == 1 {
			b += 1
		}

		rest := a - b
		if rest < 0 {
			rest = -rest
		}
		cnt := 1
		for rest > 1 {
			rest >>= 1
			cnt++
		}
		max := 0
		for n > 1 {
			n >>= 1
			max++
		}
		if cnt < max {
			fmt.Println(cnt)
		} else {
			fmt.Println("Final!")
		}
	}
}

package main

import "fmt"

func main() {
	var n, a, b int
	for {
		_, err := fmt.Scanln(&n, &a, &b)
		if err != nil {
			break
		}

		if a%2 == 1 {
			a += 1
		}
		if b%2 == 1 {
			b += 1
		}

		rest := a - b
		if rest < 0 {
			rest = -rest
		}
		if n-rest*2 <= 0 {
			fmt.Println("Final!")
		} else {
			cnt := 1
			for rest > 1 {
				rest >>= 1
				cnt++
			}
			fmt.Println(cnt)
		}
	}
}

package main

import "fmt"

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

package main

import "fmt"

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

package main

import "fmt"

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

package main

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

func Init() {
}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


package main

import (
	"fmt"
)

func main() {
	var n int

	fmt.Scan(&n)

	x := make([]int, n)

	for i := range x {
		fmt.Scan(&x[i])
	}

	for x[0] != x[1] {
		if x[0] > x[1] {
			x[0] -= x[1]
		} else {
			x[1] -= x[0]
		}
	}

	gcd := x[0]

	for i:=2; i<len(x); i++ {
		for x[i] != gcd {
			if x[i] > gcd {
				x[i] -= gcd
			} else {
				gcd -= x[i]
			}
		}
	}

	fmt.Println(gcd*len(x))
}

package main

import (
	"fmt"
)

func GCD(x, y int) int {
	for y != 0 {
		x, y = y, x%y
	}
	return x
}

func main() {
	var n, gcd int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var x int
		fmt.Scan(&x)
		if i == 0 {
			gcd = x
		} else {
			gcd = GCD(gcd, x)
		}
	}
	fmt.Println(n * gcd)
}

package main

import (
	"fmt"
)
func gcd(x, y int) int {
    for y != 0 {
        x, y = y, x%y
    }
    return x
}

func main() {
	var n,g,x int
	fmt.Scan(&n,&g)
	for i:=1;i<n;i++ {
		fmt.Scan(&x)
		g=gcd(g,x)
	}
	fmt.Println(g*n)
}

package main

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

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

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

	has_inequality := true
	for has_inequality {
		has_inequality = false
		for i := 0; i < n; i++ {
			for j := i + 1; j < n; j++ {
				if array[i] != array[j] {
					has_inequality = true
					c := sub_algorithm(array[i], array[j])
					array[i] = c
					array[j] = c
				}
			}
		}
	}

	sum := 0
	for i := 0; i < n; i++ {
		sum += array[i]
	}
	fmt.Println(sum)
}

func sub_algorithm(a, b int) int {
	if a == b {
		return a
	} else if b > a {
		a, b = b, a
	}
	return sub_algorithm(a-b, b)
}

package main

import "fmt"

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

func main() {
    var n,x int
    fmt.Scan(&n)
    a := -1
    for i := 0; i < n ; i++ {
        fmt.Scan(&x)
        if a == -1 { a = x } else { a = gcd(a,x) }
    }
    fmt.Println(a*n)
}

// 389A-mic
package main

import (
    "fmt"
    "math/big"
)

func gcd(x, y int64) int64 {
    return new(big.Int).GCD(nil, nil, big.NewInt(x), big.NewInt(y)).Int64()
}

func main() {
    var n, g, k, i int64
    fmt.Scan(&n, &g)
    for i = 1; i < n; i++ {
        fmt.Scan(&k)
        g = gcd(g, k)
    }
    fmt.Println(g * n)
}


package main

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

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

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

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

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

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

var n, m, k int64

func solve(n int64) {
	I(&m, " ")
	I(&k, "\n")
	if n == m {
		O(1, "\n")
		return
	}
	if n == 1 {
		O(m, "\n")
		return
	}
	ans := int64(2)
	m -= n + 1
	h := int64(1)
	l := k - 1
	r := n - k
	for m > 0 {
		if l > 0 {
			h++
			l--
		}
		if r > 0 {
			h++
			r--
		}
		if r <= 0 && l <= 0 {
			ans += m / h
			m = 0
		} else {
			m -= h
			if m >= 0 {
				ans++
			}
		}
	}
	O(ans, "\n")
}

package main

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

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

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

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

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

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

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

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

func solve(n int64) {
	var m, k int64
	I(&m, " ")
	I(&k, "\n")
	fair := m / n
	arr := make([]int64, n+1)
	for i := int64(1); i <= n; i++ {
		arr[i] = fair
	}
	for i := int64(1); i < k; i++ {
		if arr[i] > 1 {
			arr[i]--
			arr[i+1]++
		}
	}
	if k != n {
		for i := n; i > k; i-- {
			if arr[i] > 1 {
				arr[i]--
				arr[i-1]++
			}
		}
	}
	arr[k] += m % n
	if k > 0 {
		ooo := int64(1)
		for arr[k]-arr[k-1] > 1 && k != ooo {
			arr[k]--
			ooo %= k
			if ooo == int64(0) {
				ooo++
			}
			arr[ooo]++
			ooo++
		}
	}
	if k < 0 {
		ooo := int64(n)
		for arr[k]-arr[k+1] > 1 && k != ooo {
			arr[k]--
			if ooo == int64(k) {
				ooo = n
			}
			arr[ooo]++
			ooo--
		}
	}
	O(arr[k], "\n")
}

package main

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

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

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

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

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

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

var n, m, k int64

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

package main

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

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

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

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

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

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

func solve(n int64) {
	var m, k int64
	I(&m, " ")
	I(&k, "\n")
	fair := m / n
	arr := make([]int64, n+1)
	for i := int64(1); i <= n; i++ {
		arr[i] = fair
	}
	for i := int64(1); i < k; i++ {
		if arr[i] > 1 {
			arr[i]--
			arr[i+1]++
		}
	}
	if k != n {
		for i := n; i > k; i-- {
			if arr[i] > 1 {
				arr[i]--
				arr[i-1]++
			}
		}
	}
	arr[k] += m % n
	if k != 1 {
		ooo := int64(1)
		for arr[k]-arr[k-1] > 1 {
			arr[k]--
			arr[ooo]++
			ooo++
			ooo %= k
			if ooo == int64(0) {
				ooo++
			}
		}
	}
	if k != n {
		ooo := int64(n)
		for arr[k]-arr[k+1] > 1 {
			arr[k]--
			arr[ooo]++
			ooo--
			if ooo == int64(k) {
				ooo = n
			}
		}
	}
	O(arr[k], "\n")
}

package main

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

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

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

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

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

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

var n, m, k int64

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

package main

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

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

	fmt.Println(best + 1)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

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

	fmt.Println(best + 1)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

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

	fmt.Println(best + 1)
}

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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

package main

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

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

var scanner *bufio.Scanner

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

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

// IO

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

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

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

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

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


package main

import (
    "fmt"
    "math"
)

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

package main

import (
    "fmt"
    "math"
)

func main() {
    var ab, ac, bc int64
    fmt.Scanf("%d %d %d", &ab, &ac, &bc)
    abc := int64(math.Sqrt(float64(ab*ac*bc)))
    fmt.Print(4*(abc/bc + abc/ac + abc/ab))
}

 package main

 import (
 	"fmt"
 	"math"
 )

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

package main

import (
	"fmt"
	"math"
)

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

	a := math.Sqrt(float64(x * z / y))
	b := math.Sqrt(float64(x * y / z))
	c := math.Sqrt(float64(y * z / x))

	fmt.Println(4 * int32(a+b+c))
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var a, b, c float64
    fmt.Scanf("%f%f%f", &a, &b, &c)
    fmt.Print(4 * (math.Sqrt(a * b / c) + math.Sqrt(a * c / b) + math.Sqrt(b * c / a)))
}

// 224A-mic
package main

import (
    "fmt"
    "math"
)

func main() {
    var s1, s2, s3 int
    fmt.Scan(&s1, &s2, &s3)
    a := int(math.Sqrt(float64(s1 * s3 / s2)))
    b := int(math.Sqrt(float64(s1 * s2 / s3)))
    c := int(math.Sqrt(float64(s2 * s3 / s1)))
    fmt.Println(4 * (a + b + c))
}

package main

import (
    "fmt"
    "math"
)

func main() {
    var ab, ac, bc int
    fmt.Scanf("%d %d %d", &ab, &ac, &bc)
    abc := int(math.Sqrt(float64(ab*ac*bc)))
    fmt.Print(4*(abc/bc + abc/ac + abc/ab))
}

package main

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

func main() {
    scanner := bufio.NewScanner(os.Stdin)
    scanner.Split(bufio.ScanWords)
    var n,k int
    fmt.Scan(&n,&k)
    a := make([]int,n+1)
    ok := true
    for i := 1; i <= n; i++ {
        scanner.Scan()
        a[i], _ = strconv.Atoi(scanner.Text())
        if (i > k) && (a[i] != a[k]) {
            ok = false
        }
    }
    if ok {
        ans := k
        for a[ans-1] == a[k] { ans-- }
        fmt.Println(ans-1)
    } else {
        fmt.Println(-1)
    }
}


package main

import "fmt"

func recurs(a, b int) int {
	if a > b {
		return -1
	}
	if a == b {
		// fmt.Printf("%d\n", cnt)
		return 0
	}
	if recurs(a*2, b) != -1 {
		return 1 + recurs(a*2, b)
	}
	if recurs(a*3, b) != -1 {
		return 1 + recurs(a*3, b)
	}
	return -1
}

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

package main

import "fmt"

func main() {
	var n, m int64
	fmt.Scan(&n, &m)
	if m%n != 0 {
		fmt.Println(-1)
		return
	}
	m /= n
	cnt := 0
	for ; m%2 == 0; m /= 2 {
		cnt += 1
	}
	for ; m%3 == 0; m /= 3 {
		cnt += 1
	}
	if m > 1 {
		fmt.Println(-1)
		return
	}
	fmt.Println(cnt)
}

package main

import (
	"fmt"
)

func rec(a, b, cnt int) int {
	if a > b {
		return -1
	}
	if a == b {
		// fmt.Printf("%d\n", cnt)
		return cnt
	}
	if rec(a*2, b, cnt+1) != -1 {
		return rec(a*2, b, cnt+1)
	}
	if rec(a*3, b, cnt+1) != -1 {
		return rec(a*3, b, cnt+1)
	}
	return -1
}

func main() {
	var a, b int
	fmt.Scanf("%d %d\n", &a, &b)
	fmt.Printf("%d\n", rec(a, b, 0))
}

package main

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

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

	var n, m int
	fmt.Fscanf(buf, "%d %d\n", &n, &m)
	if m%n != 0 {
		fmt.Printf("-1\n")
		return
	}
	ans := 0
	m /= n
	for m > 1 {
		if m%2 == 0 {
			m /= 2
			ans++
		} else if m%3 == 0 {
			m /= 3
			ans++
		} else {
			fmt.Printf("-1\n")
			return
		}
	}
	fmt.Printf("%d\n", ans)

}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n,m int
	fmt.Fscan(in,&n)
	fmt.Fscan(in,&m)
	if(m == n){
		fmt.Fprint(out,0)
		return
	}
	temp := m / n;
	cnt := -1
	if(temp * n == m){

	for temp % 2 == 0{
		if(cnt == -1){
			cnt = 0
		}
		cnt++
		temp /= 2
	}

	for temp % 3 == 0{
		if(cnt == -1){
			cnt = 0
		}
		cnt ++
		temp /= 3
	}

	if(temp == 1){
		fmt.Fprint(out,cnt)
		return
	}

	}
	if(temp == 1){
		fmt.Fprint(out,cnt)
	}else{
		fmt.Fprint(out,-1)
	}

}

func max(i int, i2 int) int {
	if(i < i2){
		return i2
	}else{
		return i
	}
}
func min(i int , i2 int)  int {
	if(i < i2){
		return i
	}else{
		return i2
	}

}

package main

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

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

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

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

func main() {
  defer writer.Flush()

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

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

  div := b / a
  count := 0

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

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

package main

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

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

	var vl int

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

	var count int
	for vl > 1 {
		if vl%3 == 0 {
			vl /= 3
			count++
		} else if vl%2 == 0 {
			vl /= 2
			count++
		} else {
			fmt.Println(-1)
			return
		}
	}

	fmt.Println(count)
}

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

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

    input, _ := reader.ReadString('\n')
    input = strings.Trim(input, "\r\n")
    splitted := strings.Split(input, " ")

    n, _ := strconv.Atoi(splitted[0])
    m, _ := strconv.Atoi(splitted[1])

    if n == m {
        fmt.Println("0")
        os.Exit(0)
    } else if m % n != 0 {
        fmt.Println("-1")
        os.Exit(0)
    }

    div := m / n
    if div % 2 != 0 && div % 3 != 0 {
        fmt.Println("-1")
        os.Exit(0)
    }

    divisors := [3] int {6, 3, 2}
    ans := 0

    for i := 0; i < 3; i++ {
        for div % divisors[i] == 0 {
            if i == 0 {
                ans += 2
            } else {
                ans++
            }
            div /= divisors[i]
        }
    }

    if div == 1 {
        fmt.Println(ans)
    } else {
        fmt.Println("-1")
    }
}

package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	if m%n != 0 {
		fmt.Print("-1")
	} else {
		var div int = m / n
		var count int = 0
		for div%2 == 0 {
			count++
			div /= 2
		}
		for div%3 == 0 {
			count++
			div /= 3
		}
		if div != 1 {
			fmt.Printf("-1")
		} else {
			fmt.Printf("%v", count)
		}
	}
}

/*package main

import (
	"fmt"
)

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

}*/
package main

import (
	"fmt"
)

func main() {
	var n,m int
	d:=0
	fmt.Scan(&n)
	fmt.Scan(&m)
	if m%n!=0{
	    fmt.Printf("%d", -1)
	}
	if m%n==0{
	    x:=m/n
	    for (x%2==0||x%3==0)&&x>1{
	        if x%2==0{
	            x=x/2
	            d+=1
	        }
	        if x%3==0{
	            x=x/3
	            d+=1
	        }
	    }
	    if x==1{
	        fmt.Printf("%d", d)
	    }
	    if x!=1{
	        fmt.Printf("%d", -1)
	    }
	}

}

package main

import "fmt"

func main() {
	var n, m, fact, step int64
	fmt.Scanf("%d %d", &n, &m)
	if m != n {
		if m%n == 0 {
			fact = m / n
			for fact%3 == 0 {
				fact /= 3
				step++
			}
			for fact%2 == 0 {
				fact /= 2
				step++
			}
		}
		if fact != 1 {
			step = -1
		}
	}

	fmt.Println(step)
}

package main

import "fmt"

func main () {
	var n, m int
	fmt.Scanln(&n, &m)

	twoCount1 := 0
	threeCount1 := 0
	twoCount2 := 0
	threeCount2 := 0

	for n%2==0 {
		twoCount1 += 1
		n /= 2
	}
	for m%2==0 {
		twoCount2 += 1
		m /= 2
	}
	for n%3==0 {
		threeCount1 += 1
		n /= 3
	}
	for m%3==0 {
		threeCount2 += 1
		m /= 3
	}

	if m != n || twoCount1 > twoCount2 || threeCount1 > threeCount2 {
		fmt.Println("-1")
		return
	} else {
		fmt.Println(twoCount2 - twoCount1 + threeCount2 - threeCount1)
	}

}

package main

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

type Cin struct {
	scanner *bufio.Scanner
}

func (c *Cin) NextInt() int {
	c.scanner.Scan()
	line := c.scanner.Text()
	return c.convertInt(line)
}

func (c *Cin) NextIntSlice() []int {
	c.scanner.Scan()
	line := strings.Split(c.scanner.Text(), " ")
	var ret []int
	for _, s := range line {
		ret = append(ret, c.convertInt(s))
	}
	return ret
}

func (c *Cin) NextTwoInt() (int, int) {
	line := c.NextIntSlice()
	return line[0], line[1]
}

func (c *Cin) convertInt(data string) int {
	i, _ := strconv.Atoi(data)
	return i
}

var cin = &Cin{
	scanner: bufio.NewScanner(os.Stdin),
}

type element struct {
	value int
	step  int
	next  *element
	last  *element
}

func newElement(value, step int) *element {
	return &element{value: value, step: step}
}

type queue struct {
	head *element
	tail *element
}

func (q *queue) push(value, step int) {
	item := newElement(value, step)
	if q.isEmpty() {
		q.head = item
		q.tail = q.head
		return
	}
	item.last = q.tail
	q.tail.next = item
	q.tail = item
}

func (q *queue) isEmpty() bool {
	return q.head == nil
}

func (q *queue) pop() *element {
	if q.isEmpty() {
		panic("pop from empty queue")
	}
	item := q.head
	q.head = q.head.next
	return item
}

func newQueue() *queue {
	return &queue{}
}

func handle(n, m int) int {
	q := newQueue()
	q.push(n, 0)
	set := map[int]int{n: 0}
	for !q.isEmpty() {
		ele := q.pop()
		if ele.value == m {
			return ele.step
		}
		if ele.value > m {
			continue
		}
		if _, ok := set[ele.value*2]; !ok {
			set[ele.value*2] = ele.step + 1
			// fmt.Printf("val=[%v],step=[%v]\n", ele.value*2, ele.step+1)
			q.push(ele.value*2, ele.step+1)
		}
		if _, ok := set[ele.value*3]; !ok {
			set[ele.value*3] = ele.step + 1
			// fmt.Printf("val=[%v],step=[%v]\n", ele.value*3, ele.step+1)
			q.push(ele.value*3, ele.step+1)
		}
	}
	return -1
}

func main() {
	n, m := cin.NextTwoInt()
	fmt.Printf("%d\n", handle(n, m))
}

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

package main

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

func reduceDivisor(divisor int, moves int) int {
	if divisor == 1 {
		return moves
	} else if divisor%2 == 0 {
		return reduceDivisor(divisor/2, moves+1)
	} else if divisor%3 == 0 {
		return reduceDivisor(divisor/3, moves+1)
	}
	return -1
}

func Solve(n int, m int) int {
	if m%n != 0 || m < n {
		return -1
	}
	return reduceDivisor(m/n, 0)
}

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

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

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

package main

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

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

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

func main() {
  defer writer.Flush()

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

  if b % a !=  0 {
    printf("%d\n", -1)
    return
  }

  div := b / a
  count := 0

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

  if div == 1 {
    printf("%d\n", count)
  } else {
    printf("%d\n", -1)
  }
  return
}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n,m int
	fmt.Fscan(in,&n)
	fmt.Fscan(in,&m)
	cnt := -1
	if m % n == 0{
	temp := m / n
	for temp % 2 == 0{
		temp /= 2
		if(cnt == -1){
			cnt = 0
		}
		cnt ++
	}
	for temp % 3 == 0{
		temp /= 3
		if(cnt == -1){
			cnt = 0
		}
		cnt++
	}
	}else{
		cnt = -1
	}
	fmt.Fprint(out,cnt)
}

func max(i int, i2 int) int {
	if(i < i2){
		return i2
	}else{
		return i
	}
}
func min(i int , i2 int)  int {
	if(i < i2){
		return i
	}else{
		return i2
	}

}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n,m int
	fmt.Fscan(in,&n)
	fmt.Fscan(in,&m)
	if(n == m){
		fmt.Fprint(out,0)
		return
	}
	cnt := -1
	if m % n == 0{
	temp := m / n
	for temp % 2 == 0{
		temp /= 2
		if(cnt == -1){
			cnt = 0
		}
		cnt ++
	}
	for temp % 3 == 0{
		temp /= 3
		if(cnt == -1){
			cnt = 0
		}
		cnt++
	}
	}else{
		cnt = -1
	}
	fmt.Fprint(out,cnt)
}

func max(i int, i2 int) int {
	if(i < i2){
		return i2
	}else{
		return i
	}
}
func min(i int , i2 int)  int {
	if(i < i2){
		return i
	}else{
		return i2
	}

}

package main

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

func main()  {
	in := bufio.NewReader(os.Stdin)
	out := bufio.NewWriter(os.Stdout)
	defer out.Flush()
	var n,m int
	fmt.Fscan(in,&n)
	fmt.Fscan(in,&m)
	cnt := 0
	if m % n == 0{
	temp := m / n
	for temp % 2 == 0{
		temp /= 2
		cnt ++
	}
	for temp % 3 == 0{
		temp /= 3
		cnt++
	}
	}else{
		cnt = -1
	}
	fmt.Fprint(out,cnt)
}

func max(i int, i2 int) int {
	if(i < i2){
		return i2
	}else{
		return i
	}
}
func min(i int , i2 int)  int {
	if(i < i2){
		return i
	}else{
		return i2
	}

}

package main

import "fmt"

func main () {
	var n, m int
	fmt.Scanln(&n, &m)

	twoCount1 := 0
	threeCount1 := 0
	twoCount2 := 0
	threeCount2 := 0

	for n%2==0 {
		twoCount1 += 1
		n /= 2
	}
	for m%2==0 {
		twoCount2 += 1
		m /= 2
	}
	for n%3==0 {
		threeCount1 += 1
		n /= 3
	}
	for m%3==0 {
		threeCount2 += 1
		m /= 3
	}

	if m != n || twoCount1 > twoCount2 || threeCount1 > threeCount2 {
		println("-1")
		return
	} else {
		println(twoCount2 - twoCount1 + threeCount2 - threeCount1)
	}

}

package main

import "fmt"

func main() {
	var x, y, z, a, b, c int32
	fmt.Scan(&x, &y, &z, &a, &b, &c)
	var answer string = "YES"
	if a -= x; a < 0 {
		answer = "NO"
	}
	if b = a + b - y; b < 0 {
		answer = "NO"
	}
	if c = b + c - z; c < 0 {
		answer = "NO"
	}
	fmt.Printf("%v", answer)
}

package main

import "fmt"

func main() {
	var n, m, fact, step int64
	fmt.Scanf("%d %d", &n, &m)
	if m != n {
		if m%n == 0 {
			fact = m / n
			fmt.Println(fact)
			for fact%3 == 0 {
				fact /= 3
				step++
			}
			fmt.Println(fact)
			for fact%2 == 0 {
				fact /= 2
				step++
			}
			fmt.Println(fact)
		}
		if fact != 1 {
			step = -1
		}
	}

	fmt.Println(step)
}

package main

import "fmt"

func main() {
	var n, m, step int
	fmt.Scanf("%d %d", &n, &m)
	if m != n {
		if m%n == 0 {
			var fact = m / n
			for fact%3 == 0 {
				fact /= 3
				step++
			}
			for fact%2 == 0 {
				fact /= 2
				step++
			}
		} else {
			step = -1
		}
	}

	fmt.Println(step)
}

package main

import "fmt"

func main() {
	var n, m, fact, step int64
	fmt.Scanf("%d %d", &n, &m)
	if m != n {
		if m%n == 0 {
			fact = m / n
			for fact%3 == 0 {
				fact /= 3
				step++
			}
			for fact%2 == 0 {
				fact /= 2
				step++
			}
		}
		if fact != 1 {
			step = -1
		}
		step = -1
	}

	fmt.Println(step)
}

package main

import "fmt"

func main() {
	var n, m, step int
	fmt.Scanf("%d %d", &n, &m)
	if m != n {
		if m%n == 0 {
			var fact = m / n
			for fact%3 == 0 {
				fact /= 3
				step++
			}
			for fact%2 == 0 {
				fact /= 2
				step++
			}
			if step == 0 {
				step = -1
			}
		} else {
			step = -1
		}
	}

	fmt.Println(step)
}

package main

import "fmt"

func main() {
	var n, m, step uint
	fmt.Scanf("%d %d", &n, &m)
	if m%n == 0 {
		var fact = m / n
		for fact%3 == 0 {
			fact /= 3
			step++
		}
		for fact%2 == 0 {
			fact /= 2
			step++
		}
	}
	fmt.Println(step)
}


// 121A
package main

import (
	"fmt"
)

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

func main() {
	var a [15]int64
	var i, l, r, x, j, n1, n2 int64
	x, j = 0, 1
	fmt.Scan(&l, &r)
	for i = 0; i <= 10; i++ {
		a[i] = 0
	}
	for j <= r {
		i = 10
		a[i]++
		for a[i] > 2 {
			a[i] = 0
			i--
			a[i]++
		}
		j = 0
		for i = 1; i <= 10; i++ {
			if j > 0 && a[i] == 0 {
				break
			}
			if a[i] == 1 {
				n1 = 4
			} else {
				n1 = 0
			}
			if a[i] == 2 {
				n2 = 7
			} else {
				n2 = 0
			}
			j = j*10 + n1 + n2
		}
		if x == 0 && j >= l {
			x += j
		}
		if i <= 10 {
			continue
		}
		if j >= l {
			x += (min(j, r) - l) * j
			l = j
		}
	}
	fmt.Print(x)
}

package main

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

var scanner *bufio.Scanner

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

func getNext(x int64) int64 {
  //fmt.Fprintf(os.Stderr, "in: %d\n", x)
  digits := []int64{}
  for x != 0 {
    digits = append(digits, x%10)
    x /= 10
  }
  carry := int64(0)
  resetIndex := -1
  for i, digit := range digits {
    if carry == 1 {
      digit++
      carry = 0
    }
    if digit <= 4 {
      if digit < 4 {
        resetIndex = i-1
      }
      digits[i] = 4
    } else if digit <= 7 {
      if digit < 7 {
        resetIndex = i-1
      }
      digits[i] = 7
    } else {
      digits[i] = 4
      resetIndex = i
      carry = 1
    }
  }
  if carry == 1 {
    digits = append(digits, 4)
  }
  for i := 0; i <= resetIndex; i++ {
    digits[i] = 4
  }
  base := int64(1)
  for _, digit := range digits {
    x += base*digit
    base *= 10
  }
  //fmt.Fprintf(os.Stderr, " -> %d\n", x)
  return x
}

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

  left, right := getI64(), getI64()
  total := int64(0)
  max := getNext(right)
  current := left-1
  for {
    next := getNext(current+1)
    if next == max {
      total += (right-current)*next
      break
    }
    total += (next-current)*next
    current = next
  }
  writer.WriteString(fmt.Sprintf("%d\n", total))
}

package main

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

var scanner *bufio.Scanner

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

func getNext(x int64) int64 {
  digits := []int64{}
  for x != 0 {
    digits = append(digits, x%10)
    x /= 10
  }
  carry := int64(0)
  for i, digit := range digits {
    digit += carry
    carry = 0
    if digit <= 4 {
      digits[i] = 4
    } else if digit <= 7 {
      digits[i] = 7
    } else {
      digits[i] = 4
      carry = 1
    }
  }
  if carry == 1 {
    digits = append(digits, 4)
  }
  base := int64(1)
  for _, digit := range digits {
    x += base*digit
    base *= 10
  }
  return x
}

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

  left, right := getI64(), getI64()
  total := int64(0)
  max := getNext(right)
  current := left-1
  for {
    next := getNext(current+1)
    if next == max {
      total += (right-current)*next
      break
    }
    total += (next-current)*next
    current = next
  }
  writer.WriteString(fmt.Sprintf("%d\n", total))
}

package main

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

var scanner *bufio.Scanner

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

func getNext(x int64) int64 {
  //fmt.Fprintf(os.Stderr, "in: %d\n", x)
  digits := []int64{}
  for x != 0 {
    digits = append(digits, x%10)
    x /= 10
  }
  carry := int64(0)
  carryIndex := -1
  for i, digit := range digits {
    if carry == 1 {
      digit++
      carry = 0
    }
    if digit <= 4 {
      digits[i] = 4
    } else if digit <= 7 {
      digits[i] = 7
    } else {
      digits[i] = 4
      carry = 1
      carryIndex = i
    }
  }
  if carry == 1 {
    digits = append(digits, 4)
  }
  for i := 0; i <= carryIndex; i++ {
    digits[i] = 4
  }
  base := int64(1)
  for _, digit := range digits {
    x += base*digit
    base *= 10
  }
  //fmt.Fprintf(os.Stderr, " -> %d\n", x)
  return x
}

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

  left, right := getI64(), getI64()
  total := int64(0)
  max := getNext(right)
  current := left-1
  for {
    next := getNext(current+1)
    if next == max {
      total += (right-current)*next
      break
    }
    total += (next-current)*next
    current = next
  }
  writer.WriteString(fmt.Sprintf("%d\n", total))
}

package main

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

var scanner *bufio.Scanner

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

func getNext(x int64) int64 {
  fmt.Fprintf(os.Stderr, "%d ->", x)
  digits := []int64{}
  for x != 0 {
    digits = append(digits, x%10)
    x /= 10
  }
  carry := int64(0)
  for i, digit := range digits {
    digit += carry
    carry = 0
    if digit <= 4 {
      digits[i] = 4
    } else if digit <= 7 {
      digits[i] = 7
    } else {
      digits[i] = 4
      carry = 1
    }
  }
  if carry == 1 {
    digits = append(digits, 4)
  }
  base := int64(1)
  for _, digit := range digits {
    x += base*digit
    base *= 10
  }
  fmt.Fprintf(os.Stderr, " %d\n", x)
  return x
}

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

  span := int64(0)
  left, right := getI64(), getI64()
  total := uint64(0)
  max := getNext(right)
  current := left-1
  for current != max {
    next := getNext(current+1)
    total += uint64(next-current)*uint64(next)
    span += next-current
    fmt.Fprintf(os.Stderr, "(%d - %d = %d) * %d\n", next, current,
        next-current, next)
    if next < current {
      fmt.Fprintf(os.Stderr, "%d < %d\n", next, current)
      break
    }
    current = next
    fmt.Fprintf(os.Stderr, "  %d\n", total)
  }
  fmt.Fprintf(os.Stderr, "span = %d, right-left+1 = %d\n", span, right-left+1)
  writer.WriteString(fmt.Sprintf("%d\n", total))
}


package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"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 scanSlice(n int) []int64 {
	a := make([]int64, n)
	l, _ := reader.ReadString('\n')
	s := strings.Split(strings.TrimSpace(l), " ")
	for i := 0; i < n; i++ {
		a[i], _ = strconv.ParseInt(s[i], 10, 0)
	}
	return a
}

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

func main() {
	defer writer.Flush()

	a := scanSlice(14)

	maxcount := int64(0)
	for i := range a {
		if a[i] == 0 {
			continue
		}
		count, k := int64(0), a[i]
		a[i] = 0
		for j := range a {
			n := a[(i+j)%14] + k/14
			if (int64(j)-1+14)%14 < k%14 {
				n++
			}
			if n%2 == 0 {
				count += n
			}
		}
		maxcount, a[i] = max(maxcount, count), k
	}
	printF("%d", maxcount)
}

package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanInt(a interface{})             { fmt.Fscanf(reader, "%d", a) }
func scanlnInt(a interface{})           { fmt.Fscanf(reader, "%d\n", a) }
func scanChar(a interface{})            { fmt.Fscanf(reader, "%c", a) }
func scanString(a interface{})          { fmt.Fscanf(reader, "%s", a) }

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

func main() {
	defer writer.Flush()

	a := make([]int64, 14)
	for i := range a {
		scanInt(&a[i])
	}
	maxcount := int64(0)
	for i := int64(0); i < 14; i++ {
		count, k := int64(0), a[i]
		a[i] = 0
		for j := int64(0); j < 14; j++ {
			n := a[(i+j)%14] + k/14
			if (j-1+14)%14 < k%14 {
				n++
			}
			if n%2 == 0 {
				count += n
			}
		}
		maxcount, a[i] = max(maxcount, count), k
	}
	printf("%d", maxcount)
}

package main

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

func main() {
	var line string
	var max int64
	var start [14]int64
	var end [14]int64
	reader := bufio.NewReader(os.Stdin)
	line, _ = reader.ReadString('\n')
	arrStartStrings := strings.Split(strings.TrimSpace(line), " ")
	for i, v := range arrStartStrings {
		start[i], _ = strconv.ParseInt(v, 10, 0)
	}
	for i := 0; i < 14; i++ {
		end[i] = igra(start, i)
	}
	for i := 0; i < 14; i++ {
		if max < end[i]{
			max=end[i]
		}
	}
	fmt.Println(max)
}

func igra(start [14]int64, i int) int64 {
	var n, addToAll, result int64
	n = start[i]
	start[i] = 0
	if n == 0 {
		return 0
	}
	addToAll = n / 14
	n = n % 14
	for i := 0; i < 14; i++ {
		start[i] += addToAll
	}
	for n != 0 {
		if i+1 == 14 {
			i = 0
		} else {
			i++
		}
		start[i]++
		n--
	}
	for i := 0; i < 14; i++ {
		if start[i]%2==0{
			result+=start[i]
		}
	}
	return result
}

package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanInt(a interface{})             { fmt.Fscanf(reader, "%d", a) }
func scanlnInt(a interface{})           { fmt.Fscanf(reader, "%d\n", a) }
func scanChar(a interface{})            { fmt.Fscanf(reader, "%c", a) }
func scanString(a interface{})          { fmt.Fscanf(reader, "%s", a) }

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

func main() {
	defer writer.Flush()

	a := make([]int, 14)
	for i := range a {
		scanInt(&a[i])
	}
	maxcount := 0
	for i := range a {
		count, k := 0, a[i]
		a[i] = 0
		for j := range a {
			n := a[(i+j)%14] + k/14
			if (j-1+14)%14 < k%14 {
				n++
			}
			if n%2 == 0 {
				count += n
			}
		}
		maxcount, a[i] = max(maxcount, count), k
	}
	printf("%d", maxcount)
}

package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"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 scanSlice(n int) []int {
	a := make([]int, n)
	l, _ := reader.ReadString('\n')
	s := strings.Split(strings.TrimSpace(l), " ")
	for i := 0; i < n; i++ {
		a[i], _ = strconv.Atoi(s[i])
	}
	return a
}

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

func main() {
	defer writer.Flush()

	a := scanSlice(14)

	maxcount := 0
	for i := range a {
		if a[i] == 0 {
			continue
		}
		count, k := 0, a[i]
		a[i] = 0
		for j := range a {
			n := a[(i+j)%14] + k/14
			if (j-1+14)%14 < k%14 {
				n++
			}
			if n%2 == 0 {
				count += n
			}
		}
		maxcount, a[i] = max(maxcount, count), k
	}
	printF("%d", maxcount)
}

package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanInt(a interface{})             { fmt.Fscanf(reader, "%d", a) }
func scanlnInt(a interface{})           { fmt.Fscanf(reader, "%d\n", a) }
func scanlnSInt(n int) []int {
	s := make([]int, n)
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(reader, "%d ", &s[i])
	}
	fmt.Fscanf(reader, "%d\n", &s[n-1])
	return s
}
func scanChar(a interface{})   { fmt.Fscanf(reader, "%c", a) }
func scanString(a interface{}) { fmt.Fscanf(reader, "%s", a) }

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

func main() {
	defer writer.Flush()

	a := scanlnSInt(14)

	maxcount := 0
	for i := range a {
		if a[i] == 0 {
			continue
		}
		count, k := 0, a[i]
		a[i] = 0
		for j := range a {
			n := a[(i+j)%14] + k/14
			if (j-1+14)%14 < k%14 {
				n++
			}
			if n%2 == 0 {
				count += n
			}
		}
		maxcount, a[i] = max(maxcount, count), k
	}
	printf("%d", maxcount)
}

package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanInt(a interface{})             { fmt.Fscanf(reader, "%d", a) }
func scanlnInt(a interface{})           { fmt.Fscanf(reader, "%d\n", a) }
func scanChar(a interface{})            { fmt.Fscanf(reader, "%c", a) }
func scanString(a interface{})          { fmt.Fscanf(reader, "%s", a) }

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

func main() {
	defer writer.Flush()

	a := make([]int, 14)
	for i := range a {
		scanInt(&a[i])
	}
	maxcount := 0
	for i := range a {
		if a[i] == 0 {
			continue
		}
		count, k := 0, a[i]
		a[i] = 0
		for j := range a {
			n := a[(i+j)%14] + k/14
			if (j-1+14)%14 < k%14 {
				n++
			}
			if n%2 == 0 {
				count += n
			}
		}
		maxcount, a[i] = max(maxcount, count), k
	}
	printf("%d", maxcount)
}

package main

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

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

func printf(f string, a ...interface{}) { fmt.Fprintf(writer, f, a...) }
func scanf(f string, a ...interface{})  { fmt.Fscanf(reader, f, a...) }
func scanInt(a interface{})             { fmt.Fscanf(reader, "%d", a) }
func scanlnInt(a interface{})           { fmt.Fscanf(reader, "%d\n", a) }
func scanlnSInt(n int) []int {
	s := make([]int, n)
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(reader, "%d", &s[i])
	}
	fmt.Fscanf(reader, "%d\n", &s[n-1])
	return s
}
func scanChar(a interface{})   { fmt.Fscanf(reader, "%c", a) }
func scanString(a interface{}) { fmt.Fscanf(reader, "%s", a) }

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

func main() {
	defer writer.Flush()

	a := scanlnSInt(14)

	maxcount := 0
	for i := range a {
		if a[i] == 0 {
			continue
		}
		count, k := 0, a[i]
		a[i] = 0
		for j := range a {
			n := a[(i+j)%14] + k/14
			if (j-1+14)%14 < k%14 {
				n++
			}
			if n%2 == 0 {
				count += n
			}
		}
		maxcount, a[i] = max(maxcount, count), k
	}
	printf("%d", maxcount)
}


package main

import (
    "fmt"
    "math"
)

func main() {
    var n, pos, l, r int
    fmt.Scan(&n, &pos, &l, &r)
    var ans int
    if l == 1 {
        if r == n {
            ans = 0
        } else {
            ans = int(math.Abs(float64(pos - r))) + 1
        }
    } else if r == n {
        ans = int(math.Abs(float64(pos - l))) + 1
    } else {
        var diff int = int(math.Abs(float64(l - r)))
        var ans1 int = int(math.Abs(float64(pos - l))) + diff + 2
        var ans2 int = int(math.Abs(float64(pos - r))) + diff + 2
        if ans1 < ans2 {
            ans = ans1
        } else {
            ans = ans2
        }
    }
    fmt.Println(ans)
}

package main

import (
	"fmt"
	// "os"
	)

const INF = 0x3f3f3f3f

var n, m, tot int

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

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

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

func main() {
	// fd, _ := os.Open("in.txt")
	// os.Stdin = fd
	var T int = 1
	// fmt.Scanf("%d", &T)
	for ci:=1; ci<=T; ci++ {
		var l, r int
		fmt.Scanf("%d %d %d %d\n", &n, &m, &l, &r)
		// fmt.Printf("Case #%d: ", ci)
		if l==1 && r==n {
			fmt.Println(0)
		} else if l==1 {
			if m<=r {
				fmt.Println(1+r-m)
			} else {
				fmt.Println(1-r+m)
			}
		} else if r==n {
			if m<l {
				fmt.Println(1+l-m)
			} else {
				fmt.Println(1-l+m)
			}
		} else {
			mid := (l+r)>>1
			if m<=mid {
				fmt.Println(r+2-l+abs(m-l))
			} else {
				fmt.Println(r+2-l+abs(r-m))
			}
		}
	}
}

// http://codeforces.com/contest/915/problem/B
package main

import "fmt"

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

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

// comentar que nem gente
func main() {
	var n, pos, l, r int
	fmt.Scanf("%d %d %d %d\n", &n, &pos, &l, &r)
	if l == 1 && r == n {
		fmt.Printf("0\n")
	} else if l == 1 {
		fmt.Printf("%d\n", abs(r - pos) + 1)
	} else if r == n {
		fmt.Printf("%d\n", abs(l - pos) + 1)
	} else {
		if abs(l - pos) < abs(r - pos) {
			fmt.Printf("%d\n", abs(l - pos) + r - l + 2)
		} else {
			fmt.Printf("%d\n", abs(r - pos) + r - l + 2)
		}
	}
}

package main

/*
	If we breakdown the problem, we will found 3 cases:
	- if non-studies tabs exist both in left & right of studies tabs: 1, [2, 3, 4, 5], 6
	- if non-studies tabs exist only in right of studies tabs: [1, 2, 3], 4, 5, 6
	- if non-studies tabs exist only in left of studies tabs: 1, 2, 3, [4, 5, 6]

	For the first case the minimum number of seconds would be:
		min(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1
	In the second case:
		abs(pos-r) + 1
	In the third case:
		abs(pos-l) + 1
*/

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

func main() {
	var n, pos, l, r int
	stdin := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdin, "%d %d %d %d", &n, &pos, &l, &r)
	fmt.Println(solve(n, pos, l, r))
}

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

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

func solve(n, pos, l, r int) int {
	isLeftExist := abs(1-l) > 0
	isRightExist := abs(r-n) > 0
	if isLeftExist && isRightExist {
		return min(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1
	} else if isRightExist {
		return abs(pos-r) + 1
	} else if isLeftExist {
		return abs(pos-l) + 1
	}
	return 0
}

package main

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

func main() {
	var n, pos, l, r int
	stdin := bufio.NewReader(os.Stdin)
	fmt.Fscanf(stdin, "%d %d %d %d", &n, &pos, &l, &r)
	fmt.Println(solve(n, pos, l, r))
}

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

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

func solve(n, pos, l, r int) int {
	isLeftExist := abs(1-l) > 0
	isRightExist := abs(r-n) > 0
	if isLeftExist && isRightExist {
		return min(abs(pos-l), abs(pos-r)) + 1 + abs(l-r) + 1
	} else if isRightExist {
		return abs(pos-r) + 1
	} else if isLeftExist {
		return abs(pos-l) + 1
	}
	return 0
}

package main

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

func solve() {
	n := readInt()
	pos := readInt()
	l := readInt()
	r := readInt()
	if l == 1 && r == n {
		fmt.Println(0)
	} else if l == 1 {
		fmt.Println(abs(r-pos) + 1)
	} else if r == n {
		fmt.Println(abs(pos-l) + 1)
	} else {
		fmt.Println(min(abs(pos-l)+1+r-l+1, abs(r-pos)+1+r-l+1))
	}
}

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

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

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

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

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

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

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

//	URL: http://codeforces.com/contest/915/problem/B
//	PROBLEM RESTATEMENT
//		Let x be an array 1 ... n.
//		Given an integer pos in the range [1, n]
//		Two operations: move, and close.
//		The move operation either increment or decrements pos in range [1, n]
//		Close operator removes either (pos, n] or [1, pos) from the set.
//		Determine minimum number of operations needed to remove all elements
//		from x except for [l, r].
//	SETUP
//		There are three cases:
//			1) l = 1 and r = n.
//			2) l = 1 and r != n, by symmetry, also: l != 1 and r = n.
//			3) l != 1 and r != n.
//	CASES
//		1) We terminate in 0 operations - solved state.
//		2) Need to fix one interval: either (r, n] or [1, l). This cost is
//		   the distance from pos to r or pos to l, and one close() operation.
//		3) Need to fix both of the aforementioned intervals. We traverse to
//		   whichever interval is closer (r or l), close(), move r - l to the
//		   other interval, and close() again.

package main

import "fmt"

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

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

func solve(n int, pos int, l int, r int) int {
	if l == 1 && r == n {
		return 0
	} else if l == 1 && r != n {
		return abs(r-pos) + 1
	} else if l != 1 && r == n {
		return abs(l-pos) + 1
	} else {
		return r - l + min(abs(l-pos), abs(r-pos)) + 2
	}
}

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

package main

import (
	"fmt"
	// "os"
	)

const INF = 0x3f3f3f3f

var n, m, tot int

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

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

func main() {
	// fd, _ := os.Open("in.txt")
	// os.Stdin = fd
	var T int = 1
	// fmt.Scanf("%d", &T)
	for ci:=1; ci<=T; ci++ {
		var l, r int
		fmt.Scanf("%d %d %d %d\n", &n, &m, &l, &r)
		// fmt.Printf("Case #%d: ", ci)
		if l==1 && r==n {
			fmt.Println(0)
		} else if l==1 {
			if m<=r {
				fmt.Println(1+r-m)
			} else {
				fmt.Println(1-r+m)
			}
		} else if r==n {
			if m<l {
				fmt.Println(1+l-m)
			} else {
				fmt.Println(1-l+m)
			}
		} else {
			mid := (l+r)>>1
			if m<=mid {
				fmt.Println(r+2-l+m-l)
			} else {
				fmt.Println(r+2-l+r-m)
			}
		}
	}
}

package main

import (
	"fmt"
	// "os"
	)

const INF = 0x3f3f3f3f

var n, m, tot int

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

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

func main() {
	// fd, _ := os.Open("in.txt")
	// os.Stdin = fd
	var T int = 1
	// fmt.Scanf("%d", &T)
	for ci:=1; ci<=T; ci++ {
		var l, r int
		fmt.Scanf("%d %d %d %d\n", &n, &m, &l, &r)
		// fmt.Printf("Case #%d: ", ci)
		if l==1 && r==n {
			fmt.Println(0)
		} else if l==1 {
			if m<=r {
				fmt.Println(1+r-m)
			} else {
				fmt.Println(1-r+m)
			}
		} else if r==n {
			if m<l {
				fmt.Println(1+l-m)
			} else {
				fmt.Println(1-l+m)
			}
		} else {
			mid := l+r>>1
			if m<=mid {
				fmt.Println(r+2-l+m-l)
			} else {
				fmt.Println(r+2-l+r-m)
			}
		}
	}
}

// http://codeforces.com/contest/915/problem/B
package main

import "fmt"

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

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

// comentar que nem gente
func main() {
	var n, pos, l, r int
	fmt.Scanf("%d %d %d %d\n", &n, &pos, &l, &r)
	if l == 1 && r == n {
		fmt.Printf("0\n")
	} else if l == 1 {
		fmt.Printf("%d\n", abs(r - pos) + 1)
	} else if r == n {
		fmt.Printf("%d\n", abs(l - pos) + 2)
	} else {
		if abs(l - pos) < abs(r - pos) {
			fmt.Printf("%d\n", abs(l - pos) + r - l + 2)
		} else {
			fmt.Printf("%d\n", abs(r - pos) + r - l + 2)
		}
	}
}

package main

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

func solve() {
	n := readInt()
	pos := readInt()
	l := readInt()
	r := readInt()
	if l == 1 && r == n {
		fmt.Println(0)
	} else if l == 1 {
		fmt.Println(r - pos + 1)
	} else if r == n {
		fmt.Println(pos - l + 1)
	} else {
		fmt.Println(min(pos-l+1+r-l+1, r-pos+1+r-l+1))
	}
}

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

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

// IO

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

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

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

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

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


package main

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

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

	c, _ := strconv.Atoi(s[0])
	if (c % 2) == 1 {
		c += 1
	}
	fmt.Println(c / 2)
	//x, _ := strconv.ParseInt(s[1], 10, 64)

}

package main

import "fmt"

func main(){
	var n int
	fmt.Scanf("%d", &n)
	if n & 1 == 1 {
		fmt.Printf("%d", (n + 1) >> 1)
	}else{
		fmt.Printf("%d", n >> 1)
	}
}

package main

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

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

	c, _ := strconv.Atoi(s[0])
	fmt.Println(math.Ceil(float64(c) / 2.0))
	//x, _ := strconv.ParseInt(s[1], 10, 64)

}


package main

import (
	"bufio"
	"errors"
	"flag"
	"fmt"
	"log"
	"os"
	"strconv"
	"time"
)

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

var ()

func getAns(array []int) int {
	// logln("lol")
	// logln(array)
	n := len(array)
	res := 0
	for {
		count := 0
		left := -1
		sum := -1

		for i := 0; i < n; i++ {
			if array[i] == -1 {
				continue
			}

			left = i
			sum = 1
			break
		}

		if left != -1 {
			for j := left + 1; j < n; j++ {
				if array[j] == -1 {
					continue
				}

				if array[left] == array[j] {
					sum++
				} else {
					if sum >= 3 {
						for i := left; i < j; i++ {
							array[i] = -1
						}
						count = sum
						sum = 0
						break
					}

					left = j
					sum = 1
				}
				// logln(array)
			}

			if sum >= 3 {
				for i := left; i < n; i++ {
					array[i] = -1
				}
				count = sum
			}
			// logln(array)
		}

		if count == 0 {
			break
		}
		res += count
		count = 0
	}
	return res - 1
}

func solve() {
	n := readInt()
	_ = readInt()
	x := readInt()
	array := make([]int, n)
	for i := 0; i < n; i++ {
		array[i] = readInt()
	}

	best := 0
	for j := 0; j <= n; j++ {
		var newArray []int
		if j > 0 {
			newArray = append(newArray, array[:j]...)
		}
		newArray = append(newArray, x)
		if j < n {
			newArray = append(newArray, array[j:]...)
		}
		best = maxInt(best, getAns(newArray))
	}
	printInt(best)
	printLine()
}

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

// IO.

var (
	scanner *bufio.Scanner
	writer  *bufio.Writer
	logger  *log.Logger
)

func main() {
	local := flag.Bool("local", false, "Equals true, if run is local.")
	flag.Parse()

	var (
		input  *os.File
		output *os.File
	)

	if *local {
		startTime := time.Now()
		defer func() {
			println(fmt.Sprintf("Time: %.5fs", time.Since(startTime).Seconds()))
		}()
		input, _ = os.Open("/home/outside/coding/workspace/go/io/input.txt")
		output, _ = os.Create("/home/outside/coding/workspace/go/io/output.txt")
		logger = log.New(output, "log: ", 0)
	} else {
		input = os.Stdin
		output = os.Stdout
		// input, _ = os.Open("")
		// output, _ = os.Create("")
	}
	defer input.Close()
	defer output.Close()

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

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

	solve()
}

// Read.

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

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

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

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

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

// Write.

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

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

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

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

func printFLoat64(value float64) {
	printString(strconv.FormatFloat(value, 'f', 20, 64))
}

// Log.

func logln(value ...interface{}) {
	writer.Flush()
	logger.Println(value...)
}
func logf(format string, value ...interface{}) {
	writer.Flush()
	logger.Printf(format, value...)
}

// Tuple

type Tuple struct {
	a, b int
}

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

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

type TupleSlice []Tuple

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

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

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

// Min, max, abs.

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

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

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

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

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

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

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

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

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

// Set Key interface implementations.

type Int int

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

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

// Set.

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

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

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

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

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

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

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

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

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

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

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

	return x
}

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

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

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

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

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

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

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

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

package main

import "fmt"

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

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

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

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

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

	}

	return possibilidades
}

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

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

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

			}
			grupo = 1
		}

		i++
	}

	return row
}

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

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

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

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

package main

import "fmt"

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

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

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

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

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

	}

	return possibilidades
}

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

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

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

			}
			grupo = 1
		}

		i++
	}

	return row
}

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

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

	// Copia e algoritmos.
	jogadas := possiveisJogadas(row, num, x)
	if len(jogadas) == 0 {
		fmt.Println(0)
	}

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


package main

import "fmt"

func main() {
    var pass,code string
    fmt.Scan(&pass)
    digit := make(map[string]int)
    for i := 0; i < 10; i++ {
        fmt.Scan(&code)
        digit[code] = i
    }
    for i := 0; i < 8; i++ {
        a := pass[i*10:(i+1)*10]
        fmt.Print(digit[a])
    }
    fmt.Println()
}

package main

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

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

func main() {
  scanner := bufio.NewScanner(os.Stdin)
  scanner.Split(bufio.ScanWords)
  writer := bufio.NewWriter(os.Stdout)
  defer writer.Flush()
  scanner.Scan()
  code := scanner.Text()
  digits := map[string]int{}
  for i := 0; i < 10; i++ {
    scanner.Scan()
    digits[scanner.Text()] = i
  }
  for i := 0; i < 8; i++ {
    digit := digits[code[10*i:10*(i+1)]]
    writer.WriteString(fmt.Sprintf("%d", digit))
  }
  writer.WriteString("\n")
}