n = gets.chomp.to_i

if n % 2 == 0
  print "Mahmoud"
else
  print "Ehab"
end

n = gets.to_i
if n % 2 == 1
  puts "Ehab"
else
  puts "Mahmoud"
end

#bismillahir rahmanir rahim

n = gets.to_i

if n%2==0
    puts "Mahmoud"
else
    puts "Ehab"
end

# https://codeforces.com/problemset/problem/959/A

number = gets.to_i

if number % 2 == 0
  puts "Mahmoud"
else
  puts "Ehab"
end

t = gets.chomp.to_i

case t%2==0
    when true
        puts "Mahmoud"
    when false
        puts "Ehab"
end

n = gets.chomp.to_i

if n.odd?
  puts "Ehab"
else
  puts "Mahmoud"
end

puts gets.to_i.odd? ? "Ehab" : "Mahmoud"

n = gets.to_i
puts n.odd? ? 'Ehab' : 'Mahmoud'

##Please tell me this problmem can't be solved with this please

def winner(n)
	return "Ehab" if n % 2 != 0
	return "Mahmoud" if n % 2 == 0
end

n = gets.chomp.to_i
puts(winner(n))

n = gets.to_i
puts [:Mahmoud, :Ehab][n & 1]

# coding: utf-8

# if __FILE__ == $0
# end

n = gets.to_i

# picking -> Mahmoud picks 'a' and it is even.
#         -> Ehab picks 'a' and it is odd.
#         -> repeat until someone wins

# optimal play
# no fun

puts "Ehab" if n.odd?
puts "Mahmoud" if n.even?

puts gets.chomp.to_i.even? ? "Mahmoud" : "Ehab"

n = Integer(gets.chomp)
if n%2 == 0
    puts "Mahmoud"
else
    puts "Ehab"
end

n = gets.to_i
puts(n%2 == 0 ? 'Mahmoud' : 'Ehab')

puts gets.to_i.even? ? 'Mahmoud' : 'Ehab'

n = gets.to_i
puts n == 1 ? "Ehab" : "Mahmoud"

n = gets.chomp
if n%2 == 0
    puts "Mahmoud"
else
    puts "Ehab"
end


a, b, c = gets.split.map &:to_i

def solve(a,b,c)
  ar = Array.new(1000001) { 0 }
  ans = 0
  mod = 1073741824
  for i in 1..a do
    for j in 1..b do
      for k in 1..c do
        d = i*j*k
        ans += ret_div(ar, d, mod)
      end
    end
  end
  puts ans
end

def ret_div(ar, el, mod)
  return ar[el] if ar[el]>0
  j = 1
  div = 0
  while j*j<=el do
    if el%j == 0
      div+=2
    end
    j+=1

  end
  div-=1 if (j-1)*(j-1) == el
  ar[el] = div % mod
  ar[el]
end

solve a, b ,c


dx = gets.chomp.split("|")
dx[0] ||= ""
dx[1] ||= ""
f = false

if dx[0].length > dx[1].length
  f = true
  dx[0], dx[1] = dx[1], dx[0]
end
dx[0] += gets.chomp
if dx[0].length < dx[1].length or (dx[0].length - dx[1].length) % 2 != 0
  puts "Impossible"
else
  tmp = dx[0].length - dx[1].length
  dx = [dx[0][0...(dx[1].length + (tmp / 2))], dx[1] + dx[0][(dx[1].length + (tmp / 2))..-1]]
  if f
    puts dx[1] + "|" + dx[0]
  else
    puts dx[0] + "|" + dx[1]
  end
end

a, b = gets.chomp.split '|'
a = '' if not a
b = '' if not b
c = gets
(c ? c.chomp : '').each_char { |ch|
  if a.size < b.size then a += ch
  else b += ch end
}
puts a.size == b.size ? a + '|' + b : 'Impossible'

s = gets.strip
a, b = s.split("|")

a = a.to_s
b = b.to_s

c = gets.strip
c = c.to_s

if a.size > b.size then
  diff = a.size - b.size
  if diff <= c.size then
    b += c[0...diff]
    c = c[diff..-1]
  end
end
if a.size < b.size then
  diff = b.size - a.size
  if diff <= c.size then
    a += c[0...diff]
    c = c[diff..-1]
  end
end

if a.size == b.size
  if c.size.even?
    puts "#{a}#{c[0...c.size/2]}|#{b}#{c[c.size/2..-1]}"
  else
    puts "Impossible"
  end
else
  puts "Impossible"
end

s=gets.chomp+'|x'
t=gets.chomp
l,r=s.split '|'
t.each_char{|c|l.size>r.size ? r<<c :l<<c}
puts l.size!=r.size ? 'Impossible':"#{l}|#{r}"

s=gets.chomp
t=gets.chomp
l,r=s.split '|'
l||=""
r||=""
m=l.size+r.size+t.size
if m%2==0
  m/=2
  p=m-l.size
  q=m-r.size
  if p>=0 && q>=0
    l<<t[0...p]
    r<<t[p...t.size]
    puts "#{l}|#{r}"
    exit
  end
end
puts 'Impossible'


n=gets.to_i
m=1
r=8
while n>0
	if n%2==1 then
		m=(m*r)%10
	end
	r=(r*r)%10
	n/=2
end
puts m

n = gets.chomp.to_i
if n == 0
	puts 1
else
	puts [8,4,2,6][(n-1)%4]
end

n=gets.to_i
x=1378
r=1
while n>0
    r=r*x%10 if n.odd?
    x=x*x%10
    n>>=1
end
p r

n = gets.chomp.to_i
if n == 0
	print 1
else
	if n % 4 == 2
		print 4
	elsif n % 4 == 3
		print 2
	elsif n % 4 == 0
		print 6
	elsif n % 4 == 1
		print 8
	end
end

n = gets.strip.to_i
if n.zero?
  puts 1
  exit
end
a = [8, 4, 2, 6]
n -= 1
puts a[n % 4]

n=gets.to_i
if n==0
    puts 1
else
    puts [8,4,2,6][(n-1)%4]
end

n=gets.to_i
if n == 0
    puts 1
else
    puts "8426"[(n+3)%4]
end

n = gets.to_i

if n.zero?
  puts 1
else
  puts [6, 8, 4, 2][n%4]
end

def modPow( x, n, m )
    answer = 1
    while n > 0
        if n % 2 != 0
            answer = ( answer * x ) % m
        end
        x = (x*x) % m;
        n /= 2
    end
    return answer
end

exponent = gets.chomp.to_i
puts modPow(1378, exponent, 10)

n = gets.to_i

if n == 0
  puts "1"
else
  case n%4
  when 1
    puts "8"
  when 2
    puts "4"
  when 3
    puts "2"
  when 0
    puts "6"
  end
end

a = gets.chomp.to_i
if a==0
    p 1
elsif a%4==1
    p 8
elsif a%4==2
    p 4
elsif a%4==3
    p 2
else
    p 6
end

n = gets.chomp.to_i
if n == 0
     puts 1
     exit
end
case n%4
when 0
    puts 6
when 1
    puts 8
when 2
    puts 4
when 3
    puts 2
end

n = gets.to_i

if n == 0
  puts "1"
else
  case n%4
  when 1
    puts "8"
  when 2
    puts "4"
  when 3
    puts "2"
  when 4
    puts "6"
  end
end

n = gets.chomp.to_i
case n%4
when 0
    puts 6
when 1
    puts 8
when 2
    puts 4
when 3
    puts 2
end

# coding: utf-8

# if __FILE__ == $0
# end

# power of 1378, and last digit
# and cyclic.
# 1 -> 8, 2 -> 6, 3  -> 2, 4 -> 6, 5 -> 8
n = gets.to_i
base = 8
((n-1)%6).times {
    base *= 8
    base = base % 10
}

puts base

n = gets.strip.to_i
a = [8, 4, 2, 6]
n -= 1
puts a[n % 4]


#!/usr/bin/ruby
a=Array(1024)
1024.times{|i| a[i]=i.to_s(2).to_i}
n=gets.chomp.to_i
1024.times{|i| if a[i+1]>n then puts i;exit end}

ns = gets.chomp
s2 = ""
for i in 0..ns.length-1
	wk = ns[i].to_i
	if wk > 1
		for j in i..ns.length-1
			s2 << "1"
		end
		break
	else
		s2 << ns[i]
	end
end
puts s2.to_i(2)

n = gets.to_i
m = 0
loop do
	break if ('%b' % m).to_i > n
	m += 1
end
p m - 1

n=gets.to_i
ans=0
(1<<12).times{|i|
        v=0
        for j in 0..11
                v*=10
                if ((i>>j)&1)==1 then
                        v+=1
                end
        end
        if v<=n then
                ans+=1
        end
}
p ans-1

$n = gets.to_i

$counter = 0
$len = Math.log10($n).to_i + 1

def solve(num, depth)
	if depth == $len
		$counter += 1 if num > 0 and num <= $n
		return
	end

	[0, 1].each do |i|
		solve(num*10 + i, depth+1)
	end
end

solve(0, 0)

puts $counter

def bin2dec (b)
  ans = 0
  base = 1
  while b > 0 do
    ans += (b % 2) * base
    b = b >> 1
    base = base * 10
  end
  return ans
end
n = gets.to_i;
m = n
len = 0
while m != 0 do
  len += 1
  m /= 10
end
cand = (1 << len) - 1
#p cand
ans = 0
for i in 1..cand do
  v = bin2dec(i)
  if v >= 1 && v <= n then ans += 1 end
#  print i, " " , v
#  puts
end
print ans
puts

n = gets.to_i
res = 0
ns = [1]
i = 10
while ns.last<(10**9 + 1)
  break  if i>n
  temp = [i]
  flag = false
  ns.each do |x|
    if (x+i)<=n
      temp << x+i
    else
      flag = true
    end
  end
  ns += temp.sort
  break if flag
  i *= 10
end
puts ns.size

n = gets.to_i
i = 1
a = 1
c = 0
while a <= n
	c += 1
	i += 1
	a = i.to_s(2).to_i
end
puts c

n = gets.to_i
m = 0
loop do
  break if (m.to_s(2)).to_i > n
  m += 1
end
p m - 1

s = gets.strip

one = false

0.upto(s.length-1) do |i|
  if (s[i] > ?1) or (one)
    s[i] = ?1
    one = true
  end
end

n = s.to_i(2)
puts n

$n = 0
$res = 0
def go(x)
  if x <= $n then
    $res += 1
    go(10 * x + 0)
    go(10 * x + 1)
  end
end
$n = gets.chomp.to_i
go(1)
p $res

n = gets.to_i

z = 1
res=0
while z.to_s(2).to_i <= n
  z+=1
  res+=1
end

puts res

ns = gets.chomp
s2 = ""
for i in 0..ns.length-1
	wk = ns[i].to_i
	wk = 1 if wk > 1
	s2 << wk.to_s
end
puts s2.to_i(2)

$n = gets.to_i

$counter = 0
$len = Math.log10($n).to_i + 1

def solve(num, depth)
	if depth == $len
		$counter += 1 if num < $n
		return
	end

	[0, 1].each do |i|
		solve(num*10 + i, depth+1)
	end
end

solve(0, 0)

puts $counter


# Try Codeforces
# author: Leonardone @ NEETSDKASU

n, k = gets.strip.split.map &:to_i

v = n / k

if v.even?
    puts :NO
else
    puts :YES
end

# Codeforces My Practice
# author: Leonardone @ NEETSDKASU

n, k = gets.strip.split.map &:to_i

k2 = k * 2
v = n % k2

if v < k
    puts :NO
else
    puts :YES
end

n, k = gets.split.map(&:to_i)

puts (n / k).odd? ? 'YES' : 'NO'

n, k = gets.strip.split.map(&:to_i)
ans = "YES"
div = n / k
ans = "NO" if div.even?
puts ans

n,k=gets.split.map{|e| e.to_i}
t=n/k
if t%2==1 then
	puts "YES"
else
	puts "NO"
end

n, k=gets.split.map &:to_i
puts (n/k).odd? ? "YES" : "NO"

n,m = gets.split
n = n.to_i
m = m.to_i
k = Integer(n / m)
if k % 2 == 1 then
	puts "YES"
else
	puts "NO"
end

# coding: utf-8

# if __FILE__ == $0
# end

n, k = gets.split.map(&:to_i)

if (n/k).odd?
    puts "YES"
else
    puts "NO"
end

nk = gets.chomp.split.map(&:to_i)
n = nk[0]
k = nk[1]

if (n/k)%2 == 0
	print "NO"
else
	print "YES"
end

n,k = gets.split.map(&:to_i)
n/=k
puts (n&1!=0 ? "YES" : "NO")

n,k = gets.strip.split.map(&:to_i)

def kek(n,k)
  (n/k).even? ? 'NO' : 'YES'
end
puts kek(n,k)

a=gets.split.map &:to_i
puts (a[0]/a[1])%2==0 ?"NO":"YES"

n, k = gets.split.map(&:to_i)
case (n - k)%(2*k)
when 0..k-1
  puts "YES"
when k..2*k-1
  puts "NO"
end

# https://codeforces.com/problemset/problem/832/A
s = gets.chomp
arr = s.split(' ')

n = arr[0].to_i
k = arr[1].to_i
if ((n % k == 0) && (n / k % 2 != 0)) || ((n % k != 0) && (n / k % 2 != 0))
  puts 'YES'
else
  puts 'NO'
end

n, k=gets.split.map(&:to_i)

if (n/k)%2==1
  puts 'YES'
else
  puts 'NO'
end

# Try Codeforces
# author: Leonardone @ NEETSDKASU

n, k = gets.strip.split.map &:to_i

k2 = k * 2
v = n % k2

if v < n
    puts :NO
else
    puts :YES
end

# Try Codeforces
# author: Leonardone @ NEETSDKASU

n, k = gets.strip.split.map &:to_i

k2 = k * 2
v = n % k2

if v <= n
    puts :NO
else
    puts :YES
end

# Try Codeforces
# author: Leonardone @ NEETSDKASU

