#!/usr/bin/ruby

# Get one number at a time
n = STDIN.gets.to_f
res = Math.log2(n).ceil.to_i
puts res


n = gets.to_i
if n == 2
  printf("%d\n", 1)
elsif n == 3
  printf("%d\n", 2)
else
  cnt = 2
  i = 3
  while(1)
    add = 2 ** (cnt - 1)
    i += add
    break if i > n
    cnt += 1
  end
  printf("%d\n", cnt)
end


class Main
  #def get_problem_link
  #  problem_link = "https://codeforces.com/contest/978/problem/B"
  #  return problem_link
  #end

  #def get_submission_link
  #  submission_link = ''
  #  return submisson_link
  #end

  #begin
  #of codeforces interface
  def run_interface
    n = gets.to_i
    k = gets.split(' ')
    puts solution(n, k)
  end
  #end
  #of codeforces interface

  def solution(n, array_of_strings)
      res = 0
      counter = 0
      array_of_strings.each {|value|
        if value === "x"
          counter +=1
        else
          counter = 0
        end
        if counter > 2
          res +=1
        end
      }
      return res
  end

end

#then upload to codeforces uncomment this line:
Main.new.run_interface


n,m,a,b = gets.split.map{|x| x.to_i}
#p n,m,a,b
if a < b/m.to_f
    puts a*n
else
    puts b*(n/m) + a*(n%m)
end
#puts (x/5.0).ceil


n_m_a_b = gets.split
n = n_m_a_b[0].to_i
m = n_m_a_b[1].to_i
a = n_m_a_b[2].to_f
b = n_m_a_b[3].to_f

if b / m < a
    cost = n / m * b + n % m * a
    puts cost.to_i
else
    cost = n * a
    puts cost.to_i
end


#!/usr/bin/ruby

n, m, a, b = STDIN.readline.split.map {|s| s.to_i }
puts [n*a, n/m*b + n%m * a].min


#lucasmc

class Cheap
  attr_reader :result
  attr_reader :m
  attr_reader :n
  attr_reader :a
  attr_reader :b

  def initialize
    @result = 0
  end

  def calculate(n, m, a, b)
    m_ratio = b / m
    if m_ratio >= a
      @result = n * a
    else
      if m >= n
          @result = [a * n, b].min
      else
        q = n / m
        r = (n - (m * q))
        @result = [(q * b) + r * a, (q * b) + r * b].min
      end
    end
    return @result
  end
end

input = gets.chomp.split(" ").map(&:to_i)

n = input[0]
m = input[1]
a = input[2]
b = input[3]

cheap = Cheap.new

puts cheap.calculate(n,m,a,b)


n, m, a, b = $stdin.readline.split.map(&:to_i)

v = []
m_count = 0
while m_count<n
    n_count = n - m*m_count
    n_count = n_count>0 ? n_count : 0
    s = m_count*b + n_count*a
    #puts "n_count=#{n_count}, m_count=#{m_count}, s=#{s}"
    v << s
    m_count += 1
end

puts v.min


n, m, a, b = gets.chomp.split.map(&:to_i)
ans = a * n
k = 1
while k * m <= n do
  tans = k * b + ( n - k * m ) * a
  ans = tans if tans < ans
  k += 1
end
puts ans


  na=gets.chomp
  n=na[0..na.index(" ")-1].to_i
  i=na.index(" ")
  m=na[i+1..na.index(" ",i+1)-1].to_i
  i=na.index(" ",i+1)
  a=na[i+1..na.index(" ",i+1)-1].to_i
  i=na.index(" ",i+1)
  b=na[i+1..na.length-1].to_i

  if a<(b/m).floor
   puts n*a
  else
   puts [(n/m+1)*b,(n-(n/m).floor*m)*a+((n/m).floor)*b].min.to_i
  end


n, m, a, b = gets.chomp.split.map &:to_i
max = n  * a
max = [max, (n / m) * b + (n % m) * a].min
puts max


n, m, a, b = gets.split.map(&:to_i)
puts [n*a,n/m*b+n%m*a].min


n,m,a,b=gets.split.map &:to_i
p [n*a,n/m*b+n%m*a].min


n, m, a, b = gets.chomp.split(/ /).map(&:to_i)
cost_each_ride = n * a
special_rides = (n / m).floor
remaining_rides = n % m
cost_with_special_rides = (special_rides * b) + (remaining_rides * a)
minimum_cost = [cost_each_ride, cost_with_special_rides].min
puts minimum_cost


ans=10**10
n,m,a,b=gets.split.map{|e| e.to_i}
0.step(n,m){|i|
	t=(i/m)*b+(n-i)*a
	ans=[ans,t].min
}
puts ans


n,m,a,b = gets.chomp.split.map(&:to_i)

buy_for_a = n*a

if n >= m
  if n%m == 0
    buy_for_b = (n/m)*b
  else
    tt = ((n/m)*b) + ((n%m)*a)
    ttt = ((n/m)+1)*b
    buy_for_b = [tt,ttt].min
  end
  # buy_for_b = [t,tttt].min
else
  buy_for_b = (m*b)
end

puts [buy_for_a,buy_for_b].min


n,m,a,b = gets.split(" ").map(&:to_i)
no_of_special_tickets = n / m
one_way = n % m
puts [one_way * a + no_of_special_tickets * b, (n.to_f/m).ceil * b,n * b].min
#min(all sp,all one way,mix)


input = gets.chomp.split
n = input[0].to_i
m = input[1].to_i
a = input[2].to_i
b = input[3].to_i

ncost = n*a
mcost = 0
while n > m
    mcost += b
    n -= m
end

mcost += [n*a,m*b].min

puts [ncost, mcost].min


n, m, a, b = gets.split(' ').map(&:to_i)

puts [a*n, a*n.modulo(m) + b*n.div(m)].min


line = gets
n, m, a, b = line.split.map(&:to_i)
num1 = n * a
num2 = ((n/m) * b) + ((n%m) *a)
puts [num1, num2].min


nums = gets.split(" ")

n = nums[0].to_i
m = nums[1].to_i
a = nums[2].to_i
b = nums[3].to_i

no_pass = n * a

if n / m == 0
    pass = n / m * b
else
    buff1 = (n / m) * b + b
    buff2 = (n / m) * b + (n % m) * a

    buff1 > buff2 ? pass = buff2 : pass = buff1
end

no_pass > pass ? result = pass : result = no_pass

puts result


x, y, z, d= gets.split.map(&:to_i)
puts [n*a,n/m*b+n%m*a, (n/m+1)*b].min


class Integer
  N_BYTES = [42].pack('i').size
  N_BITS = N_BYTES * 16
  MAX = 2 ** (N_BITS - 2) - 1
  MIN = -MAX - 1
end
n, m, a, b = gets.split.map(&:to_i)
min = Integer::MAX
for i in 0..n
    x = (b*i)+(a*(n-(m*i)).abs)
    if x < min
      min = x
    end
end
p min


r1, c1, r2, c2 = gets.split.collect{|i| i.to_i}
if r1==r2 and c1==c2
    rook = 0
elsif r1==r2 or c1==c2
    rook = 1
else
    rook = 2
end
if (r1+c1)%2 != (r2+c2)%2
    bishop = 0
elsif (r1+c1)==(r2+c2) or (r1-c1).abs==(r2-c2).abs
    bishop = 1
else
    bishop = 2
end
king = [(r1-r2).abs,(c1-c2).abs].max
puts [rook,bishop,king].join(" ")


r1, c1, r2, c2 = gets.split.collect{|i| i.to_i}
if r1==r2 and c1==c2
    rook = 0
elsif r1==r2 or c1==c2
    rook = 1
else
    rook = 2
end
if (r1+c1)%2 != (r2+c2)%2
    bishop = 0
elsif r1+c1==r2+c2 or r1-c2==r2-c1
    bishop = 1
else
    bishop = 2
end
king = [(r1-r2).abs,(c1-c2).abs].max
puts [rook,bishop,king].join(" ")


require 'set'

def check n
  set=Set.new
  while set.size<=2 && n>0
    set<<n%10
    n/=10
  end

  set.size<=2
end

n=gets.to_i

count=0

(1..n).each{|i|
  count+=1 if check i
}

puts count


input_words = gets.chomp
hello_str = {'h' => 0 ,'e' => 0 ,'l1' => 0 ,'l2' => 0 ,'o' => 0 }
hello_str['h'] = input_words.index('h')
hello_str['e'] = input_words.index('e')
hello_str['l1'] = input_words.index('l')
hello_str['l2'] = input_words.index('l',hello_str['l1']+1)
hello_str['o'] = input_words.index('o')

if hello_str['h'] < hello_str['e'] && hello_str['e'] <  hello_str['l1'] && hello_str['l1'] <  hello_str['l2'] && hello_str['l2'] <  hello_str['o'] then
    print 'YES'
elsif
    print 'NO'
end


input_words = gets.chomp
hello_str = {'h' => 0 ,'e' => 0 ,'l1' => 0 ,'l2' => 0 ,'o' => 0 }
hello_str['h'] = input_words.index('h')
hello_str['e'] = input_words.index('e', hello_str['h']+1)
hello_str['l1'] = input_words.index('l', hello_str['e']+1)
hello_str['l2'] = input_words.index('l',hello_str['l1']+1)
hello_str['o'] = input_words.index('o', hello_str['l2']+1)

if hello_str['h'] < hello_str['e'] && hello_str['e'] <  hello_str['l1'] && hello_str['l1'] <  hello_str['l2'] && hello_str['l2'] <  hello_str['o'] then
    print 'YES'
elsif
    print 'NO'
end


print gets.strip =~ /.h+e+l+o+./ ? :YES : :NO


n, res = gets.to_i, 0
h = {}
a = (1..n).to_a
c = (1..n).to_a.combination(2).each do |x, y|
  h[[x, y]] = x^y
end
h.each do |k, v|
  res +=1 if v <= n && v > k.max && v < k[0]+k[1]
end
puts res


def fact(x)
  fact = 1
  x.times do |el|
    fact *= (el + 1)
    #fact %= (10**9 + 7)
  end
  fact
end

def fact_mod(x)
  fact = 1
  x.times do |el|
    fact *= (el + 1)
    fact %= (10**9 + 7)
  end
  fact
end

def fc(n, k)
  fact(n)/(fact(n - k)) # % (10**9 + 7)
end

n, x, pos = gets.chomp.split(' ').map(&:to_i)
less = -1
greater = 0
left = 0
right = n
arr = (1..n).to_a
while left < right
  middle = (left + right) / 2
  if arr[middle] <= pos + 1
    less += 1
    left = middle + 1
  else
    greater += 1
    right = middle
  end
end
gr_count = n - x
ls_count = n - gr_count - 1
fixed = n - less - greater - 1
puts (fact(fixed) * fc(gr_count, greater) * fc(ls_count, less)) % (10**9 + 7)


n = gets.to_i

k = 2
s = 0
(n-1).times do
   s += k*3
   k *= 2
end

puts n == 1 ? 2 : s


input = gets.split(" ")
input = input.sort

total_dist = 0

for i in 1..input.length-1
	total_dist = total_dist + (input[i].to_i - input[i-1].to_i)