n, k = gets.strip.split.map &:to_i

v = n / k

if v.odd?
    puts :NO
else
    puts :YES
end

n, k = gets.strip.split.map(&:to_i)
ans = "YES"
mod = n % k
div = n / k
ans = "NO" if div.even? && mod > 0
puts ans

nk = gets.chomp.split.map(&:to_i)
n = nk[0]
k = nk[1]

if n%k == 0
	print "YES"
else
	if (n/k)%2 == 0
		print "NO"
	else
		print "YES"
	end
end

a=gets.split.map &:to_i
puts (a[1]/a[0])%2==0 ?"NO":"YES"


h,m=gets.split(':').map(&:to_i)
t=Time.gm(2008,7,7,h,m)+gets.to_i*60
puts t.strftime('%H:%M')

h, m = gets.split( ":" ).map( &:to_i )
a = gets.to_i
t = Time.local( 2016, 1, 1, h, m, 0 )
puts ( t + a * 60 ).strftime( "%H:%M" )

#!/usr/bin/ruby
def encode(n) '%02d:%02d'%[n/60,n%60] end
def decode(s)
	h,m=s.split(':').map(&:to_i)
	h*60+m
end
puts encode((decode(gets)+gets.to_i)%1440)

h, m = gets.chomp.split(':').map(&:to_i)
a = gets.chomp.to_i

t = Time.new(2002, 10, 31, h, m, 0)
t2 = t + a * 60

puts "#{t2.hour.to_s.rjust(2, '0')}:#{t2.min.to_s.rjust(2, '0')}"


n, k=gets.split.map &:to_i
s=gets.split.map(&:to_i).inject(0, :+)
r=0
while 2*s<2*k*n-n
	r+=1
	s+=k;
	n+=1
end
puts r

# Try Codeforces
# author: Leonardone @ NEETSDKASU
############################################################
def gs() gets.strip end
def gi() gets.to_i end
def gss() gs.split end
def gis() gss.map(&:to_i) end
def nmapf(n,f) n.times.map{ __send__ f } end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end
def nsum(n) n * (n + 1) / 2 end
def vcount(d,r=Hash.new(0)) d.inject(r){|m,e| m[e]+=1;m} end
############################################################

n, k = gis
a = gis

sum = a.inject(:+) * 10

lim = (k - 1) * 10 + 5

i = n
loop do
    break if sum / i >= lim
    sum += k * 10
    i += 1
end

puts (i - n)


a, b, c, d, e, f = gets.split.map {|n| n.to_f }
conv_ratio = (a/b)*(c/d)*(e/f)

if d == 0
  puts "Hermione"
elsif c == 0 or (a == 0 and b > 0)
  puts "Ron"
elsif conv_ratio < 1
  puts "Ron"
else
  puts "Hermione"
end

a, b, c, d, e, f = gets.split.map {|n| n.to_f }
conv_ratio = (a/b)*(c/d)*(e/f)

if d == 0
  puts "Hermione"
elsif c == 0
  puts "Ron"
elsif b == 0
  puts "Hermione"
elsif a == 0
  puts "Ron"
elsif f == 0
  puts "Hermione"
elsif conv_ratio < 1
  puts "Ron"
else
  puts "Hermione"
end

a, b, c, d, e, f = gets.chomp.split.map{|e| e.to_i}

if (a * b * c * d * e * f != 0)
  if (a * c * e < b * d * f)
    puts "Ron"
  else
    puts "Hermione"
  end
else
  if (d == 0)
    puts "Hermione"
  elsif (c == 0)
    puts "Ron"
  else # d, c > 0
    if (b == 0)
      puts "Hermione"
    elsif (a == 0)
      puts "Ron"
    else # a, b > 0
      if (f == 0)
        puts "Hermione"
      else
        puts "Ron"
      end
    end
  end
end

a,b,c,d,e,f = gets.split(' ').map(&:to_i)
if (c==0 && d !=0) || (a==0 &&  b !=0 && c*d !=0)
  puts "Ron"
else
  if (a*c*e) < (b*d*f)
    puts "Ron"
  else
    puts "Hermione"
  end
end

a, b, c, d, e, f = gets.split(' ').map{|s| s.to_i}
ab, cd, ef = [[a, b], [c, d], [e, f]].map{|aa, bb|bb/aa.to_f}
g = ab*cd*ef
m = [cd.infinite?, ab.infinite?&&cd>0, ef.infinite?&&ab>0&&cd>0]
puts (m.any?||g>1.0) ? 'Ron' : 'Hermione'

def foo(a)
  if a[3] == 0
    return false
  end

  if a[2] == 0 && a[3] > 0
    return true
  end

  if a[1]*a[3] == 0
    return false
  end

  if a[0]*a[2] == 0 && a[1]*a[3] > 0
    return true
  end

  if a[1]*a[3]*a[5] == 0
    return false
  end

  if a[0]*a[2]*a[4] == 0 && a[1]*a[3]*a[5] > 0
    return true
  end

  pr = 1.0
  0.step(4, 2) do |i|
    pr = pr / a[i] * a[i-1]
  end
  if pr > 1
    return true
  else
    return false
  end
end

a = gets.split.map(&:to_i)
puts(foo(a) ? "Ron" :  "Hermione")

a = gets.split.map(&:to_i)
if a[2] == 0 and a[3] != 0
  puts "Ron"
else
  puts(a[0]*a[2]*a[4] < a[1]*a[3]*a[5] ? "Ron" : "Hermione")
end

a, b, c, d, e, f = gets.split.map {|n| n.to_f }
conv_ratio = (a/b)*(c/d)*(e/f)

if d == 0
  puts "Hermione"
elsif c == 0
  puts "Ron"
elsif b == 0 or f == 0
  puts "Hermione"
elsif conv_ratio < 1
  puts "Ron"
else
  puts "Hermione"
end

a, b, c, d, e, f = gets.split(' ').map{|s| s.to_i}
ab, cd, ef = [[a, b], [c, d], [e, f]].map{|aa, bb|bb/aa.to_f}
g = ab*cd*ef
puts (cd.infinite?||g>1.0) ? 'Ron' : 'Hermione'

a, b, c, d, e, f = gets.split(' ').map{|s| s.to_i}
g = (b/a.to_f) * (d/c.to_f) * (f/e.to_f)
puts (g>1.0) ? 'Ron' : 'Hermione'

a, b, c, d, e, f = gets.split(' ').map{|s| s.to_i}
ab, cd, ef = [[a, b], [c, d], [e, f]].map{|aa, bb|bb/aa.to_f}
g = ab*cd*ef
m = [cd.infinite?, ab.infinite?&&!cd.nan?, ef.infinite?&&!ab.nan?&&!cd.nan?]
puts (m.any?||g>1.0) ? 'Ron' : 'Hermione'


n, a, b = gets.split.map(&:to_i)
ans, k = 1, 2
until (a-1)/k == (b-1)/k do
  k *= 2
  ans += 1
end
puts k == n ? "Final!" : ans

n, a, b = gets.chomp.split(" ").map {|k| k.to_i}

tr = 0
while n != 0
	n = n/2
	tr +=1
end
tr -=1
out = 0
while true
	r = 0
	r = 1 if a % 2 != 0
	a = (a/2) + r
	r = 0
	r = 1 if b % 2 != 0
	b = (b/2) + r
	out += 1
	if a == b
		break
	end
end
out = "Final!" if out == tr
puts out

n,a,b=gets.split.map &:to_i
a-=1
b-=1
c=1
while a/2!=b/2
	a/=2
	b/=2
	c+=1
end
puts 1<<c==n ? 'Final!' : c

n,a,b = gets.split.map(&:to_i)
k = 2
ans = 1
while (a-1)/k != (b-1)/k
  k *= 2
  ans += 1
end
puts k == n ? "Final!" : ans

n, a, b = gets.split.map(&:to_i)
ans, k = 0, 2
until (a-1)/k == (b-1)/k do
  k *= 2
  ans += 1
end
puts k == n ? "Final!" : ans


def calc(stones)
	threes = (stones / 3).to_i # 1

	remaining = stones - (threes * 3) # 2

	count = threes * 2

	if remaining == 2
		count += 1 #, 1
		count -= 1 # 1, 2 -> 3
		count += 1 #3, 1
	end

	if remaining == 1
		count += 1
	end

	count = 1 if count == 0

	count
end

stones = gets.chomp.to_i

puts calc(stones)

n = gets.to_i

ans = n / 3 * 2
ans += 1 if n % 3 != 0
puts ans

n=gets.to_i
if n%3==0 #then
  p n/3*2
else
  p n/3*2+1
end

n = gets.to_i
begin
  puts n%3 == 0 ? n/3 * 2 : n/3 * 2 + 1
rescue
end

#! ruby
# Try Codeforces
# author: Leonardone @ NEETSDKASU
############################################################
def gs() gets.chomp end
def gi() gets.to_i end
def gss() gs.split end
def gis() gss.map(&:to_i) end
def nmapf(n,f) n.times.map{ __send__ f } end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end
def nsum(n) n * (n + 1) / 2 end
def vcount(d,r=Hash.new(0)) d.inject(r){|r,e| r[e]+=1;r} end
############################################################

n = gi

if n < 3
    puts 1
    exit
end

=begin

n = 3
1 2

n = 4
1 2 1

n = 5
1 2 1

n = 6
1 2 1 2

n = 7
1 2 1 2 1

n = 8
1 2 1 2 1

n = 9
1 2 1 2 1 2

n = 10
1 2 1 2 1 2 1

n = 11
1 2 1 2 1 2 1

a n
3 4 5
4 6
5 7 8
6 9
7 10 11
8 12

=end

if n % 3 == 0
    n /= 3
    puts 2 * n
else
    n /= 3
    puts 2 * n + 1
end

n = readline.to_i
ct = n / 3
ct *= 2
if n % 3 != 0
  ct += 1
end
puts ct

a=gets.chomp.to_i
ans=((a/3.0).ceil)*2
if a%3==0
puts "#{ans}"
else
puts "#{ans-1}"
end

n = gets.to_i
ans = n / 3 * 2
if (n % 3 == 0)
	p ans

else
	p ans + 1
end

n = gets.to_i

ans = 0

ans += n/3 * 2
n %= 3

ans += 1 if n > 0

puts ans

n = gets.chomp.to_i

a = n / 3
b = n % 3
if b != 0 then
  puts a * 2 + 1
else
  puts a * 2
end

n = gets.to_i
cnt = (n / 3) * 2
res = n % 3
cnt += 1 if res >= 1
puts cnt

stones = gets.chomp.to_i

threes = (stones / 3).to_i

remaining = stones - (threes * 3)

count = threes * 2

count += 1 if remaining == 1

count = 1 if count == 0

puts count

n = gets.to_i
begin
  puts n%3 == 0 ? n/3 : n/3 + 1
rescue
end

#! ruby
# Try Codeforces
# author: Leonardone @ NEETSDKASU
############################################################
def gs() gets.chomp end
def gi() gets.to_i end
def gss() gs.split end
def gis() gss.map(&:to_i) end
def nmapf(n,f) n.times.map{ __send__ f } end
def ngs(n) nmapf n,:gs end
def ngi(n) nmapf n,:gi end
def ngss(n) nmapf n,:gss end
def ngis(n) nmapf n,:gis end
def arr2d(h,w,v=0) h.times.map{[v] * w} end
def for2p(hr,wr,&pr) hr.each{|i|wr.each{|j| yield(i,j)}} end
def nsum(n) n * (n + 1) / 2 end
def vcount(d,r=Hash.new(0)) d.inject(r){|r,e| r[e]+=1;r} end
############################################################

n = gi

if n < 3
    puts 1
    exit
end

=begin

n = 3
1 2

n = 4
1 2 1

n = 5
1 2 1

n = 6
1 2 1 2

n = 7
1 2 1 2 1

n = 8
1 2 1 2 1

n = 9
1 2 1 2 1 2

n = 10
1 2 1 2 1 2 1

a n
3 4 5
4 6
5 7 8
6 9
7 10 11
8 12

=end

if n % 3 == 0
    puts 2 * n / 3
else
    puts 2 * n / 3 + 1
end

n = readline.to_i
ct = n / 3
if n % 3 != 0
  ct += 1
end
puts ct


a=[]
4.times do
a << gets.chomp.split("")
end
ans=0
0.upto(2) do |i|
0.upto(2) do |j|
w=0
b=0
if a[i][j]=="#"
b+=1
else
w+=1
end
if a[i+1][j]=="#"
b+=1
else
w+=1
end
if a[i][j+1]=="#"
b+=1
else
w+=1
end
if a[i+1][j+1]=="#"
b+=1
else
w+=1
end
if w>2 || b>2
ans=1
end
break if ans==1
end
break if ans==1
end
if ans==1
puts "YES"
else
puts "NO"
end

res = "NO"
data = []

4.times do
    s = gets.split("")
    data << s
end

3.times do |i|
    if data[1][i] == data[1][i+1] then
        if data[0][i] == data[1][i] || data[0][i+1] == data[1][i] then
            res = "YES"
        end
        if data[2][i] == data[1][i] || data[2][i+1] == data[1][i] then
            res = "YES"
        end
    end
end

if res == "NO" then
    3.times do |i|
        if data[-1][i] == data[-1][i+1] then
            if data[2][i] == data[1][i] || data[2][i+1] == data[1][i] then
                res = "YES"
            end
        end
    end
end

puts res

s1 = gets.split("")
s2 = gets.split("")
s3 = gets.split("")
s4 = gets.split("")
s= s1.zip(s2,s3,s4)

yes=false
i=0
3.times do
  j=0
  3.times do
    count=0
    if s[i][j]=='#'
      count+=1
    end
    if s[i+1][j]=='#'
      count+=1
    end
    if s[i+1][j+1]=='#'
      count+=1
    end
    if s[i][j+1]=='#'
       count+=1
    end
    if count!=2
      yes=true
      break
    end
    j+=1
  end
  i+=1
end

if yes
  puts "YES"
else
  puts "NO"