end

puts total_dist


a, b, c = gets.split.map(&:to_i)
g = (a + b + c) / 3
p (a - g).abs + (b - g).abs + (c - g).abs


input = gets.chomp.split(' ').map(&:to_i)

sum = input.reduce(:+)
sum /= 3
ans = 0

input.each do |i|
	ans += (sum - i).abs
end

puts ans


n = gets.chomp
s = gets.chomp
arr = s.split('')
def process(arr)
	res = 0
	while !arr.empty?
		tmp = arr.pop
		arr_tmp = []
		arr_tmp.push(tmp)
		i = arr.length-1
		while i >= 0
			arr_tmp.push(arr[i])
			u = 0
			r = 0
			d = 0
			l = 0
			arr_tmp.each{ |e|
				if e == 'U'; u += 1;break; end
				if e == 'R'; r += 1;break; end
				if e == 'D'; d += 1;break; end
				if e == 'L'; l += 1;break; end
			}
			res += 1 if u == d && r == l
			i -= 1
		end
	end
	puts res

end
process(arr)


n = gets.to_i
s = gets.strip

def mv(l)
  case l
  when 'U' then [0, 1]
  when 'R' then [1, 0]
  when 'L' then [-1, 0]
  when 'D' then [0, -1]
  end
end

ct = 0

for i in 0...s.size
  x, y = mv(s[i])
  for j in 1...s.size
    dx, dy = mv(s[j])
    x += dx
    y += dy
    if x==0 && y==0
      ct+=1
    end
  end
end

puts ct


if gets.to_i%2==0 then puts "YES"
else
    puts "NO"
end


a = gets.to_i

if (a % 2) == 0 || a == 2
  puts "YES"
else
  puts "NO"
end


    w = gets.to_i
    (w%2 == 0 and w >= 2)? puts 'YES' : puts 'NO'


  w = gets.to_i
  (w%2 == 0 and w >= 2)?(puts "YES"):(puts "NO")


w = gets.to_i
if w % 2 == 0 then print "YES\n"
else print "NO\n"
end


w = gets.to_i

if w.odd?
	puts 'NO'
else
	puts 'YES'
end


ARGV.each_with_index do |arg, i|
    num1 = Integer(arg)
    if num1>3 && num1%2==0
        puts 'YES'
    else
        puts 'NO'
    end
end


n = Integer(gets())
if n.odd? then
    puts "NO"
    exit 0
end

a = b = n/2

if a.even? && b.even? then
    puts "YES"
    exit 0
end
a--
b++
if a <= 0:
    puts "NO"
    exit 0
end
if a.even? && b.even? then
    puts "YES"
    exit 0
end
puts "NO"


n = Integer(gets())
if n.odd? then
    puts "NO"
    exit 0
end

a = b = n/2

if a.even? && b.even? then
    puts "YES"
    exit 0
end
a--
b++
if a <= 0 then
    puts "NO"
    exit 0
end
if a.even? && b.even? then
    puts "YES"
    exit 0
end
puts "NO"


watermelon_weight = gets.to_i

if watermelon_weight >= 1 && watermelon_weight <= 100
if watermelon_weight%2 == 0
  puts "Yes"
else
  puts "No"
end
end


if gets.to_i % 2 == 0
  puts "YES"
else
  puts "NO"
end


a = gets.to_i
if a%2!=0 && a>2
  puts "NO"
 else
  puts "YES"
end


w = gets.chomp.to_i
p,b = w/2, w/2
(p.even? && b.even?) ? (puts "YES") : (puts "NO")


w = gets.chomp.to_i
if w.odd? || w == 2
	puts "NO"
else
	(puts "YES") : (puts "NO")
end


input = gets.to_i

count = 0
while input % 2 == 0 && count < 3 do
  count += 1
  input /= 2
end

if count >= 2
  puts "YES"
else
  puts "NO"
end


def water
    a=gets.chomp
    if a.to_i!=2 && a.to_i%2==0
        print"YES"
    else
        print"NO"
    end
end


w = gets.to_i

puts w % 2 == 1 ? 'NO' : 'YES'


if gets.chomp.to_i % 2 == 0
    puts "YES"
else
    puts "NO"
end


w = Integer(STDIN.gets)
raise "input error." unless (1...100).include?(w)

if w == 2
  puts "NO"
else
  if w % 2 == 0
    puts "YES"
  else
    puts "NO"
  end
end


w = gets.to_i

if w % 2 == 0 || w == 2 then
    print "YES"
else
    print "NO"
end


#!/usr/bin/env ruby
inp = gets
puts inp.to_i % 2 == 0 ? 'YES' : 'NO'


p, d = gets.split.map(&:to_i)
st = 1
st += 1 while p%10**st + 1 <= d
st -= 1
down = p%(10**st) + (st == 0 ? 0 : 1)
puts p - down


def count(n)
    c = 0
    while n%10==9
        c+=1
        n/=10
    end
    return c
end

p,d = gets.chomp.split.map(&:to_i)
c = p
max = count(p)
div = 1
ans = c
while p - c <= d
    ans = c if(count(c)>max)
    div = div * 10
    c = (c/div)*div - 1
end
puts ans


p, d = gets.chomp.split(' ')
d = d.to_i
pointer = p.length - 1
ans = p.to_i

loop do
  alen = ans.to_s.length
  if (p[pointer].to_i != 9)
    number_to_minus = (ans.to_s[pointer].to_i + 1) * (10 ** (alen - 1 - pointer))
    if (number_to_minus <= d)
      d -= number_to_minus
      ans -= number_to_minus
    else
      break
    end
  end
  pointer -= 1
  pointer -=1 if (alen != ans.to_s.length)
  break if (pointer <= 0)
end

puts ans


p, d = gets.chomp.split(' ')

d = d.to_i
pointer = p.length - 1
ans = p.to_i
end_i = 0

while (pointer >= end_i)
  if (p[pointer].to_i != 9)
    next_reduction_number = (ans.to_s[pointer].to_i + 1) * (10 ** (ans.length - 1 - pointer))
    if (next_reduction_number <= d)
      d -= next_reduction_number
      ans -= next_reduction_number
    else
      break
    end
  end
  pointer -= 1
  end_i = p.length - ans.to_s.length
end

puts ans


line = STDIN.gets
A = line.split(" ");
s = A[0].length
p = A[0].to_i
d = A[1].to_i
if( d == 0 )
    puts p
    exit(0)
end
res = 0
mod = 10
now = 9
s.times { |i|
  q = p
  r = q
  if( r >= now && d >= (r-now)%mod && q >= (r-now)%mod )
    res = q-(r-now)%mod
  end
  mod *= 10
  now *= 10
  now += 9
}
if( res == 0 )
    puts p-1
else
    print res,"\n"
end


line = STDIN.gets
A = line.split(" ");
s = A[0].length
p = A[0].to_i
d = A[1].to_i
if( d == 0 )
    exit(1)
end
res = 0
mod = 10
now = 9
s.times { |i|
  q = p
  r = q
  if( r >= now && d >= (r-now)%mod && q >= (r-now)%mod )
    res = q-(r-now)%mod
  end
  mod *= 10
  now *= 10
  now += 9
}
print res,"\n"


line = STDIN.gets
A = line.split(" ");
s = A[0].length
p = A[0].to_i
d = A[1].to_i
if( d == 0 )
    puts p
    exit(0)
end
res = 0
mod = 10
now = 9
s.times { |i|
  q = p
  r = q
  if( r >= now && d >= (r-now)%mod && q >= (r-now)%mod )
    res = q-(r-now)%mod
  end
  mod *= 10
  now *= 10
  now += 9
}
if( res == 0 ) puts p-1
else print res,"\n"
end


p,d = gets.split(" ").map(&:to_i)
# arr = []
l = p.to_s.length
ans = p
l.downto(1).each do |a|
	first = p / (10 ** (a)) - 1
	val = (first.to_s + ("9" * a)).to_i
	if val >= p - d
		ans = val
		break
	end
end

puts ans


def function
b=gets.chomp
a=gets.chomp
a=a.split(' ').map(&:to_i).sort.reverse
b=a.clone
1.upto a.length do |i|
if a[i]==a[i-1]
b[i]-=1
end
end
sum=0
b.each do |i|
sum+=i
end
puts sum
end
function


gets
a=gets.split.map &:to_i
h = {}
a.sort.each{|x|
  x -= 1 while h[x]
  h[x] = true
}
if h[-1]
  p 0
else
  p h.map{|k,v|k}.inject :+
end


n = gets.to_i
a = gets.split(' ').map &:to_i
r = []
broken = false
for v in a
  while r.index(v)
    v-=1
  end
  if v >= 0
    r << v
  else
    r = [0]
    break
  end
end

puts r.inject(&:+)


a = gets.to_i
if a == 2
  puts "YES"
 elsif a.even?
  puts "YES"
else
  puts "NO"
end


w = gets.chomp.to_i
puts  w / 2.0 % 2 == 0 ? "YES" : "NO"


a = gets.to_i
puts (a % 2) == 0 ? "Yes" : "No"


#!/usr/bin/env ruby
n  = gets.chomp.to_i
var = n % 2
if (var).zero?
  puts ((n - 2)%2).zero? ? "YES" : "NO"

else
  puts "NO"
end


a = gets.chomp

if a / 2 == 0
  puts "YES"
else
  puts "NO"
end


a = gets.to_i

if a % 2 == 0
  puts "YES"
else
  puts "NO"
end


w=gets.chomp

if(w==2 or w%2==1)
	puts 'no'
else
	puts 'yes'
end


w = gets

if w==2
   puts "NO"
elsif w%2==0
     puts "YES"
else
	puts "NO"
end


#!/usr/bin/ruby
puts gets.to_i%2 == 0? :YES: :NO


w = gets.to_i

puts  w.even? and w > 2 ? 'YES' : 'NO'


input = STDIN.gets.chomp.to_i

puts 'YES' if input > 2 && input % 2 == 0


n = gets.chomp.to_i
p n % 2 == 0 && n != 2 ? "YES" : "NO"


a=gets.chomp.to_i

if a%2==0
puts "YES"
else
puts "NO"
end


def watermelon(n)
    return "NO" if n < 3
    n % 2 == 0 ? "YES" : "NO"
end

n = gets.chomp
watermelon(n.to_i)


def watermelon(n)
    return "NO" if n < 3
    n % 2 == 0 ? "YES" : "NO"
end

n = ARGV[0]
puts watermelon(n.to_i)


#!/usr/bin/env ruby

w = $stdin.gets
w = $_.strip.to_i
if w.to_i % 2 == 0
  print 'YES'
else
  print 'NO'
end


x = gets.to_i

y = x/2
z = x - y

if (x <= 100) and x > 0
    if ((y % 2 == 0) and (z % 2 == 0)) or (((x-2) % 2 == 0) and (x != 0))
        puts "yes"
    else
        puts "no"
    end
else
    puts "not applicable"
end


a = gets.to_i

if (a % 4 == 0)
	p "YES"
else
	p "NO"


a = gets.to_i

if (a % 4 == 0)
	p "YES"
else
	p "NO"
end


n = gets.split.map(&:to_f)
if n.even? then
  return "YES"
else
  return "NO"
end


n = gets.split.map(&:to_i)
n = n[0]
if n % 2 == 0 then
  print "YES"
else
  print "NO"
end


n=gets.to_i
if n%4==0 then
puts "YES"
else
puts "NO"
end


n=gets.to_i
if n%2!=0 then
puts "NO"
elseif n<=2
puts "NO"
else
puts "YES"
end


x = gets
if(x%2==0)
puts "YES"
else
puts "NO"
end


message = gets.chomp
if(message=~/^.*?h+?e+?l{2,}?o+?$/)
    puts("YES")
else
    puts("NO")
end


st = gets.chomp
s = st.split("").uniq
s = s.join
if (s.include? "helo") && (st.index("l") != st.rindex("l")) then
    puts "YES"
else
    puts "NO"
end


s = gets.chomp
if s.length == 5
	puts s =~ /hello/ ? "YES" : "NO"
else
	puts  s =~ /h+[\w]*e+[\w]*l+[\w]*o+/ ? "YES" : "NO"
end


def main()
  s = gets.chomp
  hello = ["h","e","l","l","o"]
  x = 0
  for i in 0..s.length-1
    if s[i] == hello[x]
      x+=1
    end
  end
  if x == 5
    print "Yes"
  else
    print "NO"
  end
end

main


typed_word = gets.strip

hello_word = 'hello'

index = 0
state = false
typed_word.each_char do |char|
  if hello_word[index].eql?(nil)
    state = true
    break
  end

  index += 1 if hello_word[index].eql?(char)
end

if state.eql?(true)
  puts 'YES'
else
  puts 'NO'
end


s = gets
puts (s.count('h') >= 1 and s.count('e') >= 1 and s.count('l') >= 2 and s.count('o') ? "YES" : "NO")


s = gets.chomp

s.gsub!(/[^helo]/, '')
s.gsub!(/hh*/, 'h')
s.gsub!(/ee*/, 'e')
s.gsub!(/lll*/, 'll')
s.gsub!(/oo*/, 'o')
puts (s=='hello' ? "YES" : "NO")


require_relative 'emaxx'

s = $stdin.readline
t = s.scan(/./).complect_and_count!
tt = t.collect {|x| x[:sym] }.join('')

k = tt=~/helou/
puts (k && t[k+2][:count]>=2) ? "YES" : "NO"


s = $stdin.readline

puts (s=~/h.*e.*l.*l.*o.*u/) ? "YES" : "NO"


unless (gets.chomp.match /h+e+l{2,}o+/).nil? then puts "YES" else puts "NO" end


okay = gets.chomp =~ /^.*h{1,}e{1,}l{1,}l{1,}o{1,}.*$/
if okay
  puts "YES"
else
  puts "NO"
end


ans=0
i=-1
inp=gets.chomp.delete "^helo"
p inp

while i<inp.length
	i+=1
	if inp[i]=='h' then
		ans+=1
		break
	end
end

while i<inp.length
	i+=1
	if inp[i]=='e' then
		ans+=1
		break
	end
end

while i<inp.length
	i+=1
	if inp[i]=='l' then
		ans+=1
		break
	end
end

while i<inp.length
	i+=1
	if inp[i]=='l' then
		ans+=1
		break
	end
end

while i<inp.length
	i+=1
	if inp[i]=='o' then
		ans+=1
		break
	end
end

puts (ans==5 ? 'YES' : 'NO')


p gets.scan(/h.*e.*l.*l.*o/).length > 0 ? "YES" : "NO"


word = gets.chomp

a = Array.new
for i in 0...word.length
    a[i] = word[i]
end

b = Array.new
b[0] = a[0]
for i in 0...a.length - 1
    if a[i+1] != a[i]
        b.push(a[i+1])
    end
end

x = 0
for i in 0...a.length - 2
    if a[i] == "e" && a[i+1] == "l" && a[i+2] == "l"
       for j in 0...b.length - 3
           if b[j] =="h" && b[j+1] == "e" && b[j+2] == "l" && b[j+3] == "o"
            x = 1
           end
       end
   end
   if x == 1
    break
   end
end

if x ==1
    puts "YES"
else
    puts "NO"
end


puts (gets.downcase.include?("hello") ? "YES" : "NO")


gets.to_i
nums = gets.split(' ').map(&:to_i)

all = 0
maximum = 0
(0...nums_orig.length).each do |i|
  (i...nums_orig.length).each do |j|

    nums = nums_orig.dup
    (0..nums.length).each do |ind|
      if ind >= i && ind <= j
        nums[ind] = (nums[ind] - 1).abs
      end
    end

    current,all =0,0
    (0..nums.length).each do |ind|
      if nums[ind] == 1
        current += 1
      else
        all = current if current > all
        current = 0
      end
    end

    maximum = all if all > maximum
    all = 0
  end
end

puts maximum


gets.to_i
nums_orig = gets.split(' ').map(&:to_i)

all = 0
maximum = 0
(0...nums_orig.length).each do |i|
  (i...nums_orig.length).each do |j|

    nums = nums_orig.dup
    (0..nums.length).each do |ind|
      if ind >= i && ind <= j
        nums[ind] = (nums[ind] - 1).abs
      end
    end

    current,all =0,0
    (0..nums.length).each do |ind|
      if nums[ind] == 1
        current += 1
      else
        all = current if current > all
        current = 0
      end
    end

    maximum = all if all > maximum
    all = 0
  end
end

puts maximum


#!/usr/bin/ruby

def countOnes(array,n)

	count_1 = 0

	for i in (0..n-1)
		if array[i] == 1 then
			count_1 += 1
		end
	end

	for i in (0..n-1)
		array[i] = (array[i] == 1) ? -1 : 1
	end

	max_ending_here, max_overall = 0 , 0

	for i in (0..n-1)
		max_ending_here += array[i]

		if max_ending_here < 0 then
			max_ending_here = 0
		end

		if max_ending_here > max_overall
			max_overall = max_ending_here
		end
	end

	return max_overall + count_1
end

n = gets.strip.to_i

s = gets

a = s.split.map(&:to_i)

puts countOnes a,n


$mem =  Array.new(102){Array.new(2,-100000)}
$number = Array.new(102)

def dp(idx , bool , n)
    if idx == n
		return 0
	end
	ret = $mem[idx][bool]
	if ret != -100000
		return ret
	end
	if bool == 1
		ret = [dp(idx+1,1,n)+$number[idx] , 0].max
	else
		ret = [dp(idx+1,0,n) , dp(idx+1,1,n)+$number[idx]].max
	end

	$mem[idx][bool] = ret
	return ret
end

leng = Integer(gets)
sum = 0
$number = gets.split.collect {|element| element.to_i}
$number.each{|x| sum += (x==1?1:0)}
for i in 0...leng do
	$number[i] = ($number[i]==1?-1:1)
end
puts "#{sum+dp(0,0,leng)}"


def dp(idx , bool)
    if idx == $n
		return 0
	end
	ret = $mem[idx][bool]
	if ret != -100000
		return ret
	end
	if bool == 1
		ret = [dp(idx+1,1)+$number[idx] , 0].max
	else
		ret = [dp(idx+1,0) , dp(idx+1,1)+$number[idx]].max
	end

	$mem[idx][bool] = ret
	return ret
end

$mem =  Array.new(102){Array.new(2,-100000)}
$n = gets.to_i
$number = gets.split.collect {|element| element.to_i}
sum = 0
$number.each{|x| sum += (x==1?1:0)}
for i in 0...$n do
	$number[i] = ($number[i]==1?-1:1)
end
puts "#{sum+dp(0,0)}"


def dp(idx , bool)
    if idx == $n
		return 0
	end
	ret = $mem[idx][bool]
	if ret != -100000
		return ret
	end
	if bool == 1
		ret = [dp(idx+1,1)+$number[idx] , 0].max
	else
		ret = [dp(idx+1,0) , dp(idx+1,1)+$number[idx]].max
	end

	$mem[idx][bool] = ret
	return ret
end

$mem =  Array.new(102){Array.new(2,-100000)}
$n = gets.to_i
$number = gets.split.collect {|element| element.to_i}
sum = 0
$number.each{|x| sum += (x==1?1:0)}
for i in 0...$n do
	$number[i] = ($number[i]==1?-1:1)
end
if sum == $n
   puts sum-1
else
   puts "#{sum+dp(0,0,leng)}"
end
puts "#{sum+dp(0,0)}"


n = gets.strip.to_i
coins = gets.strip.split(" ").map(&:to_i)
original_before_ones = 0
original_ones = coins.count(1)
original_after_ones = original_ones
max_ones = 0
current_ones = 0
prev_ones = 0
if coins[0] == 0 then
  prev_ones = 1
else
  prev_ones = 0
  original_after_ones -= 1
  original_before_ones += 1
end
max_ones = [prev_ones, original_before_ones].max
i = 1
# puts max_ones
# puts original_before_ones
# puts original_after_ones
while i < n do
  if coins[i] == 0 then
    current_ones = [original_before_ones + 1 + original_after_ones, prev_ones + 1].max
  else
    current_ones = [original_ones - 1, prev_ones - 1].max
    original_before_ones += 1
    original_after_ones -= 1
  end
  max_ones = [max_ones, current_ones].max
  prev_ones = current_ones
  # puts max_ones
  i += 1
end
puts max_ones


n = gets.strip.to_i
coins = gets.strip.split(" ").map(&:to_i)
current_max_ones = 0
number_of_flipped_element = 0
i = 0
current_flipped_ones = 0
number_of_ones = coins.count(1)
i0 = 0
j0 = 0
# p coins
number_of_ones_before = 0
number_of_ones_after = number_of_ones
while i < n do
  # puts i
  if coins[i] == 0 then
    if current_flipped_ones == 0 then
      i0 = i
      number_of_ones_before = coins[0..i0].count(1)
      # number_of_ones_after = number_of_ones - number_of_ones_before
    end
    current_flipped_ones += 1
    # puts "number_of_ones_before: #{number_of_ones_before}, number_of_ones_after: #{number_of_ones_after},
    #   current_flipped_ones: #{current_flipped_ones}"
    current_max_ones = current_max_ones >= number_of_ones_before + current_flipped_ones + number_of_ones_after ?
        current_max_ones : number_of_ones_before + current_flipped_ones + number_of_ones_after
  else
    if current_flipped_ones == 0 then
      number_of_ones_before += 1
      # puts "here"
      # puts i
    end
      # current_flipped_ones -= 1
      number_of_ones_after -= 1
      current_max_ones = current_max_ones >= number_of_ones_before + current_flipped_ones + number_of_ones_after ?
        current_max_ones : number_of_ones_before + current_flipped_ones + number_of_ones_after
      if current_flipped_ones == i - i0 + 1 - current_flipped_ones then
        current_flipped_ones = 0
      end
  end
  # puts "#{i} iteration: current_max_ones: #{current_max_ones}"
  i += 1
end
# puts "something"
# number_of_flipped_element = number_of_flipped_element == 0 ? 1 : number_of_flipped_element
# puts number_of_flipped_element
# puts current_max_flipped_ones
puts current_max_ones
# puts coins.count(1) - (number_of_flipped_element - current_max_flipped_ones) + current_max_flipped_ones