end

matrix = []
4.times { matrix << gets.chomp.chars.to_a }

tiles = []
(0..2).each do |i|
  (0..2).each do |j|
    tiles << [matrix[i][j], matrix[i][j+1], matrix[i+1][j], matrix[i+1][j+1]]
  end
end

freq = tiles.map { |t| [t.count('.'), t.count('#')].max }

print freq.max >= 3 ? "YES" : "NO"

#!/usr/bin/ruby1.9

grid = []

4.times do
	grid.push(STDIN.readline.strip)
end

3.times do |r|
	3.times do |c|
		count = 0
		count += 1 if grid[r][c] == '.'
		count += 1 if grid[r+1][c] == '.'
		count += 1 if grid[r][c+1] == '.'
		count += 1 if grid[r+1][c+1] == '.'
		next if count == 2
		puts 'YES'
		exit
	end
end

puts 'NO'

def run
  ary = []
  $stdin.readlines.each do |line|
    ary << line.split(//)
  end

  3.times do |x|
    3.times do |y|
      if [ary[x][y], ary[x+1][y], ary[x][y+1], ary[x+1][y+1]].select {|x| x == '#'}.length != 2
        $stdout.puts "YES"
        return
      end
    end
  end
  $stdout.puts "NO"
end

run if $0 == __FILE__

class A
  def initialize
    @cells = []
    @list = [[1,1],[1,2],[2,1],[2,2]]
    @pos1 = [[-1,0],[-1,1],[0,1]]
    @pos2 = [[-1,0],[-1,-1],[0,-1]]
    @pos3 = [[0,-1],[1,-1],[1,0]]
    @pos4 = [[0,1],[1,1],[1,0]]
    4.times do
      @cells << $stdin.gets.chomp.split('')
    end

    check
    puts "NO"
  end

  def check
    flag = false
    @list.each do |elem|
      y = elem[0]
      x = elem[1]

      flag ||= right_up(y, x)
      flag ||= left_up(y, x)
      flag ||= left_up(y, x)
      flag ||= right_down(y, x)

      if flag
        puts "YES"
        exit
      end
    end
  end

  def right_up(ypos,xpos)
    white = 0
    black = 0
    if @cells[ypos][xpos] == "#"
      black += 1
    else
      white += 1
    end

    @pos1.each do |pos|
      y = pos[0]
      x = pos[1]

      if @cells[ypos+y][xpos+x] == "#"
        black += 1
      else
        white += 1
      end

    end
    if black >= 3 || white >= 3
      true
    else
      false
    end
  end

  def left_up(ypos,xpos)
    white = 0
    black = 0
    if @cells[ypos][xpos] == "#"
      black += 1
    else
      white += 1
    end

    @pos2.each do |pos|
      y = pos[0]
      x = pos[1]

      if @cells[ypos+y][xpos+x] == "#"
        black += 1
      else
        white += 1
      end

    end
    if black >= 3 || white >= 3
      true
    else
      false
    end
  end
  def left_down(ypos,xpos)
    white = 0
    black = 0
    if @cells[ypos][xpos] == "#"
      black += 1
    else
      white += 1
    end

    @pos3.each do |pos|
      y = pos[0]
      x = pos[1]

      if @cells[ypos+y][xpos+x] == "#"
        black += 1
      else
        white += 1
      end

    end
    if black >= 3 || white >= 3
      true
    else
      false
    end
  end

  def right_down(ypos,xpos)
    white = 0
    black = 0
    if @cells[ypos][xpos] == "#"
      black += 1
    else
      white += 1
    end

    @pos4.each do |pos|
      y = pos[0]
      x = pos[1]

      if @cells[ypos+y][xpos+x] == "#"
        black += 1
      else
        white += 1
      end
    end
    if black >= 3 || white >= 3
      true
    else
      false
    end
  end
end

a = A.new

A = [gets, gets, gets, gets]
def rr(t)
  if (t[0] == t[1] and t[1] == t[2] and t[2] == t[3]) then return true end
  t = t.chars.partition { |x| x == '.' }
  if t[0].length == 1 or t[0].length == 3 then return true end
  return false
end
def solve()
  i, j = 0, 0
  while i != 3
    if rr(A[i][j] + A[i][j+1] + A[i+1][j] + A[i+1][j+1]) then return "YES" end
    j = j+1
    if j == 3 then i, j = i+1, 0 end
  end
  return "NO"
end
puts solve()

a = 4.times.map { gets.chop }
3.times do |i|
  3.times do |j|
    if [a[i][j], a[i][j+1], a[i+1][j], a[i+1][j+1]].count('#') != 2
      puts 'YES'
      exit
    end
  end
end
puts 'NO'

lines = [""]*4
lines[0] = gets.chomp.split("")
lines[1] = gets.chomp.split("")
lines[2] = gets.chomp.split("")
lines[3] = gets.chomp.split("")

s = ""
t = ""
ok = false
(0..2).each {|l|
	(0..2).each {|c|
		s = "#{lines[l][c]}#{lines[l][c+1]}#{lines[l+1][c]}#{lines[l+1][c+1]}"
		t = s.gsub(".","")
		if t.length==4 or t.length==3 or t.length==1 or t.length==0
			ok=true
		end
	}
}

if ok
	puts "YES"
else
	puts "NO"
end

m = Array.new

4.times do
  m << gets.chomp
end

3.times do |y|
  3.times do |x|
    c = (m[y][x] + m[y+1][x] + m[y][x+1] + m[y+1][x+1]).delete(".").length
    unless c == 2
      puts 'YES'
      exit 0
    end
  end
end

puts 'NO'

A = [gets, gets, gets, gets]
def rr(t)
  t = t.chars.sort {|x,y| y <=> x}.join
  puts t
  if (t[0] == t[1] and t[1] == t[2] and t[2] == t[3]) then return true end
  if t[0] != t[1] then return true end
  return false
end
def solve()
  i, j = 0, 0
  while i != 3
    if rr(A[i][j] + A[i][j+1] + A[i+1][j] + A[i+1][j+1]) then return "YES" end
    j = j+1
    if j == 3 then i, j = i+1, 0 end
  end
  return "NO"
end
puts solve()

A = [gets, gets, gets, gets]
def rr(t)
  t = t.chars.sort {|x,y| y <=> x}.join
  if (t[0] == t[1] and t[1] == t[2] and t[2] == t[3]) then return true end
  if t[0] != t[1] then return true end
  return false
end
def solve()
  i, j = 0, 0
  while i != 3
    if rr(A[i][j] + A[i][j+1] + A[i+1][j] + A[i+1][j+1]) then return "YES" end
    j = j+1
    if j == 3 then i, j = i+1, 0 end
  end
  return "NO"
end
puts solve()

m = Array.new

4.times do
  m << gets.chomp
end

3.times do |y|
  3.times do |x|
    if (m[y][x] + m[y+1][x] + m[y][x+1] + m[y+1][x+1]).delete(".").length >= 3
      puts 'YES'
      exit 0
    end
  end
end

puts 'NO'


#!/usr/bin/env ruby

require 'prime'

n = gets.chop.to_i

m = 1
while m < 10**3 do
  result = m * n + 1
  break unless result.prime?
  m += 1
end

puts m

n = gets.chomp.to_i
case n
when 1
    puts 3
when 2
    puts 4
else
    puts (n - 2)
end

n = gets.to_i
puts n <= 2 ? n + 2 : n - 2

def prime(n)
	return false if n == 0 || n == 1

	i = 2
	while i * i <= n
		return false if n % i == 0
		i += 1
	end

	return true
end

def main
	n = gets.to_i

	for m in (1..1000)
		if not prime(n * m + 1)
			puts m
			break
		end
	end
end

main

require 'prime'
n = gets.strip.to_i
ans = 1
if n > 2
    (1..n).each do |i|
        if !Prime.prime?(n * i + 1)
            ans = i
            break
        end
    end
else
    ans = n + 2
end
puts ans

require 'prime'
n=gets.to_i
m=1
while Prime.prime?(n*m+1)
	m+=1
end
puts m

require 'prime'
n= gets.to_i

for i in 1..1000
  if !(Prime.prime?((i*n) + 1))
    print i
    break
  end
end

require 'prime'
n=gets.to_i
for m in 1..999
    unless (n*m+1).prime?
        p m
        break
    end
end

require 'prime'
N = gets.to_i
(1..1000).each { |i| next if Prime.prime? N * i + 1
   p i
   exit
}

require'prime'
N=gets.to_i
p (1..1000).find{|i|!Prime.prime?N*i+1}

n=gets.chomp.to_i
def is_prime(a)
    i=2
    while i*i<=a do
        return 0 if a % i == 0
        #ruby不支持++运算！
        i += 1
    end
    return 1
end
i=1
while true do
    #print "#{i} "
    #puts i*n+1
    #if i==5 break end
    #get_character
    #puts is_prime(i*n+1)

    if is_prime(i*n+1) == 1
        i+=1
    else
        puts i
        break
    end
end

def prime(n)
	return false if n == 0 || n == 1

	i = 2
	while i * i <= n
		return false if n % i == 0
		i += 1
	end

	return true
end

def main
	n = gets.to_i

	for m in (1..1000)
		if prime(n * m + 1)
			puts m
			break
		end
	end
end

main

require 'prime'

n = gets.strip.to_i
ans = 0
(1..n).each do |i|
    if !Prime.prime?(n * i + 1)
        ans = i
        break
    end
end
puts ans

require 'prime'

n = gets.strip.to_i
ans = 1
(1..n).each do |i|
    if !Prime.prime?(n * i + 1)
        ans = i
        break
    end
end
puts ans

require 'prime'
N = gets.to_i
(1..1000).each { |i| next if Prime.prime? N * i + 1
  at_exit { p i }
}

n=gets.chomp.to_i
def is_prime(a)
    i=2
    while i*i<=a do
        return 0 if a % i == 0
        #ruby不支持++运算！
        i += 1
    end
    return 1
end
i=1
while true do
    #print "#{i} "
    #puts i*n+1
    if i==5
        break
    end
    #get_character
    #puts is_prime(i*n+1)

    if is_prime(i*n+1) == 1
        i+=1
    else
        puts i
        break
    end
end


n = gets.chomp.to_i

puts "O-|-OOOO" if n == 0
while n != 0 do
  i = n%10
  row = ""
  if i < 5
    row += "O-|"
  else
    i = i - 5
    row +=  "-O|"
  end
  case i
  when 0
    row += "-OOOO"
  when 1
    row += "O-OOO"
  when 2
    row += "OO-OO"
  when 3
    row += "OOO-O"
  when 4
    row += "OOOO-"
  end
  puts row
  n = n/10
end

n = gets.chomp
rep = {0 => 'O-|-OOOO',
 1 => 'O-|O-OOO',
 2 => 'O-|OO-OO',
 3 => 'O-|OOO-O',
 4 => 'O-|OOOO-',
 5 => '-O|-OOOO',
 6 => '-O|O-OOO',
 7 => '-O|OO-OO',
 8 => '-O|OOO-O',
 9 => '-O|OOOO-'
}

arr = []
n.each_char do |c|
	arr << rep[c.to_i]
end
arr.reverse!
arr.each do |a|
	puts a
end

def rod(d)
    if d < 5
        print "O-"
    else
        print "-O"
        d -= 5
    end
    print "|"
    remain = 4-d
    while d > 0
        print "O"
        d -= 1
    end
    print "-"
    while remain > 0
        print "O"
        remain -= 1
    end
    puts ""
end

gets.strip.reverse.each_char do |c|
    d = c.to_i
    rod(d)
end

gets.chomp.split('').map { |x| x.to_i }.reverse.each { |x|
  left = x < 5 ? 'O-' : '-O'
  m = x % 5
  right = 'O' * m + '-' + 'O' * (4 - m)
  puts left + '|' + right
}

n = gets.chomp.to_i

def draw(i)
  str = ""
  if i >= 5
    str = "-O|"
  else
    str = "O-|"
  end

  (i % 5).times do
    str += "O"
  end

  str += "-"
  (4 - (i % 5)).times do
    str += "O"
  end
  puts str
end

if n == 0
  draw(n)
end

while n != 0
  draw(n % 10)
  n /= 10
end

String.class_eval do
  ROD = %w[
    O-|-OOOO O-|O-OOO O-|OO-OO O-|OOO-O O-|OOOO-
    -O|-OOOO -O|O-OOO -O|OO-OO -O|OOO-O -O|OOOO-
  ]
  def soroban
    self.each_char{|s|puts ROD[s.to_i]}
  end
end

gets.chop.reverse.soroban

#!/usr/bin/ruby
T=[
	'O-|-OOOO',
	'O-|O-OOO',
	'O-|OO-OO',
	'O-|OOO-O',
	'O-|OOOO-',
	'-O|-OOOO',
	'-O|O-OOO',
	'-O|OO-OO',
	'-O|OOO-O',
	'-O|OOOO-',
]
gets.chomp.reverse.chars{|e|puts T[e.to_i]}

str = gets.chomp
str.reverse.split(//).each do |c|
  if c.to_i >= 5
    print "-O|"
  else
    print "O-|"
  end
  tmp = (c.to_i - 5 < 0 ? c.to_i : c.to_i - 5)
  case tmp
  when 0 then
    puts "-OOOO"
  when 1 then
    puts "O-OOO"
  when 2 then
    puts "OO-OO"
  when 3 then
    puts "OOO-O"
  when 4 then
    puts "OOOO-"
  else
    puts "-OOOO"
  end
end

n = gets.chomp.to_i
digits = ["O-|-OOOO", "O-|O-OOO", "O-|OO-OO", "O-|OOO-O", "O-|OOOO-", "-O|-OOOO", "-O|O-OOO",
            "-O|OO-OO", "-O|OOO-O", "-O|OOOO-"]
ans = []
if n == 0
    puts digits[0]
else
    while n > 0
        last = n % 10
        ans << digits[last]
        n -= last
        n /= 10
    end
    ans.each do |a|
        puts a
    end
end

# encoding: utf-8

str = gets.chomp
str.reverse.split(//).each do |c|
  if c.to_i >= 5
    print "-0|"
  else
    print "0-|"
  end
  tmp = (c.to_i - 5 < 0 ? c.to_i : c.to_i - 5)
  case tmp
  when 0 then
    puts "-0000"
  when 1 then
    puts "0-000"
  when 2 then
    puts "00-00"
  when 3 then
    puts "000-0"
  when 4 then
    puts "0000-"
  else
    puts "-0000"
  end
end

n = gets.chomp.to_i
digits = ["O-|-OOOO", "O-|O-OOO", "O-|OO-OO", "O-|OOO-O", "O-|OOOO-", "-O|-OOOO", "-O|O-OOO",
            "-O|OO-OO", "-O|OOO-O", "-O|OOOO-"]
ans = []
while n > 0
    last = n % 10
    ans << digits[last]
    n -= last
    n /= 10
end
ans.each do |a|
    puts a
end

n = gets.chomp.to_i
while n != 0 do
  i = n%10
  row = ""
  if i < 5
    row += "O-|"
  else
    i = i - 5
    row +=  "-O|"
  end
  case i
  when 0
    row += "-OOOO"
  when 1
    row += "O-OOO"
  when 2
    row += "OO-OO"
  when 3
    row += "OOO-O"
  when 4
    row += "OOOO-"
  end
  puts row
  n = n/10
end

gets.chomp.split('').map { |x| x.to_i }.reverse.each { |x|
  left = x < 5 ? '0-' : '-0'
  m = x % 5
  right = '0' * m + '-' + '0' * (4 - m)
  puts left + '|' + right
}

n = gets.chomp.to_i

def draw(i)
  str = ""
  if i >= 5
    str = "-0|"
  else
    str = "0-|"
  end

  (i % 5).times do
    str += "0"
  end

  str += "-"
  (4 - (i % 5)).times do
    str += "0"
  end
  puts str
end

while n != 0
  draw(n % 10)
  n /= 10
end

n = gets.chomp.to_i

def draw(i)
  str = ""
  if i >= 5
    str = "-O|"
  else
    str = "O-|"
  end

  (i % 5).times do
    str += "O"
  end

  str += "-"
  (4 - (i % 5)).times do
    str += "O"
  end
  puts str
end

while n != 0
  draw(n % 10)
  n /= 10
end


require 'openssl'
n,m,k=gets.split.map(&:to_i)
d=10**9+9
p=n/k
q=m-n+p
if q<=0
  puts m
  exit
end
r=2.to_bn.mod_exp(q+1,d).to_i
r=((d+r-2)%d*k+m-q*k)%d
p r

require 'openssl'
MOD = 10 ** 9 + 9
n, m, k = gets.chop.split.map(&:to_i)
extra = n - m
if(extra * k >= n)
    print m % MOD
else
    st = n - extra * k
    cnt = st / k
    rest = st % k
    total = ((2.to_bn.mod_exp(cnt + 1,MOD) - 2 + MOD) % MOD * k + rest + extra *(k - 1)) % MOD
    print total
end

MOD = 10 ** 9 + 9
def pow2(x)
    st = 1
    pow = 2
    while(x != 0)
        if((x & 1) != 0)
            st = (st * pow) % MOD
        end
        pow = (pow * pow) % MOD
        x >>= 1
    end
    return st
end
n, m, k = gets.chop.split.map(&:to_i)
extra = n - m
if(extra * k >= n)
    print m % MOD
else
    st = n - extra * k
    cnt = st / k
    rest = st % k
    total = pow2(cnt + 1)
    total = (total - 2 + MOD) % MOD
    total = (total * k + rest) % MOD
    total += extra * (k - 1)
    total %= MOD
    print total
end

module  STL
  module Algorithm
    def power_mod(a, b, c) #compute (a ^ b) mod c
      ans, tich = 1, a
      while b > 0
        ans = (ans * tich) % c if b % 2 == 1
        tich = (tich * tich) % c
        b /= 2
      end
      ans
    end
  end
end

include STL::Algorithm
MOD = 1000_000_009
def solve(f)
  n, m, k = f.gets.split.map(&:to_i)
  t = (n / k) * (k - 1) + n % k
  if m <= t
    puts m
  else
    a = m - t

    tmp = power_mod(2, (a + 1), MOD)
    puts (k * (tmp - 2) + m - a * k) % MOD
  end
end

def debug
  (1..3).each do |e|
    f = File.new("test#{e}.txt", 'r')
    solve f
    f.close
  end
end

def release
  solve STDIN
end

release

require 'openssl'

n, m, k = gets.chomp.split(' ').map(&:to_i)
d = 1000000009
x = [0, m - (n - n % k) / k * (k-1) - n % k].max

r = 2.to_bn.mod_exp(x+1, d)
r = (r-2)*k % d
r = (r + (m-x*k)) % d

while r < 0
	r += d
end

puts r

require 'openssl'

n, m, k = gets.chomp.split(' ').map(&:to_i)
d = 1000000009
x = [0, m - (n - n % k) / k * (k-1) - n % k].max
puts x

r = 2.to_bn.mod_exp(x+1, d)
r = (r-2)*k % d
r = (r + (m-x*k)) % d

while r < 0
	r += d
end

puts r

require 'openssl'

n, m, k = gets.chomp.split(' ').map(&:to_i)
d = 1000000009
x = [0, m - (n - n % k) / k * (k-1) - n % k].max
#puts x

r = 2.to_bn.mod_exp(x+1, d)
r = (r-2)*k % d
r = (r + (m-x*k)) % d

puts r

MOD = 10 ** 9 + 9
n, m, k = gets.chop.split.map(&:to_i)
extra = n - m
total = 0
if(extra * k >= n)
	print m % mod
else
	st = n - extra * k
	1.upto(st) do |i|
		total += 1
		if(i % k == 0)
			total *= 2
		end
	end
	total += extra * (k - 1)
	print total
end

MOD = 10 ** 9 + 9
def pow2(x)
    st = 1
    pow = 2
    while(x != 0)
        if(x & 1)
            st = (st * pow) % MOD
        end
        pow = (pow * pow) % MOD
        x >>= 1
    end
    return st
end
n, m, k = gets.chop.split.map(&:to_i)
extra = n - m
if(extra * k >= n)
    print m % MOD
else
    st = n - extra * k
    cnt = st / k
    rest = st % k
    total = pow2(cnt)
    total = (total - 2 + MOD) % MOD
    total = (total * k + rest) % MOD
    total += extra * (k - 1)
    total %= MOD
    print total
end

MOD = 10 ** 9 + 9
n, m, k = gets.chop.split.map(&:to_i)
extra = n - m
if(extra * k >= n)
    print m % MOD
else
    st = n - extra * k
    cnt = st / k
    rest = st % k
    total = (2 ** (cnt + 1) - 2) * k + rest
    total += extra * (k - 1)
    total %= MOD
    print total
end

require 'openssl'
n,m,k=gets.split.map(&:to_i)
d=10^9+9
p=n/k
q=m-n+p
if q<=0
  puts m
  exit
end
r=2.to_bn.mod_exp(q+1,d)
r=((r-2)%d*k%d+m-q*k)%d
p r

require 'openssl'
n,m,k=gets.split.map(&:to_i)
d=10^9+9
p=n/k
q=m-n+p
if q<=0
  puts m
  exit
end
r=2.to_bn.mod_exp(q+1,d).to_i
r=((d+r-2)%d*k+m-q*k)%d
p r

require 'openssl'
n,m,k=gets.split.map(&:to_i)
d=10^9+9
p=n/k
q=m-n+p
if q<=0
  puts m
  exit
end
r=2.to_bn.mod_exp(q+1,d).to_i
r=((r-2)%d*k+m-q*k)%d
p r

module Containers
  class Stack

  end
end

module Algorithm
  def pow_mod(a, b, c) #compute (a ^ b) mod c
    ans, tich = 1, a
    while b > 0
      ans = (ans * tich) % c if b % 2 == 1
      tich = (tich * tich) % c
      b /= 2
    end
    ans
  end
end

def solve
  n, m, k = gets.split.map(&:to_i)
  t = (n / k) * (k - 1) + n % k
  if m <= t
    puts m
  else
    a = m - t
    puts k * ((1 << (a + 1)) - 2) + m - a * k
  end
end

solve


n,a,b,c = (gets+gets+gets+gets).split.map(&:to_i)

if n==1
    p 0;exit
end
len = 0

x = [a,b].min
len += x
n-=2

if n > 0
    len += [x,c].min*n
end

p len

#! /usr/bin/env ruby

n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i

n -= 1

ans = 0

if n > 0
    ans += [a, b].min
    n -= 1
end

ans += [a, b, c].min * n
n -= n

puts ans

n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
n -= 1
x = [a, b, c].min
tot = 0
if n >= 1
  tot += [a, b].min
  tot += (n - 1) * x
end
puts tot

n = gets.strip.to_i
a = gets.strip.to_i
b = gets.strip.to_i
c = gets.strip.to_i
curr = 1
ans = 0
if n > 1
    i = 1
    while i < n
        dist = 0
        case curr
        when 1
            if a <= b
                dist = a
                curr = 2
            else
                dist = b
                curr = 3
            end
        when 2
            if a <= c
                dist = a
                curr = 1
            else
                dist = c
                curr = 2
            end
        when 3
            if c <= b
                dist = c
                curr = 2
            else
                dist = b
                curr = 1
            end
        end
        ans += dist
        i += 1
    end
end
puts ans

n = gets.strip.to_i
a = gets.strip.to_i
b = gets.strip.to_i
c = gets.strip.to_i
curr = 1
ans = 0
if n > 1
    i = 1
    while i < n
        dist = 0
        if curr.odd?
            dist = [a, b].min
            curr = 2
        else
            dist = [a, b, c].min
            curr = 1
        end
        ans += dist
        i += 1
    end
end
puts ans

n,a,b,c = (gets+gets+gets+gets).split.map(&:to_i)

if n==1
    p 0
end
len = 0

x = [a,b].min
len += x
n-=2

if n > 0
    len += [x,c].min*n
end

p len

#! /usr/bin/env ruby

n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i

n -= 1

ans = 0

ans += [a, b].min
n -= 1

ans += [a, b, c].min * n
n -= n

puts ans

n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
n -= 1
x = [0, a, b, c].sort
tot = (n / 3) * (a + b + c)
for i in 1 .. 3
  x[i] += x[i - 1]
end
tot += x[n % 3]
puts tot

n = gets.to_i
a = gets.to_i
b = gets.to_i
c = gets.to_i
x = [a, b, c].min
tot = (n - 1) * x
puts tot


def run
  n = $stdin.gets.to_i
  a = $stdin.gets.split.map(&:to_i)
  max = a.delete_at(a.index(a.max))
  min = a.delete_at(a.index(a.min))

  puts ([max] + a.sort + [min]).join(" ")
end

run if $0 == __FILE__

n = gets.to_i
array = gets.chomp!.split(' ').map(&:to_i).sort
array[0], array[-1] = array[-1], array[0]
puts array.join(' ')

class A
  def initialize
    n = gets.chomp.to_i
    num_list = gets.chomp.split(' ').map(&:to_i)
    max_num = num_list.max
    min_num = num_list.min
    num_list.delete_at(num_list.find_index(max_num))
    num_list.delete_at(num_list.find_index(min_num))

    answer = [max_num] + num_list.sort + [min_num]

    puts answer.join(' ')
  end
end

a = A.new


MOD=10**9+7
cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def desc(ar) ar.sort{|x,y|y<=>x} end##
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+) end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end

def puts_yesno(can) puts(can ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def debug(k,v) puts "#{k}:#{v}" end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,k=gsmi
s=gs
l0=s.length

cnt=0
l=l0
k-=1
prev=[s]
while k>0 do
  ar=[]
  prev.each do |pr|
    l.times do |i|
      st=pr[0,i]+pr[(i+1)..-1]
      ar<<st
    end
  end
  ar.uniq!
  if k<=ar.size
    cnt+=k*(l0-(l-1))
    break
  end
  cnt+=ar.size*(l0-(l-1))
  k-=ar.size
  l-=1
  prev=ar
  putsend -1 if l==0&&k>=1
end

puts cnt


5.times do |i|
    j = gets.split.index("1")
    if j
        puts (2 - i).abs + (2 - j).abs
        break
    end
end

5.times do|i|
j=gets.split.index(?1)and puts (i-2).abs+(j-2).abs
end

for i in 1..5
	str = gets.chomp
	if str.include? "1"
		y = i
		x = (((" " + str).index "1") + 1) / 2
	end
end
puts (x - 3).abs + (y - 3).abs

arr = []
x = nil
y = nil

5.times do |tx|
  arr << gets.chomp.split(' ')
  y ||= arr.last.index '1'
  (x ||= tx) if y
end

puts (x-2).abs + (y-2).abs

1.upto(5) { |i| gets.chomp.split.each_with_index { |x,j| puts (i-3).abs + (j-2).abs if x == '1'} }

$<.each_with_index{|x,r|c=x.split.index('1');(puts (r-2).abs+(c-2).abs; break) if c}

ar = []
5.times do
  ar << gets.split(' ').map(&:to_i)
end
row = ar.map{|x| x.inject(:+)}.index(1)
col = ar[row].index(1)
puts (row-2).abs+(col-2).abs

def abs(x)
    if x < 0 then
        return -x
    else
        return x
    end
end

n = 0
m = 0
matrix = []
5.times do |i|
    matrix[i] = gets.split
    if q = matrix[i].index("1") then
        n = i + 1
        m = q + 1
    end
end

result = abs(n-3) + abs(m-3)
puts result

5.times do |i|
  j = gets.split.index(?1)
  puts (i-2).abs + (j-2).abs if j
end

matrix = [] ; 5.times{ matrix << gets.chomp.split(" ").map(&:to_i) }
matrix.each_with_index do |line, i|
  if line.include?(1)
    count_heigth = (3 - (i+1)).abs
    line.each_with_index do |element, index|
      if element == 1
        count_element = (3 - (index+1)).abs
        puts count_heigth + count_element
      end
    end
  end
end

def read_tokens
  return gets.chomp.to_s.strip.split(' ')
end

def read_ints
  data = []
  read_tokens.each { |s|
    data.push(s.to_i)
  }
  return data
end

r_1, c_1 = 0, 0
(0...5).each { |r|
  row = read_ints
  c = row.find_index(1)
  if c != nil
    r_1, c_1 = r, c
  end
}

def solve(row, col)
  dest_r, dest_c = 2, 2
  return (dest_r - row).abs + (dest_c - col).abs
end

print(solve(r_1, c_1))

f = false
m = 0
0.upto 4 do |t|
	if !f
		a = gets.chomp.split(" ")
		if a.include? "1"
			m += (2 - t).abs
			m += (2 - a.index("1")).abs
			f = true
		end
	else
		gets
	end
end
puts m

a=Array.new
s=1
5.times do
j=0
a=gets.split.map(&:to_i)
for i in 0..4 do
if a[i]==1 then
puts (s-3).abs+(i+1-3).abs
j=1
end
end
break if j== 1
s+=1
end

r1 = gets.chomp
row1 = r1.split(" ")
r2 = gets.chomp
row2 = r2.split(" ")
r3 = gets.chomp
row3 = r3.split(" ")
r4 = gets.chomp
row4 = r4.split(" ")
r5 = gets.chomp
row5 = r5.split(" ")

spaces = 0
if row1.include? "1"
	if row1[2] == "1"
		spaces = 0
	elsif row1[0] == "1" || row1[4] == "1"
		spaces += 2
	else
		spaces += 1
	end
	spaces += 2
elsif row2.include? "1"
	if row2[2] == "1"
		spaces = 0
	elsif row2[0] == "1" || row2[4] == "1"
		spaces += 2
	else
		spaces += 1
	end
	spaces += 1
elsif row3.include? "1"
	if row3[2] == "1"
		spaces = 0
	elsif row3[0] == "1" || row3[4] == "1"
		spaces += 2
	else
		spaces += 1
	end
elsif row4.include? "1"
	if row4[2] == "1"
		spaces = 0
	elsif row4[0] == "1" || row4[4] == "1"
		spaces += 2
	else
		spaces += 1
	end
	spaces += 1
else
	if row5[2] == "1"
		spaces = 0
	elsif row5[0] == "1" || row5[4] == "1"
		spaces += 2
	else
		spaces += 1
	end
	spaces += 2
end

puts spaces

mat = []
5.times{
	mat << STDIN.readline.split
}

(0..4).each{|i|
	(0..4).each{|j|
		if mat[i][j] == '1'
			p (i-2).abs+(j-2).abs
		end
	}
}

arr = []
i = 0
j = 0
5.times {
  arr.push(gets.split(" ").map(&:to_i))
}
arr.each_with_index do |row,i_ind|
  val = row.index(1)
  i = i_ind and j = val if val
end
puts (i - 2).abs + (2 - j ).abs

(1..5).each do |i|
  m = gets.split(/\s+/).map(&:to_i)
  i_th = m.index(1)
  unless i_th.nil?
    movements = (3-(i_th+1)).abs + (3-i).abs
    puts movements
    break
  end
end

m = 0
n = 0
for i in 0...5
    x = gets.split.map(&:to_i)
    for j in 0...5
        if x[j]==1
            m = j
            n = i
            break
        end
    end

end

puts (n-2).abs + (m-2).abs

#!/usr/bin/ruby1.9

5.times do |r|
	row = STDIN.readline.split
	5.times do |c|
		if row[c] == '1'
			puts ((r-2).abs+(c-2).abs)
			exit
		end
	end
end

x = 0
y = 0
(0...5).each do |i|
  a = []
  a = gets.split.map &:to_i
  (0...5).each do |j|
    if a[j] == 1
      x = i + 1
      y = j + 1
    end
  end
end

puts (3 - x).abs + (3 - y).abs

5.times { |row|
  c = gets.chomp.gsub(" ", "").index("1")
  puts (2-row).abs + (2-c).abs if c
}

matrix = []
5.times do
  row_string = gets.strip
  row = row_string.split(' ').map(&:to_i)
  matrix.push(row)
end

row = nil
column = nil
5.times do |row_index|
  5.times do |column_index|
    next unless matrix[row_index][column_index].eql?(1)

    row = row_index
    column = column_index
    break
  end
end

diff_row = (row - 2).abs
diff_column = (column - 2).abs
result = diff_row + diff_column
puts result

a=[]
i=0
x=0
y=0
5.times do
	row=gets.chomp.split(' ')
	#print row
	#puts
	row.each_index do |char|
		#puts row[char]
		if row[char]=='1'
			x=i
			y=char
		end
	end
	a.push(row)
	i+=1
end
#puts '('+x.to_s+','+y.to_s+')'
puts (x-2).abs+(y-2).abs

# https://codeforces.com/problemset/problem/263/A
0.upto(4) do |i|
  line = gets.chomp
  chars = line.split(' ')
  chars.each_with_index do |c, j|
    if c == '1'
      p (2 - i).abs + (2 - j).abs
    end
  end
end

l = []
(1..5).each { l << gets.split.map(&:to_i) }

x = 0
y = 0

l.each_with_index { |i, in1|
	i.each_with_index { |j, in2|
			if j == 1
				x = in2
				y = in1
				break
			end
		}
	}

puts (x - 2).abs + (y - 2).abs

coco = 0
moco = 0
5.times do |x|
    a = gets.split.map(&:to_i)
    if a.include? 1
        coco = x
        moco = a.index(1)
    end
end

puts (coco - 2).abs + (moco - 2).abs

i = 1
row_num = 0
output = 0
while i <= 5
  input_row = gets.chomp.split
  if input_row.include?("1") then
    input_row = input_row.map{|i| i.to_i}
    colum_num = input_row.index{|i| i == 1}
    row_num = i
    colum_num = colum_num +1
  end
  i = i+1
end
if 3 > row_num then
  output = 3 - row_num
elsif 3 < row_num then
    output = row_num -3
end
if 3 > colum_num then
  output = 3 - colum_num + output
elsif 3 < colum_num then
  output = colum_num - 3 + output
end
print output

line1 = gets.chomp.split(" ")
line2 = gets.chomp.split(" ")
line3 = gets.chomp.split(" ")
line4 = gets.chomp.split(" ")
line5 = gets.chomp.split(" ")

i = 0
j = 0
if line1.index("1")
	j = line1.index("1")
	i = 0
end

if line2.index("1")
	j = line2.index("1")
	i = 1
end

if line3.index("1")
	j = line3.index("1")
	i = 2
end

if line4.index("1")
	j = line4.index("1")
	i = 3
end

if line5.index("1")
	j = line5.index("1")
	i = 4
end

puts "#{(i-2).abs+(j-2).abs}"

i,j = nil, nil
(0..4).each do |k|
    a = $stdin.readline.split.map(&:to_i)
    t = a.find_index(1)
    if !t.nil?
        i,j=k,t
    end
end

di = (2-i).abs
dj = (2-j).abs

puts di+dj

a = Array.new(5, Array.new(5))
ii, jj = 0, 0;
for i in 0...5
  a[i] = gets.split(" ").map(&:to_i)
  for j in 0...5
    if a[i][j] == 1
      ii ,jj = i, j;
    end
  end
end
puts (ii - 2).abs + (jj  - 2).abs

def run
  ARGF.readlines.each_with_index do |line, i|
    line.chomp.split(" ").each_with_index do |c, j|
      if c == "1"
        puts (i - 2).abs + (j - 2).abs
        return
      end
    end
  end
end

run if $0 == __FILE__

# cook your code here
arr = Array.new(5,Array.new(5))
one_row =0
one_col=0
(0..4).each do |row|
    val = gets.split(" ").map(&:to_i)
    (0..4).each do |col|
        arr[row][col] = val[col]
        if val[col] == 1
            one_row = row
            one_col = col
        end
    end
end
puts (one_row - 2).abs  + (one_col-2).abs

inp = Array.new
5.times do
  inp << gets.chomp
end
inp.each do |str|
  if str =~ /^.*1.*$/
    str.scan(/1/) { |ch| puts (inp.index(str) - 2).abs + (str.delete(" ").index(ch) - 2).abs }
  end
end

#!/usr/bin/env ruby -w

v = (1..5).map do
  gets.split(/\s+/).map(&:to_i)
end

found = false
(0..4).each do |i|
  break if found
  (0..4).each do |j|
    if v[i][j] == 1
      puts (i - 2).abs + (j - 2).abs
      found = true
      break
    end
  end
end

grids = []
one_id = nil
5.times do |i|
  line = gets.split.map(&:to_i)
  one_id = line.index(1)
  if one_id
    puts (i - 2).abs + (one_id - 2).abs
  end
end

def check (n,r)
	if n.include?(1)
		puts (3-r).abs + (3-(n.index(1)+1)).abs
	end
end

x = []
x = gets.split.map(&:to_i)

y = []
y = gets.split.map(&:to_i)

z = []
z = gets.split.map(&:to_i)

a = []
a = gets.split.map(&:to_i)

b = []
b = gets.split.map(&:to_i)

check(x,1)
check(y,2)
check(z,3)
check(a,4)
check(b,5)

arr_input = []
i, j = -1
5.times do |n|
 	arr = gets.chomp
 	arr_input << arr
end

arr_input.each.with_index do |row, index|
	row.split(' ').each.with_index do |col, idx|
		if col.to_i == 1
			i = index
			j = idx
		end
	end
end
min_distance = (2 - i).abs + (2 - j).abs

puts min_distance

arr_input = []
i, j = -1
5.times do |n|
 	arr = gets.chomp
 	arr_input << arr
 	arr.split(' ').each.with_index do |col, idx|
		if col.to_i == 1
			i = n
			j = idx
		end
	end
end
min_distance = (2 - i).abs + (2 - j).abs

puts min_distance

5.times do |i|
    a = gets.split.map(&:to_i)
    5.times do |j|
        if a[j] == 1
            puts (2 - i).abs() + (2 - j).abs()
            exit 0
        end
    end
end

#!/usr/bin/env ruby

5.times do |i|
	gets.split.each_with_index do |v, j|
		if v == "1"
			puts (i - 2).abs + (j - 2).abs
			exit 0
		end
	end
end

n = 0
5.times.each_with_index do |row, ind|
  line = gets.chomp.match(/1/)
  if line
    n = (ind - 2).abs + (line.begin(0) / 2 - 2).abs
  end
end
puts n

include Math
BEGIN{
	def gint()
		return gets.split.map(&:to_i)
	end
	def main()
		a = []
		x = y = 0
		5.times do |i|
			a[i] = gint
			a[i].each_with_index do |ta,w|
				if ta == 1 then
					x, y = i, w
				end
			end
		end
		puts (x-2).abs + (y-2).abs
	end
	Test_case = 1
	Test_case.times do
		main()
	end
}

line = 0
pos = 0
while true
  line += 1
  pos = gets.split.map(&:to_i).index(1)
  if pos != nil
    break
  end
end
pos += 1
puts (3-line).abs + (3-pos).abs

_2d = []
5.times{ _2d = _2d + [gets.chomp.split.map(&:to_i)]}
for i in (0...5) do
  for j in (0...5) do
    unless _2d[i][j].zero?
      puts (3-(i+1)).abs + (3-(j+1)).abs
    end
  end
end

t = 5

t.times do |i|
	s = gets.split.collect{|x| x.to_i}

	s.each_index{|j|
		if s[j] == 1
			puts (i-2).abs + (j-2).abs
		end
	}
end

x=nil
y=nil

5.times do |i|
  a=gets.split.map{|e|e.to_i}
  n=a.index 1
  if n
    x=n
    y=i
    break
  end
end

puts (2-x).abs+(2-y).abs

matrix = []
row, column = 0, 0

(0...5).each do |iterNum|
	matrix << gets.chomp.split(' ').map {|item| item.to_i}
	row, column = iterNum, matrix[iterNum].index(1) unless matrix[iterNum].index(1).nil?
end

puts (2 - row).abs + (2 - column).abs

matrix = []
pos_one = [-1, -1]
beautiful_pos = [3, 3]
(1..5).each do |index|
    row = gets.chomp.split(/ /).map(&:to_i)
    matrix << row
    pos_one = [index, row.index( 1 ) + 1] if row.include? 1
end
puts (pos_one[0] - beautiful_pos[0]).abs + (pos_one[1] - beautiful_pos[1]).abs

# http://codeforces.com/problemset/problem/263/A

rows = []

one_row_index = -1
one_col_index = -1

5.times do |t|
  row = gets.chomp.split
  if row.include? "1"
    one_row_index = t
    one_col_index = row.find_index("1")
  end
  rows << row
end

puts "#{(2 - one_row_index).abs + (2 - one_col_index).abs}"

runner = 0
height = 0
width = 0
while line = gets.to_s.strip do
  break if line == ''
  columns = line.split(' ')
  if columns.include? '1'
    width = columns.index '1'
    height = runner
  end
  runner += 1
end

needed_height = 2
needed_width = 2

puts (needed_width - width).abs + (needed_height - height).abs

n = Array.new
for i in 0...5
    n[i] = Array.new
end
for i in 0...5
    input = gets.chomp
    for j in 0...5
        nums = input.split
        n[i][j] = Integer(nums[j])
    end
end

a = 0
b = 0
for i in 0...5
    for j in 0...5
        if n[i][j] == 1
            a = i
            b = j
        end
    end
end

if a >= 2 && b >= 2
    puts a - 2 + b - 2
elsif a < 2 && b >= 2
    puts 2 - a + b - 2
elsif a < 2 && b < 2
    puts 2 - a + 2 - b
else  a >= 2 && b < 2
    puts  a - 2 + 2 - b
end

5.times do |i|
  j=gets.split.find_index(?1)
  puts (i-2).abs+(j-2).abs if j
end

5.times {|i|
  j=gets.split.index(?1)
  puts (i-2).abs+(j-2).abs if j
}

r=0
c=0
1.upto(5) do |i|
a=gets.chomp
if a.count("1")==1
r=i
a.each_char do |k|
if k=="0" || k=="1"
c+=1
end
break if k== "1"
end
end
end
ans= (r-3).abs+(c-3).abs

puts "#{ans}"

a = Array.new(5)
5.times do |i|
  a[i] = gets.split.map(&:to_i)
end
xi = 0
xj = 0
5.times do |i|
  5.times do |j|
    if a[i][j] == 1
      xi = i + 1
      xj = j + 1
      break
    end
  end
end
puts (xi - 3).abs + (xj - 3).abs

total = 0
5.times{|i|
	j = gets.split(' ').index(?1)
	puts (i-2).abs + (j-2).abs if j
}

x, y = 0, 0
5.times do |i|
  a = gets.split(" ").map{|x| x.to_i}
  x, y  = i, a.index(1) if a.include?(1)
end
puts (2 - x).abs + (2 - y).abs

# -*- encoding: utf-8 -*-

x, y = 0, 0

for i in 0 .. 4 do
  cols = gets.chomp.split(" ").map{|n| n.to_i}

  for j in 0 .. 4 do
    if cols[j] == 1
      x = j
      y = i
      break
    end
  end
end
puts (2 - x).abs + (2 - y).abs

require 'set'
include Math
$stdin = File.open("./input.txt", "r") if ENV["USER"] == "new"
# ====================================

matrix = []
5.times do
  matrix << gets.strip.split.map(&:to_i)
end

x, y = 0, 0
catch (:done) do
  for i in 0...5 do
    for j in 0...5 do
      if matrix[i][j] == 1
        x, y = i, j
        throw :done
      end
    end
  end
end

moves = (x - 2).abs + (y - 2).abs
puts moves

l = []
(1..5).each { l << gets.split.map(&:to_i) }

x = 0
y = 0

l.each_with_index { |i, in1|
	i.each_with_index { |j, in2|
			if j == 1
				x = in2
				y = in1
				break
			end
		}
	}

puts (x - 3).abs + (y - 3).abs

_2d = []
5.times{ _2d = _2d + gets.chomp.split.map(&:to_i)}
_2d.each_with_index{|x, index| puts ((index+1)-13).abs unless x.zero?}

5.times do |i|
  j = gets.split.find_index(1)
  puts (i-2).abs + (j-2).abs if j
end

x = 0
y = 0
(0...5).each do |i|
  a = []
  a = gets.split.map &:to_i
  (0...5).each do |j|
    if a[j] == 1
      x = i
      y = j
    end
  end
end
puts (3 - x).abs + (3 - y).abs

a=[]
i=0
x=0
y=0
5.times do
	row=gets.chomp.split(' ').map(&:to_i)
	row.each_index do |char|
		if char==1
			x=i
			y=char
		end
	end
	a.push(row)
	i+=1
end
puts (x+y-4).abs

a=[]
i=0
x=0
y=0
5.times do
	row=gets.chomp.split(' ').map(&:to_i)
	row.each_index do |char|
		if char==1
			x=i
			y=char
		end
	end
	a.push(row)
	i+=1
end
puts (x-2).abs+(y-2).abs

arr = []
x = nil
y = nil

5.times do |tx|
  arr << gets.chomp.split(' ')
  y ||= arr.last.index '1'
  (x ||= tx) if y
end

puts "COORDS: " + x.to_s + " " + y.to_s
puts (x-2).abs + (y-2).abs

i,j = nil, nil
(0..4).each do |k|
    a = $stdin.readline.split.map(&:to_i)
    t = a.find_index(1)
    if !t.nil?
        i,j=k,t
    end
end

di = (2-i).abs
dj = (2-i).abs

puts 1+di+dj

a=gets.chomp.split(" ").map {|i| i.to_i}
b=gets.chomp.split(" ").map {|i| i.to_i}
b.sort!
if a[0]-a[1]>=0
c=b[a[0]-a[1]]
puts "#{c} #{c-1}"
else
puts "-1"
end

n = Array.new
for i in 0...5
    n[i] = Array.new
end
for i in 0...5
    input = gets.chomp
    for j in 0...5
        nums = input.split
        n[i][j] = Integer(nums[j])
    end
end

a = 0
b = 0
for i in 0...5
    for j in 0...5
        if n[i][j] == 1
            a = i
            b = j
        end
    end
end

if a > b
    puts a - b
elsif a == 0 && b == 0
    puts 4
elsif a == 1 && b == 1
    puts 2
elsif a == 2 && b == 2
    puts 0
elsif a == 3 && b == 3
    puts 2
elsif a == 4 && b == 4
    puts 4

else
    a < b
    puts  b - a
end


r, x, y, x_, y_ = gets.split.map &:to_i

d = Math.sqrt(((x_ - x) ** 2) + ((y_ - y) ** 2))

puts (d / (2 * r).to_f).ceil

r,x,y,x1,y1 = gets.chomp.split

r = r.to_f
x = x.to_f
y = y.to_f
x1= x1.to_f
y1= y1.to_f

l = Math.sqrt((x-x1)*(x-x1)+(y-y1)*(y-y1))
l = l/(2*r)
l = l.ceil

puts l.to_i

#!/usr/bin/env ruby
r,*_=gets.split.map(&:to_f)
d=Math.hypot(*_.each_slice(2).to_a.transpose.map{|e|e.reduce(:-)})
p (d/r/2).ceil

def run
  r, x, y, xp, yp = $stdin.gets.split.map(&:to_i)

  dx = xp - x
  dy = yp - y

  n = (Math.sqrt(dx * dx + dy * dy) / (r * 2)).ceil
  puts n
end

run if $0 == __FILE__

r,x1,y1,x2,y2=gets.split.map{|e| e.to_f}
r2=Math.hypot(x1-x2,y1-y2)
r4=r*2
if r2==0 then
	puts 0
else
	r3=r2.to_i
	ans=(r2/r4).floor
	#p [r2,r4,ans]
	d=r2-r4*ans
	if d>0 && d<r4 then
		ans+=1
	end
	puts ans.to_i
end

# coding: utf-8
# if __FILE__ == $0
# end

r, x1, y1, x2, y2 = gets.split.map(&:to_i)
unit = 2*r
direct_distance = Math.sqrt((x1-x2)**2 + (y1-y2)**2)

steps = (direct_distance/unit).floor
direct_distance -= steps * unit
if direct_distance > 0
    # subtract 1 step and make into 2 step to fulfill 2r < R < 4r
    steps += 1
end
puts steps

def stop
	puts "stop"
	sleep(2)
end
def readarr
	gets.split.map{|i| i.to_i}
end
def write(foo)
	if foo.is_a?(Array)
		puts foo.map{|i| i.to_s}.join(" ")
	else
		puts foo
	end
end
r, x, y, x1, y1 = readarr
N = ((x1-x)**2+(y1-y)**2)
l = (4*r*r)
ans =(N/l)**0.5
if(ans*ans*l==N)
	puts ans.to_i
else
	puts ans.to_i+1
end
#sleep(300)

r, x, y, xd, yd = gets.split(" ").map &:to_f

len = Math.sqrt((xd - x)**2 + (yd - y)**2)

puts (len / (2 * r)).ceil

#!ruby

r, x0, y0, x1, y1 = gets.split.map{|e| e.to_i}

distance = Math.sqrt((x1-x0)**2 + (y1-y0)**2)

count = 0

while ( distance > 0 )
  count += 1
  distance -= r*2
end

puts count

r,x1,y1,x2,y2=gets.split.map{|e| e.to_f}
r2=Math.hypot(x1-x2,y1-y2)
r4=r*2
if r2==0 then
	puts 0
else
	r3=r2.to_i
	ans=(r2/r4).floor
	#p [r2,r4,ans]
	d=r2-r4*ans
	if ans==0 then
		ans=2
	elsif d>0 && d<r4 then
		ans+=1
	end
	puts ans.to_i
end

# coding: utf-8

# if __FILE__ == $0
# end

r, x1, y1, x2, y2 = gets.split.map(&:to_i)
step = 2*r

puts (x1 - x2).abs/step + (y1 - y2).abs/step

def stop
	puts "stop"
	sleep(2)
end
def readarr
	gets.split.map{|i| i.to_i}
end
def write(foo)
	if foo.is_a?(Array)
		puts foo.map{|i| i.to_s}.join(" ")
	else
		puts foo
	end
end
r, x, y, x1, y1 = readarr
ans = ((x1-x)**2+(y1-y)**2)**(0.5)/(2*r)
if ans-ans.to_i<1e-9
	puts ans.to_i
else
	puts ans.to_i+1
end
#sleep(300)


j=gets.to_i.abs;i=0;j-=i+=1 while j>0||j&1>0;puts i

x = STDIN.gets.chomp.to_i
if (x < 0)
  x = -x
end
n = 0
i = 0
while true
  n += i;
  if (n == x)
    puts i
    break;
  elsif(n > x && (n-x) % 2 == 0)
    puts i
    break;
  end
  i += 1
end

j=-gets.to_i.abs;i=0;j+=i+=1 while j<0||j&1>0;puts i

x=gets.to_i.abs;i=j=0;while j<x||(j-x)&1>0 do j+=i+=1 end;puts i

n=gets.to_i.abs;s=i=0;s+=i+=1 while s<n||(s-n)%2>0;p i

#!/usr/bin/ruby

class Solver
  def solve(x)
    x = x.abs()
    i = 0
    sum = 0

    while sum < x or (x - sum)%2 != 0 do
      i += 1
      sum += i
    end

    puts i
  end
end

x = STDIN.gets.to_i
solver = Solver.new
solver.solve(x)

n=gets.to_i.abs
if n==0 then puts "0";exit end

i=1
k=0
loop do
        k+=i
        if k>=n && (k-n)%2==0 then break end
        i+=1
end

puts i

n=gets.to_i.abs
i=1
k=0
while k<n
        k+=i
        i+=1
end
if (k-n)%2==0 then
        puts i-1
elsif k%2==0 then
        puts i+1
else
        puts i

end

n=gets.to_i.abs
i=1
k=0
while k<n
        k+=i
        i+=1
end
if (k-n)==0 then
        puts i-1
elsif k%2==0 then
        puts i+1
else
        puts i

end

n=gets.to_i.abs
i=1
k=0
while k<n
        k+=i
        i+=1
end
#p k
if (k-n)%2==0 then
        puts i-1
elsif k%2==0 then
        puts i+1
else
        puts i+1

end

n=gets.to_i.abs
i=1
k=0
while k<n || k&1>0
    k+=i
    i+=1
end
#p k
puts i-1

x = STDIN.gets.chomp.to_i
n = 0
i = 0
while true
  n += i;
  if (n == x)
    puts i
    break;
  elsif(n > x && i % 2 != 0)
    puts i
    break;
  end
  i += 1
end

x=gets.to_i;i=j=0;while j<x||(j-x)&1>0 do j+=i+=1 end;puts i


#!/usr/bin/ruby

n = gets.to_i

ret = "BigInteger"
ret = "long" if n <= 9223372036854775807
ret = "int" if n <= 2147483647
ret = "short" if n <= 32767
ret = "byte" if n <= 127
puts ret

#! /usr/bin/ruby
$a = gets.to_i
def f
    if $a < -9223372036854775808 or $a > 9223372036854775807
        return 'BigInteger'
    end

    if $a < -2147483648 or $a > 2147483647
        return 'long'
    end

    if $a < -32768 or $a > 32767
        return 'int'
    end

    if $a < -128 or $a > 127
        return 'short'
    end

    return 'byte'
end

puts f

y = [1 << 7, 1 << 15, 1 << 31, 1 << 63]
name = ['byte', 'short', 'int', 'long', 'BigInteger']

x = gets.to_i

add = 0
if x > 0
  add = -1
else
  add = 0
  x = -x
end

ans = ''
for i in 0...4

  if x <= y[i] + add
    ans = name[i]
    break
  end

end

if ans == ''
  ans = 'BigInteger'
end

puts ans

N = gets.to_i

if N > 9223372036854775807
  puts "BigInteger"
elsif N > 2147483647
  puts "long"
elsif N > 32767
  puts "int"
elsif N > 127
  puts "short"
else
  puts "byte"
end

arr=["byte","short","int","long","BigInteger"]
n=(gets.chomp.to_i).abs
if n > 9223372036854775807
	puts arr[4]
elsif n > 2147483647
	puts arr[3]
elsif n > 32767
	puts arr[2]
elsif n >127
	puts arr[1]
else
	puts arr[0]
end

d=gets.to_i
if  d>=-128 and d<=127 then puts 'byte'
elsif d>=-32768 and d<=32767 then puts 'short'
elsif d>=-2147483648 and d<=2147483647 then puts 'int'
elsif d>=-9223372036854775808 and d<=9223372036854775807 then puts 'long'
else puts 'BigInteger'
end

a = gets.to_i
res = 'BigInteger'
res = 'long' if a <= 9223372036854775807
res = 'int' if a <= 2147483647
res = 'short' if a <= 32767
res = 'byte' if a <= 127
puts res


n, k = gets.strip.split.map(&:to_i)
ary = gets.strip.split.map(&:to_i)
ans = 0
si = -1
0.upto(n-1).each do |i|
  if ary[i] <= k
    ans += 1
    si = i
  else
    break
  end
end
(n-1).downto(si+1).each do |i|
  if ary[i] <= k
    ans += 1
  else
    break
  end
end
puts ans

n, k = gets.split.map &:to_i

nums = gets.split.map &:to_i

count = 0

index = 0
for i in 0..n-1
    if nums[i]<=k
        count+=1
    else
        index = i
        break
    end
end

if count!=n
    for i in 0..n-index-1
        if nums[n-i-1]<=k
            count+=1
        else
            break
        end
    end
    puts count
else
    puts count
end

def solution
  _, k = read_ints
  ps = read_ints

  count = 0

  while ps.first && ps.first <= k
    count += 1
    ps.shift
  end

  while ps.last && ps.last <= k
    count += 1
    ps.pop
  end

  puts count
end

def read_int
  gets.to_i
end

def read_ints
  gets.split.map(&:to_i)
end

def read_string
  gets.chomp
end

solution unless ENV['TEST__MODE']

n,k = readline.split.map(&:to_i)
a = readline.split.map(&:to_i)

ans=0
i=0
while i<n and a[i]<=k
	ans += 1
	i += 1
end
i=n-1
while i>=0 and a[i]<=k
	ans += 1
	i -= 1
end

puts [ans,n].min

n, k = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)

ans = 0
(0..n-1).each do |i|
  a = as[i]
  if a <= k
    ans += 1
  else
    break
  end
end

(n-1).downto(ans) do |i|
  a = as[i]
  if a <= k
    ans += 1
  else
    break
  end
end

puts ans

# https://codeforces.com/problemset/problem/999/A
def solution(n, k, a)
  count = 0

  i = 0
  while i < n && a[i] <= k do
    count += 1
    i += 1
  end

  return count if count == n

  i = n - 1
  while i > 0 && a[i] <= k do
    count += 1
    i -= 1
  end

  return count
end

n, k = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ").map(&:to_i)

puts solution(n, k, a)

n, k = gets.chomp.split.map(&:to_i)
list = gets.chomp.split.map(&:to_i)

i, j = 0, n - 1

while i < n
  break i if list[i] > k
  i += 1
end

while j >= 0
  break j if list[j] > k
  j -= 1
end

if i == n && j == -1
  puts n
else
  puts (n - (j - i + 1))
end

$n,$k=gets.split
$n,$k,i=$n.to_i,$k.to_i,0
a=gets.split
$ans,$flag=[0,0],[0,0]
def test(c,p)
	if c>$k
	  yield p,0
	else
          yield p,1
	end
end
a.each{|c| test(c.to_i,0){|id,fla|
			     if fla==0
			         $flag[id]=1
			     elsif $flag[id]==0
                                 $ans[id]=$ans[id]+1
			     end
				}}
a.reverse.each{|c| test(c.to_i,1){|id,fla|
			     if fla==0
			         $flag[id]=1
			     elsif $flag[id]==0
                                 $ans[id]=$ans[id]+1
			     end
				}
		}
puts [$ans[0]+$ans[1],$n].min

n, k = gets.split(" ").map{|n| n.to_i }
a = gets.split(" ").map{|n| n.to_i }
count = 0
all_solved = true
a.each {|m|
  if m <= k
    count += 1
    next
  end
  all_solved = false
  break
}
if all_solved
  puts count
else
  a.reverse.each {|m|
    if m <= k
      count += 1
      next
    end
    break
  }
  puts count
end

n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
pos = a.each_with_index.select { |v, i| v > k }.map { _2 }
if pos.empty?
	puts n
else
	puts pos[0] + (n - 1 - pos[-1])
end

n,k,*a=$<.read.split.map &:to_i
p a.all?{|e|e<=k}?n:a.index{|e|e>k}+(n-1-a.rindex{|e|e>k})

N, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
as.shift while as.length > 0 && as[0] <= K
as.pop while as.length > 0 && as[-1] <= K
puts N - as.length

n,k,*a=$<.read.split.map &:to_i
p a.count{|e|e<=k}

n,k,*a=$<.read.split.map &:to_i
p a.all?{|e|e<=k}?n:a.index{|e|e>k}+(n-a.rindex{|e|e>k})

n, k = gets.split(" ").map{|n| n.to_i }
a = gets.split(" ").map{|n| n.to_i }
count = 0
all_solved = true
a.each {|n|
  count += 1 if n <= k
  all_solved = false
  break
}
if all_solved
  puts count
else
  a.reverse.each {|n|
    count += 1 if n <= k
    break
  }
end


def parse_time(time)
  time.split(':').map(&:to_i)
end

def to_str(h, m)
  [h, m].map { |t| "%02d" % t }.join(':')
end

def solve(cur_time, duration)
  hc, mc = parse_time cur_time
  hd, md = parse_time duration
  hg = hc - hd
  mg = mc - md
  if mg < 0
    mg = 60 + mg
    hg -= 1
  end
  hg = (hg + 24) % 24
  to_str(hg, mg)
end

if __FILE__ == $0
  puts solve(gets.chomp, gets.chomp)
end

class Tm
  attr_accessor :x
  def initialize(a)
    if a.class == String
      h, m = a.split(":").map(&:to_i)
      @x = h*60 + m
    else
      @x = a
      @x += 1440 if @x < 0
    end
  end
  def -(y)
    Tm.new (@x - y.x)
  end
  def output
    printf "%02d:%02d\n", @x/60, @x%60
  end
end
st = Tm.new gets.chomp
ed = Tm.new gets.chomp
(st-ed).output

require 'date'

$SIZE_DAY_IN_MINUTES = 24 * 60

def convert_to_secunds(minutes)
  minutes * 60
end

def convert_to_minutes(time)
  time.hour * 60 + time.min
end

endTime   = DateTime.parse gets.chomp
startTime = DateTime.parse gets.chomp

endTime_minutes   = convert_to_minutes endTime
startTime_minutes = convert_to_minutes startTime

if startTime_minutes > endTime_minutes
  minutes_yesterday = $SIZE_DAY_IN_MINUTES - startTime_minutes
  sleep = minutes_yesterday + endTime_minutes
else
  sleep = endTime_minutes - startTime_minutes
end

puts Time.at(convert_to_secunds sleep).utc.strftime("%H:%M")

mh,mm = gets.split(":").map(&:to_i)
nh, nn  = gets.split(":").map(&:to_i)

mh=mh-nh
mm= mm-nn

if mm<0
  mm+=60
  mh-=1
end
if mh<0
  mh+=24
end
if mm<10
  mm= "0" + mm.to_s
end
if mh<10
  mh = "0"+mh.to_s
end
puts "#{mh}:#{mm}"

class ProblemA
  def initialize
    @dats = STDIN.read.split("\n")
    @now = @dats[0]
    @slept = @dats[1]
  end

  def solve
    slept_h = @slept.split(":")[0].to_i % 24
    sleft_m = @slept.split(":")[1].to_i

    now_h = @now.split(":")[0].to_i
    now_m = @now.split(":")[1].to_i

    m = now_m - sleft_m
    h = now_h - slept_h
    minus = 0
    if m < 0
      m = now_m + 60 - sleft_m
      minus = 1
    end

    h = now_h - slept_h - minus
    h = h < 0 ? h + 24 : h

    h = h < 10 ? "0#{h}" : h
    m = m < 10 ? "0#{m}" : m
    print "#{h}:#{m}"
  end
end

solver = ProblemA.new
solver.solve

wh,wm=gets.chomp.split(':').collect{|a| a.to_i}
sh,sm=gets.chomp.split(':').collect{|a| a.to_i}
rh=0
rm=0
if wm<sm
 wh-=1
 wm+=60
end
rm=wm-sm
if wh== -1
 wh=23
end
rh=wh-sh
if rh <0
  rh=24 +rh
end
res_h=rh.to_s
if(rh<10)
res_h="0" +res_h
end
res_m=rm.to_s
if(rm<10)
res_m="0"+res_m
end
res=res_h+":"+res_m
puts res

def getTime(time)
    hour = (time[0].ord - '0'.ord) * 10 + time[1].ord - '0'.ord
    minute = (time[3].ord - '0'.ord) * 10 + time[4].ord - '0'.ord
    return [hour, minute]
end

wake_up = getTime(gets.chomp)
slept = getTime(gets.chomp)

fell_asleep = [wake_up[0] - slept[0], wake_up[1] - slept[1]]

if fell_asleep[1] < 0
    fell_asleep[1] += 60
    fell_asleep[0] -= 1
end

fell_asleep[0] += 24 if fell_asleep[0] < 0

puts fell_asleep[0].to_s.rjust(2, "0") + ":" + fell_asleep[1].to_s.rjust(2, "0")

def getTime(time)
	hour = (time[0].to_i - '0'.to_i) * 10 + time[1].to_i - '0'.to_i
	minute = (time[3].to_i - '0'.to_i) * 10 + time[4].to_i - '0'.to_i
	return [hour, minute]
end

def getFellAsleep(wake_up, slept)
	fell_asleep = [wake_up[0] - slept[0], wake_up[1] - slept[1]]

	if fell_asleep[1] < 0
		fell_asleep[1] += 60
		fell_asleep[0] -= 1
	end

	fell_asleep[0] += 24 if fell_asleep[0] < 0

	return fell_asleep
end

wake_up = getTime(gets.chomp)
slept = getTime(gets.chomp)

fell_asleep = getFellAsleep(wake_up, slept)

puts fell_asleep[0].to_s.rjust(2, "0") + ":" + fell_asleep[1].to_s.rjust(2, "0")

first = gets.chomp
second = gets.chomp

first = first.split(":").map { |i| i.to_i }
second = second.split(":").map { |i| i.to_i }

first = first[0]*60 + first[1]
second = second[0]*60 + second[1]

x = first - second

if x >= 0 then

	hr = x/60
	mn = x%60

	print "0" if hr < 10
	print hr,":"
	print "0" if mn < 10
	print mn

else

	hr = ((24*60) - (-1*x)) / 60
	mn = ((24*60) - (-1*x)) % 60
	print "0" if hr < 10
	print hr,":"
	print "0" if mn < 10
	print mn

end

s = gets.strip.split(":").map! {|i| i.to_i}
shh = s[0]
smm = s[1]

t = gets.strip.split(":").map! {|i| i.to_i}
thh = t[0]
tmm = t[1]

ahh = (shh-thh)
amm = (smm-tmm)
if amm < 0
  ahh = ahh - 1
  amm = 60 + amm
end
if ahh < 0
  ahh = 24 + ahh
end
puts "%02d:%02d" % [ahh, amm]

sh, sm = gets.chomp.split(":").map(&:to_i)
th, tm = gets.chomp.split(":").map(&:to_i)
if sm < tm
  sh -= 1
  sm += 60
end
ph = [sh - th, (24 + (sh - th)) % 24].max
pm = sm - tm
puts "#{"%02d" % ph}:#{"%02d" % pm}"

def parseTime(s)
	[s[0,2].to_i, s[-2, 2].to_i]
end

h1, m1 = parseTime(gets.chomp)
h2, m2 = parseTime(gets.chomp)

t1 = h1*60+m1
t2 = h2*60+m2

if t2 > t1
	t1 += 1440
end

result = t1 - t2

print "%02d:%02d" % [result / 60, result % 60]

mh,mm = gets.split(":").map(&:to_i)
nh, nn  = gets.split(":").map(&:to_i)

mh=mh-nh
mm= mm-nn
if mm<0
  mm-=60
  mh+=1
end
if mh<0
  mh+=24
end
if mm<10
  mm= "0" + mm.to_s
end
if mh<10
  mh = "0"+mh.to_s
end
puts "#{mh}:#{mm}"

wh,wm=gets.chomp.split(':').collect{|a| a.to_i}
sh,sm=gets.chomp.split(':').collect{|a| a.to_i}
rh=0
rm=0
if wm<sm
 wh-=1
 wm+=60
end
rm=wm-sm
if wh== -1
 wh=0
end
rh=wh-sh
if rh <0
  rh=24 +rh
end
res_h=rh.to_s
if(rh<10)
res_h="0" +res_h
end
res_m=rm.to_s
if(rm<10)
res_m="0"+res_m
end
res=res_h+":"+res_m
puts res

# s = current time, first line hh:mm
# t = time slept, seconde line hh:mm

s = gets.strip.split(":").map! {|i| i.to_i}
shh = s[0]
smm = s[1]

t = gets.strip.split(":").map! {|i| i.to_i}
thh = t[0]
tmm = t[1]

ahh = (shh-thh)
amm = (smm-tmm)
if amm < 0
  ahh = ahh - 1
  ahh = 60 + ahh
end
if ahh < 0
  ahh = 24 + ahh
end
puts "%02d:%02d" % [ahh, amm]
#puts (shh - thh).to_s + ":" + (smm-tmm).to_s


def lscan; gets.split.map(&:to_i); end

w1,h1,w2,h2 = lscan

ans = (w2+1)*2+(h1+h2+1)*2
ans += (w1-w2)*2

p ans

a,b,c,d = gets.split.map(&:to_i)
p a+2*b+c+2*d+(a-c).abs+4

require 'scanf'
w1,h1,w2,h2=scanf("%d%d%d%d")
puts w1*2+h1*2+h2*2+4

DBG = true
w1,h1,w2,h2 = gets.split.map{|z| z.to_i}
puts "#{2*(w1+h1+h2)+4}"

w1, h1, w2, h2 = gets.split.map &:to_i
puts 2*(h1 + h2 + 2 + w1)

if File.exists?("input")
  $stdin = File.open("input")
  $stdout = File.open("output","w")
end

whwh = gets.chomp.split(" ").map(&:to_i)
w1=whwh[0]
h1=whwh[1]
w2=whwh[2]
h2=whwh[3]

ans = h1+h2+w1+w2+4+h1+h2+(w1-w2).abs
puts ans


x, y=gets.split.map &:to_i
a=y, y, y
res=0
while a[0]<x
    a[0]=[a[1]+a[2]-1, x].min
    a.sort!
    res+=1
end
p res

x, y = gets.split.map(&:to_i)
a = [y] * 3
r = 0
until a[0] == x
	a[0] = [a[1] + a[2] - 1, x].min
	a.sort!
	r += 1
end

puts r

def printlol(ar)
  for i in 0..(ar.length-2) do
    print ar[i]
    print " "
  end
  print ar.last
  puts ""
end

input = gets.strip.split(' ').map(&:to_i)
x = input[0]
y = input[1]

lol = [y, y, y]
count = 0
while lol[0] != x or lol[1] != x or lol[2] != x do
  asd = lol.dup
  asd.slice!(lol.index(lol.min))
  top = (asd[0] + asd[1])

  if top - 1 > x
    asd << x
  else
    asd << top - 1
  end

  lol = asd
  count += 1
  #printlol(lol)
end

puts count

x, y = gets.split.map(&:to_i)
a = [y, y, y]
c = 1
loop do
  mx = a.min
  case mx
  when a[0]
    a[0] = [a[1] + a[2] - 1, x].min
  when a[1]
    a[1] = [a[0] + a[2] - 1, x].min
  when a[2]
    a[2] = [a[0] + a[1] - 1, x].min
  end
  break if a == [x, x, x]
  c += 1
end
puts c

n, m = readline.split.map(&:to_i)

s = [m,m,m]

ans = 0
while s.min <= n
  s[0] = s[1] + s[2]-1
  s=s.sort
  ans += 1
end

puts ans

x, y = gets.chomp.split(' ').map(&:to_i)
sides = [y, y, y]

ans = 0

until sides.count(x) == 3
    sortedSides = Array.new(sides).sort
    power = x - sortedSides[0]

    power = sortedSides[1] + sortedSides[2] - sortedSides[0] - 1 if power >= sortedSides[1] + sortedSides[2] - sortedSides[0]
    sides[sides.index(sortedSides[0])] = sides[sides.index(sortedSides[0])] + power

    #print sides
    #puts ''

    ans += 1
end

puts ans

#!/usr/bin/ruby
x,y=gets.split.map(&:to_i)
a=[y]*3
r=0
while a[0]!=x
	a[0]=[a[1]+a[2]-1,x].min
	a.sort!
	r+=1
end
p r

#!/usr/bin/ruby
x,y=gets.split.map(&:to_i)
a=[x]*3
r=0
while a[2]!=y
	a[2]=[a[1]-a[0]+1,y].max
	a.sort!
	r+=1
end
p r

def printlol(ar)
  for i in 0..(ar.length-2) do
    print ar[i]
    print " "
  end
  print ar.last
  puts ""
end

input = gets.strip.split(' ').map(&:to_i)
x = input[0]
y = input[1]

lol = [x, x, x]
count = 0
while lol[0] != y or lol[1] != y or lol[2] != y do
  asd = lol.dup
  asd.slice!(lol.index(lol.max))
  fark = (asd[0] - asd[1]).abs
  if fark + 1 < y
    asd << [y, ((asd[0] + asd[1]) / 6.to_f).round].max
  else
    if (fark + 1) >= ((asd[0] + asd[1]) / 6.to_f).round
      asd << (fark + 1)
    else
      asd << ((asd[0] + asd[1]) / 6.to_f).round
    end
  end
  lol = asd
  count += 1
  #printlol(lol)
end

puts count

def printlol(ar)
  for i in 0..(ar.length-2) do
    print ar[i]
    print " "
  end
  print ar.last
  puts ""
end

input = gets.strip.split(' ').map(&:to_i)
x = input[0]
y = input[1]

lol = [x, x, x]
count = 0
while lol[0] != y or lol[1] != y or lol[2] != y do
  asd = lol.dup
  asd.slice!(lol.index(lol.max))
  fark = (asd[0] - asd[1]).abs
  if fark + 1 < y
    asd << [y, ((asd[0] + asd[1]) / 6)].max
  else
    if (fark + 1) >= ((asd[0] + asd[1]) / 6)
      asd << (fark + 1)
    else
      asd << ((asd[0] + asd[1]) / 6)
    end
  end
  lol = asd
  count += 1
  if count > 20
    break
  end
  #printlol(lol)
end

puts count

def printlol(ar)
  for i in 0..(ar.length-2) do
    print ar[i]
    print " "
  end
  print ar.last
  puts ""
end

input = gets.strip.split(' ').map(&:to_i)
x = input[0]
y = input[1]

lol = [x, x, x]
count = 0
while lol[0] != y or lol[1] != y or lol[2] != y do
  asd = lol.dup
  asd.slice!(lol.index(lol.max))
  fark = (asd[0] - asd[1]).abs
  if fark + 1 < y
    if (y - ((asd[0] + asd[1] + 1) / 6.to_f).round + 1).abs == 1
      asd << y
    else
      asd << [y, ((asd[0] + asd[1] + 1) / 6.to_f).round + 1].max
    end
  else
    if (fark + 1) >= ((asd[0] + asd[1] + 1) / 6.to_f).round + 1
      asd << (fark + 1)
    else
      asd << ((asd[0] + asd[1] + 1) / 6.to_f).round + 1
    end
  end
  lol = asd
  count += 1
  #printlol(lol)
end

puts count

def printlol(ar)
  for i in 0..(ar.length-2) do
    print ar[i]
    print " "
  end
  print ar.last
  puts ""
end

input = gets.strip.split(' ').map(&:to_i)
x = input[0]
y = input[1]

lol = [x, x, x]
count = 0
while lol[0] != y or lol[1] != y or lol[2] != y do
  asd = lol.dup
  asd.slice!(lol.index(lol.max))
  fark = (asd[0] - asd[1]).abs
  if fark + 1 < y
    asd << [y, ((asd[0] + asd[1]) / 6)].max
  else
    if (fark + 1) >= ((asd[0] + asd[1]) / 6)
      asd << (fark + 1)
    else
      asd << ((asd[0] + asd[1]) / 6)
    end
  end
  lol = asd
  count += 1
  if count > 20
    break
  end
  printlol(lol)
end

puts count

def printlol(ar)
  for i in 0..(ar.length-2) do
    print ar[i]
    print " "
  end
  print ar.last
  puts ""
end

input = gets.strip.split(' ').map(&:to_i)
x = input[0]
y = input[1]

lol = [x, x, x]
count = 0
while lol[0] != y or lol[1] != y or lol[2] != y do
  asd = lol.dup
  asd.slice!(lol.index(lol.max))
  fark = (asd[0] - asd[1]).abs
  if fark + 1 < y
    asd << [y, ((asd[0] + asd[1]) / 6)].max
  else
    if (fark + 1) >= ((asd[0] + asd[1]) / 6)
      asd << (fark + 1)
    else
      asd << ((asd[0] + asd[1]) / 6)
    end
  end
  lol = asd
  count += 1
  #printlol(lol)
end

puts count

def printlol(ar)
  for i in 0..(ar.length-2) do
    print ar[i]
    print " "
  end
  print ar.last
  puts ""
end

input = gets.strip.split(' ').map(&:to_i)
x = input[0]
y = input[1]

lol = [x, x, x]
count = 0
while lol[0] != y or lol[1] != y or lol[2] != y do
  asd = lol.dup
  asd.slice!(lol.index(lol.max))
  fark = (asd[0] - asd[1]).abs
  if fark + 1 < y
    asd << [y, ((asd[0] + asd[1]) / 6)].max
  else
    if (fark + 1) >= ((asd[0] + asd[1]) / 6)
      asd << (fark + 1)
    else
      asd << ((asd[0] + asd[1]) / 6)
    end
  end
  lol = asd
  count += 1
  printlol(lol)
end

puts count

n, m = readline.split.map(&:to_i)

s = [m,m,m]

ans = 0
while s.min <= n
  s[0] = s[1] + s[2]
  s=s.sort
  ans += 1
end

puts ans


gets
p gets.chomp.split(/[A-Z]+/).each.map{|s|s.split(//).uniq.length}.max || 0

class String
  def is_lower?
    self == self.downcase
  end
end

n = STDIN.gets.chomp.to_i
s = STDIN.gets.chomp
letters = {}
answer = 0
s.each_char do |ch|
  if ch.is_lower?
    letters[ch] = true
  else
    answer = [answer, letters.size].max
    letters = {}
  end
end
answer = [answer, letters.size].max
puts answer

n = gets.to_i

ans = 0

abc = []
gets.chomp.each_char do |c|
	if 'a' <= c && c <= 'z'
		abc[c.ord - 'a'.ord] = 1
	else
		ans = [ans, abc.count(1)].max
		abc = []
	end
end

p [ans, abc.count(1)].max

def is_up_case?( chr )
    chr >= 'A' && chr <= 'Z'
end
n = gets.strip.to_i
s = gets.strip
i = ans = 0
prev = '0'
while i < n
    curr = s[i]
    dist = {}
    while !is_up_case? curr
        curr = s[i]
        break if curr.nil? || is_up_case?( curr )
        dist[curr] = 1 if dist[curr].nil?
        prev = curr
        i += 1
    end
    ans = [ans, dist.length].max
    i += 1
end
puts ans

n = gets.to_i

ans = 0

abc = []
gets.chomp.each_char do |c|
	if 'a' <= c && c <= 'z'
		abc[c.ord - 'a'.ord] = 1
	else
		ans = [ans, abc.count(1)].max
		abc = []
	end
end

p ans

n = gets.strip.to_i
s = gets.strip
count = Array.new(26, 0)
n.times do |i|
    curr = s[i]
    if curr >= 'a' && curr <= 'z'
        pos = curr.ord - 'a'.ord
        count[pos] += 1
    end
end
ans = 0
count.each do |a|
    ans += 1 if a > 0
end
puts ans

class String
  def is_lower?
    self == self.downcase
  end
end

n = STDIN.gets.chomp.to_i
s = STDIN.gets.chomp
letters = {}
answer = 0
s.each_char do |ch|
  if ch.is_lower?
    letters[ch] = true
  else
    answer = [answer, letters.size].max
    letters = {}
  end
end
puts answer


def dsum(given_degree)
    given_degree['1'] + given_degree['2'] + given_degree['3']
end

n = gets.to_i
degree = gets.split(' ')
degree_1 = {:min => degree.first.to_i, :max => degree.last.to_i}
degree = gets.split(' ')
degree_2 = {:min => degree.first.to_i, :max => degree.last.to_i}
degree = gets.split(' ')
degree_3 = {:min => degree.first.to_i, :max => degree.last.to_i}
given_degree = {'1' => degree_1[:min], '2' => degree_2[:min], '3' => degree_3[:min]}
if dsum(given_degree) == n
    puts "#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}"
else
    if n - dsum(given_degree) <= (degree_1[:max] - given_degree['1'])
        given_degree['1'] += n - dsum(given_degree)
    else
        given_degree['1'] = degree_1[:max]
        puts "#{given_degree['2']} #{given_degree['2']} #{given_degree['3']}" if dsum(given_degree) == n
        if n - dsum(given_degree) <= (degree_2[:max] - given_degree['2'])
            given_degree['2'] += n - dsum(given_degree)
        else
            given_degree['2'] = degree_2[:max]
            puts "#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}" if dsum(given_degree) == n
            if n - dsum(given_degree) <= (degree_3[:max] - given_degree['3'])
                given_degree['3'] += n - dsum(given_degree)
            end
        end
    end
    puts "#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}"
end

# http://codeforces.com/contest/557/problem/A
n = gets.chomp.to_i
first, second, third = [].tap do |arr|
  3.times { arr << gets.chomp.split.map(&:to_i) }
end

a = [first[1], n - second[0] - third[0]].min
b = [second[1], n - a - third[0]].min
c = n - a - b

puts [a, b, c].join(' ')

def read_ints; gets.chomp.split.map(&:to_i) end
@n = read_ints[0]
min1,max1 = read_ints
min2,max2 = read_ints
min3,max3 = read_ints

@rez = [min1,min2,min3]

def left; @n - @rez.inject(:+) end

@rez[0]+=[left,max1-@rez[0]].min
@rez[1]+=[left,max2-@rez[1]].min
@rez[2]+=[left,max3-@rez[2]].min

puts @rez.join(' ')

n = gets.to_i
min1, max1 = gets.split.map { |e| e.to_i }
min2, max2 = gets.split.map { |e| e.to_i }
min3, max3 = gets.split.map { |e| e.to_i }

d1, d2, d3 = 0, 0, 0

d1 = n-min2-min3 > max1 ? max1 : n-min2-min3
n -= d1
print d1.to_s + ' '

d2 = n-min3 > max2 ? max2 : n-min3
n -= d2
print d2.to_s + ' '

print n

n = gets.to_i
a = 3.times.map{gets.split.map(&:to_i)}
p = a.map{|x, y| x}
n -= p.inject(:+)
3.times do |i|
  mi = [a[i][1] - a[i][0], n].min
  p[i] += mi
  n -= mi
  break if n <= 0
end
puts p.join(' ')

n = gets.to_i
a = 3.times.map{gets.split.map(&:to_i)}
p = a.map{|x, y| x}
n -= p.inject(:+)
3.times do |i|
  mi = [a[i][1] - a[i][0], n].min
  p[i] += mi
  n -= mi
  break if n <= 0
end
puts "#{p[0]} #{p[1]} #{p[2]}"

def dsum(given_degree)
    given_degree['1'] + given_degree['2'] + given_degree['3']
end

n = gets.to_i
degree = gets.split(' ')
degree_1 = {:min => degree.first.to_i, :max => degree.last.to_i}
degree = gets.split(' ')
degree_2 = {:min => degree.first.to_i, :max => degree.last.to_i}
degree = gets.split(' ')
degree_3 = {:min => degree.first.to_i, :max => degree.last.to_i}
given_degree = {'1' => degree_1[:min], '2' => degree_2[:min], '3' => degree_3[:min]}
if dsum(given_degree) == n
    puts "#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}"
else
    if n - dsum(given_degree) <= (degree_1[:max] - given_degree['1'])
        given_degree['1'] += n - dsum(given_degree)
    else
        given_degree['1'] = degree_1[:max]
        puts "#{given_degree['2']} #{given_degree['2']} #{given_degree['3']}" if dsum(given_degree) == n
        if n - dsum(given_degree) <= (degree_2[:max] - given_degree['2'])
            given_degree['2'] += n - dsum(given_degree)
        else
            given_degree['2'] = degree_2[:max]
            puts "#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}" if dsum(given_degree) == n
            if n - dsum(given_degree) <= (degree_3[:max] - given_degree['3'])
                given_degree['3'] += n - dsum(given_degree)
            end
        end
    end
end
puts "#{given_degree['1']} #{given_degree['2']} #{given_degree['3']}"