def run
  n = $stdin.readline.to_i
  a = $stdin.readline.split(" ").map(&:to_i)

  sum = a.reduce(&:+)
  max_zeros = 0
  for i in 0..n
    for j in i..n
      max_zeros = [a[i..j].count(1), max_zeros].max
    end
  end

  puts sum + max_zeros
end

run if $0 == __FILE__


gets
arr = gets.chomp.split.join("")
max = 0
arr.scan(/0+/) { |x| max = x.length if x.length > max }
puts arr.split("").count { |x| x == "1" } + max


gets
a = gets.split(' ').map(&:to_i)
cur1 = 0
cur0 = 0
best = 0
s = 0
for x in a
  s += x
end
for x in a
  if x==0
    cur0 += 1
  else
    if cur1 == cur0
      cur1 = cur0 = 0
    else
      cur1 += 1
    end
  end
  best = [best,cur0-cur1+s-cur1].max
end
if best == s
  best -= 1
end
print best


gets
x = gets.split.map(&:to_i)
a = []
c = 1
r = x[0]
for i in 1...x.size
	r += x[i]
	if x[i] == x[i - 1]
		c += 1
	else
		a<<c
		c = 1
	end
end
a<<c
a<<0
a<<0
a<<0
d = 0
i = x.first
while i < a.size - 3
	if a[i] >= a[ i + 1] and a[i + 1] <= a[i + 2]
		a[i + 2] += a[i]
		a[i + 2] -= a[i+1]
	end
	d = [a[i] , d].max
	i += 2
end
if a.size == 4 and x.first == 1
	puts r - 1
else
	puts r + d
end


n = gets.chomp.to_i
input = gets.chomp.split(' ').map { |i| i.to_i}
bits = input.clone
bits.each_with_index { |bit,index|
  if bit.eql? 1
    bits[index] = -1
  else
    bits[index] = 1
  end
}
currentMax = bits[0]
maxEndingHere = bits[0]
start = 0
startTemp = 0
last = 0
bits.each_with_index { |bit,i|

  if maxEndingHere < 0
    maxEndingHere = bit
    startTemp = i
  else
    maxEndingHere += bit
  end

  if maxEndingHere >= currentMax
    currentMax = maxEndingHere
    start = startTemp
    last = i
  end
}

for i in start..last
  input[i] = (input[i] + 1) % 2
end

p input.count 1


n = Integer(gets)
input = gets.chomp
nums = input.split
number = Array.new
number1 = Array.new

for i in 0...n
    number[i] = number1[i] = Integer(nums[i])
end

def sum(a)
    x = 0
    for i in 0...a.length
        x += a[i]
    end
    return x
end
def restore(number1,number)
    for i in 0...number.length
        number1[i] = number[i]
    end
end

c = 0
for i in 0...n
    for j in i...n
        for x in i..j
            if number[x] == 1
                number1[x] = 0
            else
                number1[x] = 1
            end
        end
        if sum(number1) > c
            c = sum(number1)
        end
        restore(number1,number)
    end
end
if n == 1 && number[0] == 1
    puts 0
else

    if c > sum(number)
        puts c
    else
        puts sum(number)
    end
end


def solution(arr)
  if arr.size == 1
    return 1 if arr[0] == 0
    return 0 if arr[0] == 1
  end

  initial_value = arr.reduce(:+)
  return initial_value - 1 if initial_value == arr.size

  acumulator = initial_value
  max_value = 0

  for i in 0...arr.size do
    acumulator = [initial_value, acumulator + (arr[i] == 1 ? -1 : 1)].max
    max_value = [max_value, acumulator].max
  end
  max_value
end

puts solution(gets.split.map(&:to_i))


gets
n = gets.chomp.split(/ /).map { |x| x.to_i }
sum = 0
max = 0
ones = 0
n.each do |x|
  if x == 1
    ones += 1
    sum -= 1
  else
    sum += 1
  end
  sum = 0 if sum < 0
  max = sum if max < sum
end
puts "#{max + ones}"


def flip_sum(t,i,e)
    t[i..e] = t[i..e].map { |v|  v = 1 - v }
    return t.inject(0){|sum,x| sum + x}
end

def get_result(b, e, dpa)
    best = dpa[[0,e-1].max]
    for i in 0..e
        ans = flip_sum(b.clone,i,e)
        best = ans if ans > best
    end
    return best
end

# Read Input
n = gets.strip.to_i
b = gets.strip.split.map{|s| s.to_i}

# Initialize params
dpa = Array.new(n,0)

for i in 0..n do
    dpa[i] = get_result(b, i, dpa)
end

puts dpa.max


n = gets.to_i
a = gets.split(' ').map(&:to_i)

x = -100000
1.upto(n) do |i|
  i.upto(n) do |j|
    x = [x, a[i, j-i+1].count(0)-a[i, j-i+1].count(1)].max
  end
end

puts a.count(1) + x


def find_max(a)
  max_ending_here = max_so_far = 0
  a.each { |x|
    max_ending_here = [0, max_ending_here + x].max
    max_so_far = [max_so_far, max_ending_here].max
  }
  max_so_far
end

gets.chomp # Skip the first line
seq = gets.chomp.split.map { |x| x.to_i }
puts seq.inject(:+) + find_max(seq.map { |s| s == 1 ? -1 : 1 })


def is_lucky(s)
        while s>0
                return false if s%10!=7 && s%10!=4
                s/=10
        end
        return true
end
def fact(k)
        return 1 if k<=0
        return fact(k-1)*k
end
def lucky(now)
        res=[]
        return [] if now>1000000000
        return [now]+lucky(now*10+4)+lucky(now*10+7)
end
n,k=gets.split.map(&:to_i)
k-=1
remain=[]

def solve(n,remain,k)
        return [] if n==0
        n.times{|i|
                if k<fact(n-1)*(i+1) then
                        ans=[remain[i]]
                        remain.delete_at(i)
                        ans+=solve(n-1,remain,k-fact(n-1)*i)
                        return ans
                end
        }
end
if n<=30 then
        n.times{|i|
                remain.push(i+1)
        }
        res=solve(n,remain,k)
        ans=0
        n.times{|i|
                ans+=1 if is_lucky(i+1) && is_lucky(res[i])
        }
        p ans
else
        (n-29).upto(n){|i|
                remain.push(i)
        }
        res=solve(30,remain,k)
        ans=0
        (n-29).upto(n){|i|
                ans+=1 if is_lucky(res[i-n+29]) && is_lucky(i)
        }
        lucky_number=lucky(0)
        lucky_number.shift
        lucky_number.each{|i|
                ans+=1 if i<n-29
        }
        p ans
end


n = gets.chomp.to_i
print [1, 2 * (n - 1)].max


gets
a,b=$<.map{|e|e.split}
puts (a&b).empty? ? a.min+b.min : (a&b).min


class Solver1
  def self.solve(arr)
    l1 = arr[0]
    l2 = arr[1]
    uniq = l2 & l1
    return uniq.min if uniq.size > 0
    min1 = l1.min
    min2 = l2.min
    return [(min2.to_s + min1.to_s).to_i, (min1.to_s + min2.to_s).to_i].min
  end
end
string = ARGF.read
arr = string.split('\n')
arr.map! { |elem| elem.strip }
arr1 = arr.drop(1)
arr1.map! { |elem| elem.split }
puts Solver1.solve(arr1)
exit(true)


#! /usr/bin/env ruby

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

if not c.empty?
    puts c.min
else
    puts [a.min, b.min].sort.join
end


sin = STDIN
sout = STDOUT
# sin = File.open("test.in", "r")
# sout = File.open("test.out", "w")

n, k, l, c, d, p, nl, np = *sin.readline.split.map{|e| e.to_i}

l *= k
c *= d

ans = 0

while l > 0 && c > 0 && p > 0
    ans += 1
    l -= nl * n
    c -= n
    p -= np * n
end

sout.puts ans - 1


puts (gets.chomp+gets.chomp).chars.sort==(gets.chomp).chars.sort ? :YES :"NO"


n, k, l, c, d, p, nl, np = gets.chomp.split(/ /).map(&:to_i)
total_drink = k * l
total_toasts = total_drink / n
total_dimes = c * d
total_share_of_salt = p / np
ans = [total_toasts, total_dimes, total_share_of_salt].min / n
puts ans


n, k, l, c, d, p, nl, np = gets.split.map &:to_i
drinkm, slices, c = k * l, c * d, 0

loop do
  n.times { |i| drinkm -= nl; slices -= 1; p -= np }
  break unless [drinkm, slices, p].select { |e| e <= 0 }.empty?
  c += 1
end

print c


a = gets.split
l = a[0].to_i; r = a[1].to_i;
count = l==0?1:0
now = 3
for i in 2..18
    for j in 0..i-2
        t = now^(1<<j)
        count += (t>=l && t<=r) ? 1:0
    end
    now = now<<1|1

end
print count


a,b=gets.split.map(&:to_i)
ans=0
1.upto(64){|k|
	n=2**k-1
	next unless a<=n&&n<=b
	0.upto(k-1){|s|
		m=n^(1<<s)
		if a<=m&&m<=b
			ans+=1
		end
	}

}

puts ans


#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0]
  y << point[-1][1]
end
if x.uniq!.size == 3 && y.uniq!.size == 3
  if point.include? [x.sort[1], y.sort[1]]
    puts "ugly"
  else
    puts "respectable"
  end
else
  puts "ugly"
end


#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0] unless x.include? point[-1][0]
  y << point[-1][1] unless y.include? point[-1][1]
end
if x.size == 3 && y.size == 3
  ok = true
  for i in 0...3
    for j in 0...3
      next if i == 1 && j == 1
      ok = false unless point.include?([x[i], y[j]])
    end
  end
  puts ok ? "respectable" : "ugly"
else
  puts "ugly"
end


#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0] unless x.include? point[-1][0]
  y << point[-1][1] unless y.include? point[-1][1]
end
if x.size == 3 && y.size == 3
  ok = true
  for i in 0...3
    for j in 0...3
      next if i == 1 && j == 1
      ok = false unless point.include?([x[i], y[j]])
    end
  end
  puts ok? "respectable" : "ugly"
else
  puts "ugly"
end


#!/usr/bin/env ruby
point,x, y = [], [], []
8.times do
  point << gets.split(' ').map(&:to_i)
  x << point[-1][0] unless x.include? point[-1][0]
  y << point[-1][1] unless y.include? point[-1][1]
end
if x.sort!.size == 3 && y.sort!.size == 3
  if point.uniq.size == point.size && point.include?([x[1], y[1]])
    puts "respectable"
  else
    puts "ugly"
  end
else
  puts "ugly"
end


points =[]
for i in 1..8
 temp=gets.chomp.split.collect{|a| a.to_i}
 points.push temp
end
xs=points.collect{|a| a.first}.sort.uniq
ys=points.collect{|a| a.last }.sort.uniq
#puts xs,ys
if xs.length!=3 ||ys.length!=3 || points.uniq !=8
   puts "ugly"
else
  avg=[xs[1],ys[1]]
 # puts avg
  if points.include? avg
     puts "ugly"
  else
      puts"respectable"
  end
end


xy = []
8.times do
  x,y = gets.split(' ').map(&:to_i)
  xy << [x,y]
end

xs,ys = xy.transpose
xxs = xs.sort.uniq
yys = ys.sort.uniq

ok = true
xxs.each.with_index do |x,i|
  if xs.count(x) != (i == 1 ? 2 : 3)
    ok = false
    break;
  end
end

yys.each.with_index do |y,i|
  if ys.count(y) != (i == 1 ? 2 : 3)
    ok = false
    break;
  end
end if ok

if !ok || xxs.size != 3 || yys.size != 3 || xy.include?([xxs[1], yys[1]])
  puts "ugly"
else
  puts "respectable"
end


def runb(list)
  x = list.map{|x,y| x}.uniq.sort
  y = list.map{|x,y| y}.uniq.sort

  return false unless x.size == 3
  return false unless y.size == 3
  return false if list.member?([x[1],y[1]])
  return true
end

def run(list)
  runb(list) ? "respectable" : "ugly"
end

def convert(n)
  n.split(' ').map(&:to_i)
end

n = gets
list = []
while n != nil
  list << convert(n)
  if list.size == 8
    puts run(list)
    list = []
  end
  n = gets
end


# http://codeforces.com/problemset/problem/334/B

list_x = []
list_y = []
8.times do
  pair = gets.chomp.split
  list_x << pair[0].to_i
  list_y << pair[1].to_i
end

list_x = list_x.sort
list_y = list_y.sort

avg_x, avg_y = 0, 0

for i in 0..7
  avg_x += 1 if list_x[i] == list_x[3]
  avg_y += 1 if list_y[i] == list_y[3]
end

puts avg_x == 2 && avg_y == 2 ? "respectable" : "ugly"


# http://codeforces.com/problemset/problem/334/B
list = []
list_x = []
list_y = []
8.times do |i|
  list << gets.chomp.split.map(&:to_i)
  list_x << list[i][0]
  list_y << list[i][1]
end

def eight_point_set(list, list_x, list_y)
  hash = Hash.new { |hash, key| hash[key] = 0 }
  for i in 0..7
    hash[list[i]] += 0

    if hash[list[i]] > 1
      return "ugly"
    end
  end

  sorted_list_x = list_x.sort
  sorted_list_y = list_y.sort
  avg_x, avg_y = 0, 0

  for i in 0..7
    avg_x += 1 if sorted_list_x[i] == sorted_list_x[3]
    avg_y += 1 if sorted_list_y[i] == sorted_list_y[3]
  end

  return avg_x == 2 && avg_y == 2 ? "respectable" : "ugly"
end

puts eight_point_set(list, list_x, list_y)


require 'prime'
def find_minimum(row, col, factor, n)
  (0..n).collect {|i|
    [row * (factor**i), col * (factor**(n-i))]
  }.select{ |pair|
    pair[0] <= pair[1]
  }.min_by { |pair|
    pair[1] - pair[0]
  }
end

def minimum_pair(row, col, primes)
  if primes.size == 1
    return find_minimum(row, col, primes[0][0], primes[0][1])
  else
    prime = primes[0][0]
    n = primes[0][1]
    rest = primes[1..-1]
    minimum = 10000000
    minimum_result = nil
    (0..n).collect { |i|
      minimum_pair(row*(prime**i), col*(prime**(n-i)), rest)
    }.select{ |pair|
      pair[0] <= pair[1]
    }.min_by { |pair|
      pair[1] - pair[0]
    }
  end
end

def solve(n)
  primes = n.prime_division
  puts primes
  minimum_pair(1, 1, primes)
end

puts solve(STDIN.read.to_i).join(" ")


require 'prime'
def find_minimum(row, col, factor, n)
  res = (0..n).collect {|i|
    [row * (factor**i), col * (factor**(n-i))]
  }.select{ |pair|
    pair[0] <= pair[1]
  }.min_by { |pair|
    pair[1] - pair[0]
  }
  res.nil? ? [1, row*col*(factor**n)] : res
end

def minimum_pair(row, col, primes)
  if primes.size == 1
    return find_minimum(row, col, primes[0][0], primes[0][1])
  else
    prime = primes[0][0]
    n = primes[0][1]
    rest = primes[1..-1]
    minimum = 10000000
    minimum_result = nil
    (0..n).collect { |i|
      minimum_pair(row*(prime**i), col*(prime**(n-i)), rest)
    }.select{ |pair|
      pair[0] <= pair[1]
    }.min_by { |pair|
      pair[1] - pair[0]
    }
  end
end

def solve(n)
  primes = n.prime_division
  minimum_pair(1, 1, primes)
end

puts solve(STDIN.read.to_i).join(" ")


x= Integer(gets.chomp)

if (x%2==0)
  p "white"
  p'1 2'
else
  p'black'
end


n, c1, c2 = gets.split.map(&:to_i)
s = gets.chomp!
group = [0, 0]
n.times do |i|
  group[s[i].to_i] += 1
end

max = c1 + c2 * (n - 1) ** 2
tmp = 0

group[1].times do |i|
  tmp = (n / (i+1)).to_i * (c1 + c2 * i**2)
  tmp += c1 + c2 * ((n % (i+1)) - 1)**2 if n % (i+1) != 0
  max = tmp if max > tmp
end

puts max


n,f=gets.split.map{|e| e.to_i}
hs=Hash.new(0)
gets.chomp.chars.each{|e|
	hs[e]+=1
}
hs.each{|k,v|
	f-=(v/2).to_i
}
if f<=0 then
	puts "YES"
else
	puts "NO"
end


n,k=gets.split.map(&:to_i)
s = gets.chomp
h = Hash.new(0)
s.chars do |c|
    h[c] += 1
end

f = true
[*?a..?z].each do |c|
    if h[c] % 2 == 1
        f = false
        break
    end
end
puts f ? "YES" : "NO"


a = Array.new(123, gets.split[1].to_i)
gets.chars{|c| a[c.ord] -= 1}
p a.min < 0 ? 'NO' : 'YES'


a = gets.to_i

a=a+1

if a==1
    puts 0
elsif a%2
    puts a
else
    puts a/2
end


    n = gets.to_i
    if (n+1) % 2 == 0 and n != 0
        puts ((n+1)/2)
    elsif (n+1) % 2 != 0
        puts (n+1)
    elsif n == 0
        puts "0"
    end


#!/usr/bin/ruby1.9

n, k = STDIN.readline.split.collect {|s| s.to_i }

need = n-1
max = k-1

if (max+1)*max/2 < need
	puts -1
	exit
end

low, high = 1, max
while low < high
	mid = (low+high)/2
	sum = (mid+max)*(max-mid+1)/2
	if sum == need
		break
	elsif sum < need
		high = mid
	else
		low = mid+1
	end
end

mid = (low+high)/2
if (mid+max)*(max-mid+1)/2 >= need
	puts max-mid+1
else
	puts max-mid+2
end


class B
  def initialize
    n, k = $stdin.gets.chomp.split(' ').map(&:to_i)

    if k >= n
      puts 1
      exit
    end

    sum = 0
    count = 0

    (k-1).downto(1) do |val|
      count += 1
      if val == 1
        sum += 2
      else
        sum += val
      end

      if sum >= n
        puts count
        exit
      end
    end

    puts -1
  end
end

b = B.new


class B
  def initialize
    n, k = $stdin.gets.chomp.split(' ').map(&:to_i)

    if k >= n
      puts 1
      exit
    end

    left = 2
    right = k

    while(left < right)
      m = (left+right)/2

      if(m*(2*k-m-1)/2+1<n)
        left = m+1
      else
        right = m
      end
    end

    #p k*(k-1)/2-(right-2)*(right-1)/2 + 1

    if (right*(2*k-right-1)/2+1<n)
      puts -1
    else
      puts right
    end
  end
end

b = B.new


x1, y1, x2, y2 = gets.chomp.split.map &:to_i
x, y = gets.chomp.split.map &:to_i

m = (x1 - x2).abs
n = (y1 - y2).abs
h = m % 2
k = n % 2
if m % x == 0 && n % y == 0 && h % x == k % y
    puts "YES"
else
    puts "NO"
end


s = gets.chomp
ret = ""
idx = 0
while idx < s.length
	if idx != 0 && idx != s.length-3 && s.slice(idx,3) == "dot"
		ret += "."
		idx += 3
		next
	end
	if idx != 0 && idx != s.length-2 && s.slice(idx,2) == "at"
		ret += "@"
		idx += 2
		next
	end
	ret += s[idx]
	idx += 1
end
puts ret


str = gets.chomp

res = [str[0], str[1..-2].gsub(/at/,'@').gsub('dot', '.'), str[-1]].join

puts res


w = gets.chomp
h_a, l = false, w.length
ret = ""
i = 0
while i < l
  if w[i] == 'a' && i + 1 < l && w[i +1] == 't'
    if i == 0
      ret += "at"
      i += 2
    else
      if h_a
        ret += "at"
        i += 2
      else
        h_a = true
        ret += "@"
        i += 2
      end
    end
  elsif w[i] == 'd' && i + 1 < l && w[i + 1] == 'o' && i + 2 < l && w[i + 2] == 't'
    if i == 0
      ret += "dot"
      i += 3
    else
      ret += "."
      i += 3
    end
  else
    ret += w[i]
    i += 1
  end
end
puts ret


a,b,c = gets.split.map(&:to_i)
puts 7*([a,b/2,c/4].min)


# https://codeforces.com/problemset/problem/746/A
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
r = 0
s = 1
d = 2
f = 4
while s != a
  if (a >= s) && (b >= d) && (c >= f)
    r += 7
  end
  s += 1
  d += 2
  f += 4
end
p r


h=Hash.new(0)
gets
gets.chomp.chars{|c|c.to_i.prime_division.each{|n,p|h[n]+=p}}
puts '7'*h[7]+'5'*h[5]+'3'*h[3]+'2'*h[2]


def function
b=gets.chomp
a=gets.chomp
a=a.delete('0')
a=a.delete('1')
a=a.gsub('4' , '322')
a=a.gsub('6' , '53')
a=a.gsub('8' , '7222')
arr=[]
a.each_char do |i|
arr.push(i.to_i)
end
arr=arr.sort.reverse
arr.each do |i|
print i
end
end
function


a=gets.chomp.to_i
b=gets.chomp.split("").map{|i| i.to_i  }
c=[]
b.delete(1)
b.delete(0)
0.upto(b.length-1) do |i|
if b[i]==4
c<<3<<2<<2
elsif b[i]==6
c<<5<<3
elsif b[i]==8
c<<7<<2<<2<<2
elsif b[i]==9
c<<7<<3<<3<<2<<2
else c<<b[i]
end
end
c.sort!
c.reverse!
puts c.join("")


n=gets.chomp.to_i
s=gets.chomp.to_s
s=s.gsub('0','')
s=s.gsub('1','')
s=s.split("")
c=[]
for i in s
	case i
		when '9'
			c.push('7')
			c.push('3')
			c.push('2')
		when '8'
			c.push('7')
			3.times{c.push('2')}
		when '7'
			c.push('7')
		when '6'
			c.push('5')
			c.push('3')
		when '5'
			c.push('5')
		when '4'
			c.push('3')
			c.push('2')
			c.push('2')
		when '3'
			c.push('3')
		when '2'
			c.push('2')
	end
end
c=c.sort.reverse
for i in c
	print("#{i}")
end
puts


# Drazil and Factorial
# ======================================
# time limit per test:   2 seconds
# memory limit per test: 256 megabytes
# input:                 standard input
# output:                standard output
# ======================================
fact= [2, 3, 322, 5, 53, 7, 7222, 9]

n= gets.chomp.to_i
a= gets.chomp

x= []
a.split(//).each do |c|
  d= c.to_i
  x << fact[d - 2] unless d < 2
end

puts x.join.split(//).sort.reverse.join


# coding: utf-8

# if __FILE__ == $0
# end

# F(x), factorials of its digits
# F(123) = 1! * 2! * 3!
# find possible maximum integer
n = gets.to_i
ar = Array.new(11) { 0 }
gets.chomp.split(//).each { |i|
    i = i.to_i
    ar[i] += 1
}

i = 9
j = 2
updated = true
while updated # if equals, indicates no more spread/break op(s) possible
    updated = false
    last_length = ar.length
    # breaking 8 -> 3x 2!
    ar[7] += ar[8]
    ar[2] += ar[8] * 3
    ar[8] = 0
    # break 6 -> 3!
    ar[5] += ar[6]
    ar[3] += ar[6]
    ar[6] = 0
    # break 4 -> 2x 2!
    ar[2] += ar[4]*2
    ar[3] += ar[4]
    ar[4] = 0
    # 1st point to check updated
    updated = ar.length != last_length
    # spread 9->2x 3! if 2's exist
    a9min = [ar[9], ar[2]/2].min
    ar[9] -= a9min
    ar[8] += a9min
    ar[2] -= a9min*2
    ar[3] += a9min*2
    # 2nd point to check updated
    if !updated
        updated = a9min > 0
    end
end

# 9! -> transform into 8! and spread 2x 3 (useful, only if 2's are enough)
# --> if 2x 3 can be spreaded to somewhere, it can be 8! can create more digits.
# 8! -> transform into 7! and create 3x 2! (useful)
# 7! -> transform into 6! and spread 1x 7 (useless)
# --> if 1x 7 can be spreaded to somewhere, it can be 6! so next condition works.
# --> but by spreading 7 to 6!, 6! can not create 1x 3!. can not create digits.
# 6! -> transform into 5! and create 1x 3! (useful)
# 5! -> transform into 4! and spread 1x 5 (useless)
# --> if 1x 5 can be spreaded to somewhere, it can be 4! so next condition works.
# --> but by spreading 5 to 4!, 4! can not create 2x 2!, can not create digits.
# 4! -> transform into 3! and create 2x 2! (useful)
# 3! -> transform into 2! and spread 1x 3 (no need to do so, useless)
# 2! -> most valuable one. (useful again, just leave them as is)

# join'em and print out
buf = []
for j in 2..9
    if ar[j] > 0
        buf << "#{j}"*ar[j]
    end
end

puts buf.reverse.join('')


pa=Array.new(10,0)

n=gets.to_i
str=gets.to_s

for i in 0..n-1
  k=str[i].to_i
  pa[k]+=1
end

while pa[4] != 0
  pa[2] += 2
  pa[4] -= 1
  pa[3] += 1
end

while pa[8] != 0
  pa[2] += 3
  pa[8] -= 1
  pa[7] += 1
end

while pa[6]!=0 && pa[2]!=0
  pa[6] -= 1
  pa[5] += 1
  pa[3] += 1
end

i=9
while i!=1
  while pa[i]!=0
    print i
    pa[i] -= 1
  end
  i -= 1
end

puts


w = gets.chomp
tmp = w.to_i / 2 + 1
if w.to_i % 2 == 0 && ((tmp % 2 == 0 && w.to_i % 2 == 0) || (w.to_i / 2) % 2 == 0)
	puts 'YES'
else
	puts 'NO'
end


n = gets.to_i
if n % 2 == 0
  puts "YES"
else
  puts "NO"
end


#! ruby -Ku
# -*- coding: utf-8 -*-

n = gets.to_i
if n % 2 == 0
puts YES
else
puts NO


x = gets.to_i
if x.even?
  puts "YES"
elsif
  puts "NO"
end


x = gets.to_i
if x.even? && x/2.even?
  puts "YES"
elsif
  puts "NO"
end


a =gets.to_i
if (a%2==0)
  print "YES"
else
  print "NO"
end


# https://codeforces.com/problemset/problem/4/A
a = gets.chomp.to_i
if (a % 2) % 2 == 0 then
  puts 'YES'
else
  puts 'NO'
end


w = gets
w = w.to_i
if( w%2 == 0)
	puts "YES"
else
	puts "NO"
end


n = gets.to_i

puts n % 2 > 0 && n >2 ? "YES" : "NO"


n = gets.to_i

puts n % 0  == 2 && n > 2 ? "YES" : "NO"


def split_watermellow(w)
  w = w.to_i
  return unless valid?(w)

  if divisors_are_even?(w)
    puts 'YES'
  else
    puts 'NO'
  end
end

def valid?(w)
  w.is_a?(Integer) &&
    1 <= w &&
    w <= 100
end

def divisors_are_even?(w)
  divisors = []
  (1..w/2).each { |x| divisors << ((w % x == 0) && ((w / x) % 2 == 0)) }
  divisors.any?(&:trust)
end

w = gets()
split_watermellow(w)


def split_watermellow(w)
  return unless valid?(w)

  if divisors_are_even?(w)
    puts 'YES'
  else
    puts 'NO'
  end
end

def valid?(w)
  w.is_a?(Integer) &&
    1 <= w &&
    w <= 100
end

def divisors_are_even?(w)
  (w / 2.0) % 2 == 0
end

split_watermellow(w)


def split_watermellow(w)
  w = w.to_i
  return unless valid?(w)

  if divisors_are_even?(w)
    puts 'YES'
  else
    puts 'NO'
  end
end

def valid?(w)
  w.is_a?(Integer) &&
    2 < w &&
    w <= 100
end

def divisors_are_even?(w)
  divisors = []
  (1..w/2).each { |x| divisors << ((w % x == 0) && ((w / x) % 2 == 0)) }
  divisors.any?(&:trust)
end

w = gets()
split_watermellow(w)


weight = gets.chomp

if weight % 2 == 0 && weight % 4 == 0
  puts 'YES'
else
  puts 'NO'
end


weight = gets.strip.chomp
half_watermelon = weight/2

if weight % 2 == 0 && half_watermelon % 2 == 0
  puts 'YES'
else
  puts 'NO'
end


a = STDIN.gets.chomp.to_i
if a % 2 == 0 and a > 4
  puts "YES"
else
  puts "NO"
end


w = gets.chomp.to_i

if ( w == 1 or w == 2 or w == 3)
  p "NO"
elsif w % 2 == 0
  p "YES"
else
  p "NO"
end


w = getc.to_i

if ((w == 1) || (w == 2) || (w == 3))
  print "NO"
elsif ((w % 2) == 0)
  print "YES"
else
  print "NO"
end


g = gets.to_i
if g%4 == 0 then puts 'YES'
else puts 'NO'
end


class Watermelon
  w = gets.chomp.to_i
  if w <=0
    print 'NO'
  elsif w % 2 == 0
    print 'YES'
  else
    print 'NO'
  end
end


STDIN.read.split("\n").each do |a|
  if Integer(a) % 2 == 0
    puts "YES"
  else
    puts "NO"
  end
end


w = gets.chomp.to_f

print w % 2 == 0 ? 'YES' : 'NO'


#!/usr/bin/ruby
require 'rational'
x,y,a,b=gets.split.map(&:to_i)
g=x/x.gcd(y)*y
p b/y-(a-1)/y


def run
  x, y, a, b = $stdin.gets.split.map(&:to_i)
  c = x.lcm(y)
  puts (((b - a) / c) + 1)
end

run if $0 == __FILE__


x, y, a, b = gets.chomp.split.map{|e| e.to_i}

s = 0

for i in a..b
	s += 1 if i % x == 0 and i % y == 0
end

puts s


x, y, a, b = gets.chomp.split.map{|e| e.to_i}

s = 0

while (a % x != 0) or (a % y != 0)
	a += 1
end

while (b % x != 0) or (b % y != 0)
	b -= 1
end

puts ((b - a + 1.0)/(x*y)).ceil


inp = gets.split.map(&:to_i)
count = 0
(inp[2]..inp[3]).each{|x| count+=1  if (x%inp[0]==0 && x%inp[1]==0)}
p count


x,y,a,b=gets.split.map(&:to_i)
q=x.lcm y
b/q-(a+q-1)/q+1


x, y, a, b = gets.chomp.split.map { |x| x.to_i }
k = x.lcm(y)
r = (b - a) / k
r += 1 if a % k == 0
puts r


a = gets.split(' ')
b = []

def ucln(m, n)
    if m > n
        p = m%n
            while p > 0 do
                m = n
                n = p
                p = m%n
            end
        return n
    else
        p = n%m
            while p > 0 do
                n = m
                m = p
                p = n%m
            end
        return m
    end
end

(0..3).each do |i|
    b[i] = a[i].to_i
end

bcnn = b[0] * b[1] / ucln(b[0], b[1])

kq = (b[3]/bcnn).floor + 1 - (b[2]/bcnn).ceil

puts kq


input = gets.split(" ").map {|e| e.to_i}
x = input[0]
y = input[1]
a = input[2]
b = input[3]

puts (b / (x*y) - (a.to_f / (x*y).to_f).ceil + 1)


def gcd a, b
	return a if b == 0
	gcd b, a % b
end

x, y, a, b = gets.split.map { |x| x.to_i }
l = x / gcd(x, y) * y
puts a / l + (b - 1) / l


arr = gets.split.map &:to_i
$n, x0, y0, dx, dy, t = arr

def mod(a)
  (a - 1) % $n + 1
end

dx, dy = mod(dx), mod(dy)

def zmul(a, b)
  ans = 0
  6.times do |i|
    ans += mod(a[i] * b[i])
    ans -= $n if ans > $n
  end
  ans
end

class Matrix
  def initialize(n)
    @mat = Array.new(n) do |i|
      Array.new(n) { |j| i == j ? 1 : 0 }
    end
  end

  def [](index)
    @mat[index]
  end

  def []=(index, val)
    @mat[index] = val
  end

  def mul(rhs)
    ans = Matrix.new(6)
    6.times do |i|
      6.times do |j|
        ans[i][j] = 0
        6.times do |k|
          ans[i][j] += mod(@mat[i][k] * rhs[k][j])
          ans[i][j] -= $n if ans[i][j] > $n
        end
      end
    end
    ans
  end

  def pow(e)
    ans = Matrix.new(6)
    tmp = self.clone
    while e > 0
      ans = ans.mul(tmp) if (e & 1) == 1
      tmp = tmp.mul(tmp) if (e >>= 1) > 0
    end
    ans
  end
end

mat = Matrix.new(6)
mat[0] = [2, 1, 1, 0, 1, 0]
mat[1] = [1, 2, 0, 1, 1, 0]
mat[2] = [1, 1, 1, 0, 1, 0]
mat[3] = [1, 1, 0, 1, 1, 0]
mat[4] = [0, 0, 0, 0, 1, 1]
mat[5] = [0, 0, 0, 0, 0, 1]

mat = mat.pow(t)

arr.shift
arr << 1
puts "#{zmul(mat[0], arr)} #{zmul(mat[1], arr)}"


# your code goes here

n = STDIN.gets.chomp.to_i
x = STDIN.gets.chomp.to_i

t=[0,0,0]

t[(x - 1)] = 1

(n - 1).downto(1) do
	|i|;
	puts i;
	x = t[1];
	if (i % 2) == 0;
		t[1] = t[2];
		t[2] = x;
	else;
		t[1] = t[0];
		t[0] = x;
	end;
end;

puts t.index(1);


# your code goes here

n = STDIN.gets.chomp.to_i
x = STDIN.gets.chomp.to_i

t=[0,0,0]

t[x] = 1

(n).downto(1) do
	|i|;
	#puts i;
	x = t[1];
	if (i % 2) == 0;
		t[1] = t[2];
		t[2] = x;
	else;
		t[1] = t[0];
		t[0] = x;
	end;
end;

puts t.index(1);


n = gets.to_i
for i in 1..n
  if 2 ** i >= n
    break
  end
end
print i


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)


myArray = $stdin.readlines

input=[]

myArray.each do |l|
  input.push(l)
end

a = input[0].split(',').map{|x| x.to_i}

#insert your code within this function
def solution(a)
  a2 = a.sort
  n = a2.size
  index_swap = 0
  for i in 0..n-1
    index_swap +=1 if a[i] != a2[i]
  end
  return index_swap <= 2
end

puts solution(a)


n, k, x = $stdin.gets.chomp.split(' ').map { |v| v.to_i }
a = $stdin.gets.chomp.split(' ').map { |v| v.to_i }

def cnt(l ,r)
  ans = 0
  flag = false
  while true do
    sum = 0
    while l>-1 && a[l] == a[r] do
      l -= 1
      sum += 1
    end
    l += 1
    while r < n && a[l] == a[r] do
      r += 1
      sum += 1
    end
    r -= 1
    return ans if flag && sum < 3
    flag = 1
    ans = [ans, r - l + 1].max
    l -= 1
    r += 1
    return ans if l <0 || r >= n || a[l] != a[r]
  end
end

ans = 0
for i in 0..n-1
  ans = [ans, cnt(i, i+1)].max if a[i] == a[i+1] && a[i] == x
end

puts ans


# Created by Alex
n, k, x = gets.split.map {|i| i.to_i}
a = gets.split.map {|i| i.to_i}
max = 0
for i in 0...n - 1
  if a[i] != x || a[i + 1] != x
    next
  end
  l = i - 1
  r = i + 2
  cnt = 3
  while l >= 0 && r < n
    p1 = l
    while p1 > 0 && a[p1 - 1] == a[r]
      p1 -= 1
    end
    p2 = r
    while p2 < n - 1 && a[p2 + 1] == a[l]
      p2 += 1
    end
    if l - p1 + p2 - r + 2 < 3
      break
    end
    cnt += l - p1 + p2 - r + 2
    l = p1 - 1
    r = p2 + 1
  end
  if cnt > max
    max = cnt
  end
end
if max < 3
  max = 1
end
puts max - 1


def run
  k = $stdin.gets.to_i
  h = Hash.new(0)
  $stdin.readlines.each do |line|
    line.chomp.split(//).each do |c|
      h[c] += 1 if c != '.'
    end
  end

  puts h.values.max <= 2*k ? "YES" : "NO"
end

run if $0 == __FILE__


a=gets.chomp.to_i*2
hash=Hash.new(0)
4.times do
temp=gets.chomp
temp.each_char do |i|
if i!="."
hash[i]+=1
end
end
end
k=hash.values.sort.reverse[0]

if k>a
puts "NO"
else
puts "YES"
end


k = gets.to_i

panels = 4.times.map do
  gets.chomp.chars.to_a
end.flatten.reject do |x|
  x == "."
end

hash = Hash.new 0
panels.each do |panel|
  hash[panel] += 1
end

yes = hash.values.max <= k * 2

puts yes ? "YES" : "NO"


n = get.to_i
if n>2 && n%2==0 then
    puts "YES"
else
    puts "NO"
end


a = gets.chomp.to_i

puts "YES" if a.even?
puts "NO" unless a.even?


w = gets
x = w%2
if x == 0
    puts YES
else
    puts NO
end


w = gets.to_i
if w%2 == 0 && ! 1
    puts "YES"
else
    puts "NO"
end


n=gets.to_i;
    if ((n % 2)==0)
        if ((n/2)% 2 == 0)
            puts "YES";
        else
            puts "NO";
        end
    else
        puts "NO";
    end


n=gets.to_i;

    mod_n = n % 2;
    if (mod_n == 0)
        p YES;
    else
        p NO;
    end


w = gets

if w.to_i % 2 == 0
  printf 'YES'
else
  printf 'NO'
end


a = gets.to_i

if a%2 == 0
	puts "YES"
elsif a%2!=0
	puts "NO"
end


input = STDIN.read

input.each_line do |w|
  puts w.to_i.even? ? 'YES' : 'NO'
end


puts(STDIN.gets.to_i % 2 == 0 ? 'YES' : 'NO')


def is_even(w)
	if w % 2 != 0
		return print "NO"
	else
		return print "YES"
	end
end
input = gets.chomp
w = Integer(input)
puts is_even(w)


w = gets.chomp
if w>3 && w%2 == 0
    print "YES"
else
    print "NO"
end


w = gets.chomp.to_i
if w%2 == 0
	print "YES"
else
	print "NO"
end


a = gets.chop.to_i
check = false

if (a%2==0)
	puts ('NO')
	check=true
end

if (a%2==0)
	if (check==false)
puts 'YES'
end
end

if a%2==1
	puts 'NO'
    end


x = gets.chomp
if (x.to_i % 2 == 0)
  puts "yes"
  elsif
  puts "no"
end


x = gets.chomp.to_i
if x%2==0
    puts "YES"
else
    puts "NO"
end


a = gets.to_i
puts ((a/2*2 == a) ? "YES" : "NO")


w = gets.chomp.to_f
if w/2%2==0
    puts 'YES'
else
    puts 'NO'
end


def watermelon(w)
token = w.even?
if token && w > 2
	puts "YES"
else
	puts "NO"
end
end


token = w.even?
"#{token && w > 2 ? 'YES' : 'NO'}"


n = gets.chomp.to_i
if n % 2 == 0 && (n / 2) % 2 == 0 then
   puts "YES"
else
   puts "NO"
end


weigth = gets().chomp.to_i

if (weigth%2==0 && (weigth/2).even?) then puts "YES" else puts "NO" end


n=gets.to_i
if n.even? then puts "YES" else puts "NO" end


a=gets.to_i
print "NO" if a%2 != 0
print "YES" if a%2 == 0


class BearBalls
  def consecutive_elements?(array)
    array.find.with_index do |_, i|
      array[i] + 2 == array[i + 2]
    end
  end

  def run(balls)
    balls_array = balls.split.sort.uniq.map(&:to_i)
    puts consecutive_elements?(balls_array) ? "YES" : "NO"
  end
end

size = gets.chomp
balls = gets.chomp
BearBalls.new.run(balls)


n=gets.to_i;
t=gets.split.map{|i| i.to_i}.sort

flag=false

for i in (1..t.length-2)
    if t[i]-t[i-1]==1 and t[i+1]-t[i]==1
        flag=true
        break
    end
end

if flag
    puts 'YES'
else
    puts 'NO'
end


n = gets.to_i
a = gets.split.map(&:to_i)
b = a.uniq.sort
ans = 'NO'
(b.size - 3).times do |i|
 ans = 'YES' if b[i + 2] - b[i] == 2
end
puts ans


b = gets
a = b.split(" ").sort
res = 1 ; i=1 ; mn = a[0].to_i

until i > mn
      res = res * i
      i+=1
end

print res


watermelon = gets.chomp.to_i
if (watermelon % 2) == 0
	puts "YES"
else
	puts "NO"
end


if gets.to_i.even?
  puts "YES"
else puts "NO"
end


w = (gets.split.map &:to_f)[0]
d = w/2
if d % 2 == 0
   puts 'YES'
else
   puts 'NO'
end


W = $stdin.gets.to_i
if W == 0
  puts("NO")
elsif W%2 == 0
    puts ("YES")
  else
    puts ("NO")
  end


if W%2 == 0
    puts ("YES")
  else
    puts ("NO")
  end


n = gets.chomp.to_i
if (n&1) && n != 2
	puts "YES"
else
	puts "NO"
end


weight = 0
weight = gets.to_i

if weight % 2 == 0 || weight != 2
	puts "YES"
else
	puts "NO"
end


while a = gets
	a = a.to_i
	#result = a % 2 == 0 ? 'YES' : 'NO'
	#puts result
	if a == 1
		puts "NO"
		next
	end

	result = "NO"
	(2..a).step(2) do |n|
		if (a - n) % 2 == 0
			result = "YES"
		end
	end
	puts result
end


x = gets.to_i
if x > 2 and w % 2 == 0
  puts "YES"
else
  puts "NO"
end


w = STDIN.read.to_i

if w % 2 == 0
  puts 'YES'
else
  puts 'NO'
end


n = gets.chomp.to_i
if n < 4
  puts 'NO'
elsif n % 2 != 0
  puts 'NO'
elsif n === 4
  puts 'YES'
else
  i = 0
  divisible = false
  while (i * 2 + 4) <= n / 2
    if (n - (i * 2 + 4)) % 2 === 0
      divisible = true
      break
    end
    i += 1
  end
  puts divisible ? 'YES' : 'NO'
end


n = gets.chomp
if n < 4
  p 'NO'
elsif n % 2 != 0
  p 'NO'
else
  i = 0
  divisible = false
  while (i * 2 + 4) <= n / 2
    if (n - (i * 2 + 4)) % 2 === 0
      divisible = true
      break
    end
    i += 1
  end
  p divisible ? 'YES' : 'NO'
end


n = gets.chomp.to_i
if n.even? && (n / 2).even?
  puts "YES"
else
  puts "NO"
end


w = gets.to_i
p (w / 2).even? ? 'YES' : 'NO'


w = gets.split.map &:to_i
puts "YES" if w % 2 == 0
puts "NO" if w % 2 != 0


w = gets.to_i
if w >= 4 and w % 2 == 0 do
puts "YES"
else
puts "NO"
end


w = STDIN.read.to_i
if w % 2 == 0
    puts "YES"
else
    puts "NO"
end


a, b, c = STDIN.readline.split.map {|s| s.to_i }.sort
puts a*a + (a+b)*c - (a+b+c) + 1


x, y, z = gets.split

puts 2 * (x + y + z)


x, y, z = gets.split.map(&:to_i)

puts 2 * (x + y + z)


a, b, c = gets.split.map { |x| x.to_i }
x = [a - 1, b - 2].min
s = (1 + x) * (2 * c + x)
ex = a + 1 - b
s += (c + b - 1) * ex if ex > 0
puts s


x = gets.split()
a = x[0].to_i
y = x[1].to_i
z = x[2].to_i

if y >= z
then
   b = y
   c = z
else
b = z
c = y
end

i= a

d =b +c - 1

if d%2== 0
then
   (c-1).times do
   a = a + 1
   i = i + a
   end
   (d/2-c).times do
   i = i + a
   end
   puts i*2
else
  (c-1).times do
   a = a + 1
   i = i + a
   end

  e = (d-1)/2
  (e-c).times do
  a = a + 1
  i = a + i
  end
 puts i*2 -a
end


n,m,k=gets.split.map(&:to_i)
planets=n.times.map{
	gets
	m.times.map{gets.split.map(&:to_i)}
}
ans=0
planets.permutation(2).each{|p1,p2|
	t=[]
	m.times{|i|t<<[p2[i][1]-p1[i][0],p1[i][2]]}
	kk=k
	a=0
	t.sort_by{|d,c|d}.reverse.each{|d,c|
		num=[kk,c].min
		a+=num*d
		kk-=num
		break if kk==0
	}
	ans=a if a>ans
}
p ans


a,b,c = gets.split.map &:to_i
puts b*c+b+c-1


n = STDIN.gets.to_i
def remaining(n)
  return 0 if n == 0
  return 1 if n == 1
  return 3 * remaining(n-1)
end
print remaining(n)


require 'set'
class Spelling
  attr_reader(:s)
  def initialize(s)
    @s = s
  end

  def sp
    @s.split("")
  end

  def rotated
    (0..s.length).map{|i| sp.rotate(i)}
  end

  def result
    rotated.to_set
  end
end

print Spelling.new(gets).result.length


x, y, l, r = gets.chomp.split.map &:to_i

unlucky = []
for i in 0...64
    for j in 0...64
        if x ** i +  y ** j <= r
            unlucky.push(x ** i + y ** j)
        else
            break
        end
    end
end
interval = []
for i in l..r
    interval.push(i)
end

golden = interval - unlucky

max = 1
for i in 0...golden.length-1
    if golden[i + 1] - golden[i] == 1
        max += 1
    else
        max = 1
    end
end

if golden.length > 0
    print max
else
    print 0
end


x, y, l, r = gets.chomp.split.map &:to_i

unlucky = []
for i in 0...64
    for j in 0...64
        m = x ** i + y ** j
        if m <= r && m >= l
            unlucky.push(m)
        end
    end
end

unlucky = unlucky.sort!
print unlucky
puts
unlucky_neat = []
if !unlucky.empty?
    unlucky_neat.push(unlucky[0])
    for i in 1...unlucky.length
        if unlucky[i] != unlucky[i - 1]
            unlucky_neat.push(unlucky[i])
        end
    end
end
print unlucky_neat
if !unlucky_neat.empty?
    max = (unlucky_neat[0] - l) > (r - unlucky_neat[unlucky_neat.length - 1]) ? (unlucky_neat[0] - l) : (r - unlucky_neat[unlucky_neat.length - 1])
    for i in 0...unlucky_neat.length - 1
        if unlucky_neat[i + 1] - unlucky_neat[i] - 1 > max
            max = unlucky_neat[i + 1] - unlucky_neat[i] - 1
        end
    end
    puts max
else
    max = r - l + 1
    puts max
end


x, y, l, r = gets.chomp.split.map &:to_i

unlucky = []
for i in 0...64
    for j in 0...64
        if x ** i + y ** j <= r && x ** i + y ** j >= l
            unlucky.push(x ** i + y ** j)
        end
    end
end
unlucky = unlucky.sort!
unlucky_neat = []
unlucky_neat.push(unlucky[0])
for i in 1...unlucky.length
    if unlucky[i] != unlucky[i - 1]
        unlucky_neat.push(unlucky[i])
    end
end

max = (unlucky_neat[0] - l) > (r - unlucky_neat[unlucky_neat.length - 1]) ? (unlucky_neat[0] - l) : (r - unlucky_neat[unlucky_neat.length - 1])
for i in 0...unlucky_neat.length - 1
    if unlucky_neat[i + 1] - unlucky_neat[i] - 1 > max
        max = unlucky_neat[i + 1] - unlucky_neat[i] - 1
    end
end

puts max


x,y,l,r=gets.split(" ").map(&:to_i)
xp=[]
yp=[]
t=1
while t<r do
  xp.push(t)
  t*=x
end
t=1
while t<r do
  yp.push(t)
  t*=y
end

zp=[]

for i in xp do
  for j in yp do
    zp.push(i+j)
  end
end

zp.uniq!()
zp.sort!()

#p zp

ans=0
tl=l
for i in zp do
  next if i<tl
  if i>=r then
    #p [ans,tl]
    ans=[ans,r+1-tl].max
    tl=i+1
    break
  end
  if tl<i then
    ans=[ans,i-tl].max
    tl=i+1
  end
  #p ans
end
#p [ans,tl]
ans=[ans,r+1-tl].max

puts ans


#!/usr/bin/ruby
h={}
f=10
x=1
gets.chomp.each_char.with_index{|c,i|
	if i==0&&!('0'..'9').include?(c)
		f=9
	end
	if c=='?'
		x*=10
	elsif ('A'..'J').include?(c)
		h[c]=1
	end
}
p x*(11-h.size..10).reduce(1,:*)/10*f


t = STDIN.gets
def ppp(start,lcounter)
  return start if lcounter == 1
  start*ppp(start-1, lcounter -1)
end
h = []
k = []
qcounter = 0

t.size.times do |i|
  if t[i] =~ /[A-J]/
    h << t[i] if not h.include? t[i]
  end
  if '0123456789'.include? t[i]
    k << t[i] if not k.include? t[i]
  end
  qcounter = qcounter + 1 if t[i] == '?'
end

p = h.count
p = 0 if p < 0
pp = 10

res = ((t[0] =~ /[A-J]/) ? ppp(pp-1, p-1)*(pp-1) : ppp(pp, p))* ((t[0] == '?') ? (10)**(qcounter - 1)*9 : (10)**qcounter)
puts res


a = gets.split.map(&:to_i)
a.sort!
x = (a.first + a.last) / 2
puts x - a.first + [ a[1] - x, x - a[1] ].max + a.last - x


while str = STDIN.gets
  array = str.split(' ').map{|_| _.to_i}
  ave = array.inject(0.0){|r, i| r += i } / array.size
  puts array.map{|_| (ave - _).abs}.inject {|sum, n| sum + n}.to_i
end


line = gets.chomp.split(/ /)
res = 0
if line.length == 2
	red_socks = line[0].to_i
	blue_socks = line[1].to_i
	if red_socks > blue_socks
		print blue_socks," "

		res = (red_socks-blue_socks)/2
		puts res
	elsif red_socks < blue_socks
		print red_socks, " "
		res = (blue_socks-red_socks)/2
		puts res
	else
		print red_socks," ", blue_socks
		print "\n"
	end
end


input = STDIN.gets
arr = input.split
first_days = arr.min.to_i
second_days = (arr.max.to_i - arr.min.to_i) / 2
puts "#{first_days} #{second_days}"
# puts "input - #{input}"


red_blue = gets.chomp
red_blue = red_blue.split
red = red_blue[0].to_i
blue = red_blue[1].to_i

arr = [red,blue]

hipster = 0
normal = 0

if red + blue >= 2
	print arr.min
	red = (red - arr.min)
	blue = (blue - arr.min)
	print " "
	if red > 0
		print red/2
	elsif blue > 0
		print blue/2
	end
else
	print 0
	print " "
	print 0
end


#!/usr/bin/local/ruby

#puts c
#読み込み
input = gets.chop.split(" ")
a = input[0].to_i
b = input[1].to_i

puts b.to_s+" "+(([a,b].max-[a,b].min)/2).to_s


#$stdin = File.open('in.txt')
#$stdout = File.open('out.txt', 'w')

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

a, b = b, a if a > b

p a, (b - a + 1) / 2


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


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


def swap(s, i)
	tmp = s[i]
	s[i] = s[i + 1]
	s[i + 1] = tmp
end

s = gets.strip.split
s1 = s[0]
s2 = s[1].to_i
i = 0
cnt = 0
while (i + 1) >= 0 && (i + 1) < s1.size
	break if cnt == s2
	if s1[i + 1] > s1[i]
		swap(s1, i)
		cnt += 1
		i -= 1
	else
		i += 1
	end
end
puts s1


s = gets.strip.split
a = s[0].split(//)
k = s[1].to_i
aa = []
while k > 0
	m = a[0..k].max
	mp = a.index(m)
	if mp == 0
		next
	else
		# swap...
		k -= mp
		aa << a[mp]
		a.delete_at(mp)
	end
end
aa << a
puts aa.join


s = gets.strip.split
a = s[0].split(//)
k = s[1].to_i
aa = []
while k > 0
	m = a[0..k].max
	mp = a.index(m)
	k -= mp if mp != 0
	aa << a[mp]
	a.delete_at(mp)
end
aa << a
puts aa.join


a,b=gets.split
a=a.split('').map(&:to_i)
k=b.to_i
i=0
while k>0&&i<a.size
	p=a[i,i+k+1].index(a[i,i+k+1].max)+i
	k-=(p-i+1)
	a.insert( i, a[p] )
	a.delete_at(p+1)
	i+=1
end
puts a*''


as,k = gets.split
len = as.length
keta = as.chars.map { |c| c.ord - '0'.ord }
k = k.to_i

len.times do |idx|
  best = keta[idx]
  bestj = idx
  (idx+1...len).each do |j|
    if j - idx <= k and best < keta[j]
      best = keta[j]
      bestj = j
    end
  end
  if bestj != -1
    keta[idx],keta[bestj] = [keta[bestj],keta[idx]]
    k -= bestj - idx
  end
end

puts keta.join


a, k = gets.split.map(&:to_i)
a = a.to_s.split(//)

(0..a.size-1).each do |i|
    bound = [i+k, a.size-1].min
    best = a[i..bound].max
    best_index = a.find_index(best)
    (i+1..best_index).to_a.reverse.each do |j|
        a[j] = a[j-1]
    end
    a[i] = best
    k -= (best_index-i)

end

puts a.join("")


l,d,v,g,r = gets.split(" ").map(&:to_i)

till_a = d/v.to_f

total_interval = g + r

extra_time = (till_a % total_interval) >= g ? (total_interval - till_a) : 0

a_to_b = (l-d) / v.to_f

puts till_a + extra_time + a_to_b


def sum(x)
	y=((x+1)*x)/2
end
m=gets.chomp.to_i
b=gets.chomp.to_i
max=0
(b+1).times do |y|
	x=(-y*m)+b*m
	s=(y+1)*sum(x)+(x+1)*sum(y)
	max= max > s ? max : s
end
p max