class Solver
  def solve(*a)
    p = a[0]
    t = a[1]

    moves = []
    while p != t && moves.size < 8
      #puts "#{p} -> #{t}"

      moves << navigate(p,t)
    end
    moves
  end

  def navigate(p,t)
    dx = dir(t[0].ord - p[0].ord)
    dy = dir(t[1].ord - p[1].ord)

    p[0] = (p[0].ord + dx).chr
    p[1] = (p[1].ord + dy).chr

    ['L','','R'][dx+1] + ['D','','U'][dy+1]
  end

  def dir(d)
    return 0 if d == 0
    return 1 if d > 0
    return -1
  end
end

if __FILE__==$0
  a = gets.chomp
  b = gets.chomp
  s = Solver.new
  sol = s.solve(a,b)
  puts sol.count
  sol.each do |s|
    puts s
  end
end

s = gets
t = gets
sx = s[0..0].ord
sy = s[1..1].to_i
tx = t[0..0].ord
ty = t[1..1].to_i
dx = sx-tx
dy = sy-ty
step = [dx.abs,dy.abs].max
puts step
step.times do
  if dx<0
    print "R"
    dx += 1
  elsif dx>0
    print "L"
    dx -= 1
  end
  if dy<0
    print "U"
    dy += 1
  elsif dy>0
    print "D"
    dy -= 1
  end
  puts
end

input = gets
king = [input[0].ord - 96, input[1].ord - 48]
input = gets
target = [input[0].ord - 96, input[1].ord - 48]

path = Array.new

while king != target
  s = String.new
  if king[0] < target[0]
    s << "R"
    king[0] += 1
  elsif king[0] > target[0]
    s << "L"
    king[0] -= 1
  end
  if king[1] < target[1]
    s << "U"
    king[1] += 1
  elsif king[1] > target[1]
    s << "D"
    king[1] -= 1
  end
  path.concat([s])
end

puts path.count
path.each {|x| puts x}

s, t = gets.to_s, gets.to_s
row = t[0].ord - s[0].ord
col = t[1].ord - s[1].ord
if row.abs > col.abs
	puts row.abs
	rc = 1
	diff = (row.abs - col.abs).to_i
	sqr = row.abs - diff
else
	puts col.abs
	rc = 0
	diff = (col.abs - row.abs).to_i
	sqr = col.abs - diff
end
if row >= 0 and col >= 0
	sqr.times{
		puts "RU"
	}
	if rc == 1
		diff.times{
			puts "R"
		}
	else
		diff.times{
			puts "U"
		}
	end
elsif row <= 0 and col >= 0
	sqr.times{
		puts "LU"
	}
	if rc == 1
		diff.times{
			puts "L"
		}
	else
		diff.times{
			puts "U"
		}
	end
elsif row <= 0 and col <= 0
	sqr.times{
		puts "LD"
	}
	if rc == 1
		diff.times{
			puts "L"
		}
	else
		diff.times{
			puts "D"
		}
	end
else
	sqr.times{
		puts "RD"
	}
	if rc == 1
		diff.times{
			puts "R"
		}
	else
		diff.times{
			puts "D"
		}
	end
end

class King
  def initialize(s, t)
    @start = s
    @end = t
  end

  def get_path
    return 0 if @start == @end
    result = []
    horizontal = (@start[0] == @end[0])
    vertical = (@start[1] == @end[1])

    current = @start
    steps = 0
    until horizontal || vertical
      current = move_diag(current)
      horizontal = (current[0] == @end[0])
      vertical = (current[1] == @end[1])
      result << direction.join
      steps += 1
    end

    if vertical
      current_steps = (current[0].ord.to_i - @end[0].ord.to_i).abs
      result += [direction.first]*current_steps
      steps += current_steps
    elsif horizontal
      current_steps = (current[1].to_i - @end[1].to_i).abs
      result += [direction.last]*current_steps
      steps += current_steps
    end
    result.unshift(steps)

    # if @start == @end
    #   result << 0
    # elsif horizontal
    #   result = [steps_x.abs] + [direction.last]*steps_x.abs
    # elsif vertical
    #   result = [steps_y.abs] + [direction.first]*steps_y.abs
    # else
      # current = @start
      # steps = 0
      # until horizontal || vertical
      #   current = move_diag(current)
      #   horizontal = (current[0] == @end[0])
      #   vertical = (current[1] == @end[1])
      #   result << direction.join
      #   steps += 1
      # end
    # end
    result
  end

  def move_diag(position)
    x_inc = steps_x == 0 ? 0 : steps_x/steps_x.abs
    y_inc = steps_y == 0 ? 0 : steps_y/steps_y.abs
    [(position[0].ord - y_inc).chr, (position[1].to_i - x_inc)].join
  end

  def direction
    [direction_y, direction_x]
  end

  def direction_x
    steps_x > 0 ? 'D' : 'U'
  end

  def direction_y
    steps_y > 0 ? 'L' : 'R'
  end

  def steps_x
    @start[1].to_i - @end[1].to_i
  end

  def steps_y
    @start[0].ord.to_i - @end[0].ord.to_i
  end
end

s, t = [gets.chomp, gets.chomp]
game = King.new(s, t)
puts game.get_path

a = gets.chomp
b = gets.chomp
x, y = a[0].ord-b[0].ord, a[1].to_i-b[1].to_i
puts [x.abs, y.abs].max
s = ""
if x.abs > y.abs
    s = (x>0 ? "L" : "R")
else
    s = (y>0 ? "D" : "U")
end
print (s+"\n")*(x.abs-y.abs).abs
if x > 0
    s = (y > 0 ? "LD" : "LU")
else
    s = (y > 0 ? "RD" : "RU")
end
print (s+"\n")*[x.abs, y.abs].min

s=gets

t=gets

r=t[0].ord-s[0].ord

c=t[1].hex-s[1].hex

a=[""]*9

f=lambda{|r,c|r.times{|i|a[i]+=c}}

f.call(r,"R")

f.call(-r,"L")

f.call(c,"U")

f.call(-c,"D")

a.select!{|i|i!=""}

p a.size

puts a

include Math
a=0
"a".each_byte do |n|
  a=n
end
memo=gets.chomp!.scan(/./)
sx=0
memo[0].each_byte do |n|
  sx=n-a+1
end
sy=memo[1].to_i
ex=0
memo=gets.chomp!.scan(/./)
memo[0].each_byte do |n|
  ex=n-a+1
end
ey=memo[1].to_i
xx=ex-sx
yy=ey-sy
hosu=[xx<0 ? -xx : xx,yy<0 ? -yy :yy].max
puts hosu
if xx >=0 && yy>=0
  if xx>=yy
    yy.times do
      puts "RU"
    end
    (xx-yy).times do
      puts "R"
    end
  else
    xx.times do
      puts "RU"
    end
    (yy-xx).times do
      puts "U"
    end
  end
end
if xx >=0 && yy<0
  yy=-yy
  if xx>=yy
    yy.times do
      puts "RD"
    end
    (xx-yy).times do
      puts "R"
    end
  else
    xx.times do
      puts "RD"
    end
    (yy-xx).times do
      puts "D"
    end
  end
end
if xx < 0 && yy >=0
  xx=-xx
  if xx>=yy
    yy.times do
      puts "LU"
    end
    (xx-yy).times do
      puts "L"
    end
  else
    xx.times do
      puts "LU"
    end
    (yy-xx).times do
      puts "U"
    end
  end
end
if xx <0 && yy<0
  xx=-xx
  yy=-yy
  if xx>=yy
    yy.times do
      puts "LD"
    end
    (xx-yy).times do
      puts "L"
    end
  else
    xx.times do
      puts "LD"
    end
    (yy-xx).times do
      puts "D"
    end
  end
end

s=gets.chomp.split("")
t=gets.chomp.split("")
valu=1..8
alph=('a' .. 'h')
valu=[*valu]
alph=[*alph]
valu_hash={}
i=0
loop do
	break if i==8
	valu_hash[alph[i]]=valu[i]
	i+=1
 end
dir_arry=[]
if valu_hash[s[0]]< valu_hash[t[0]]
   dir_arry[0]="R"
elsif valu_hash[s[0]]> valu_hash[t[0]]
   dir_arry[0]="L"
else
   dir_arry[0]=0
end

if s[1].to_i< t[1].to_i
   dir_arry[1]="U"
elsif s[1].to_i> t[1].to_i
   dir_arry[1]="D"
else
   dir_arry[1]=0
end

hmove=valu_hash[s[0]] - valu_hash[t[0]]
if hmove<0
hmove=hmove*(-1)
end
vmove=s[1].to_i-t[1].to_i
if vmove<0
vmove=vmove*(-1)
end

if hmove==0
	puts vmove
	vmove.times{puts dir_arry[1]}
elsif vmove==0
	puts hmove
	hmove.times{puts dir_arry[0] }
elsif vmove==hmove
	puts hmove
    hmove.times{puts dir_arry[0]+dir_arry[1] }
elsif hmove>vmove
	puts hmove
	vmove.times{puts dir_arry[0]+dir_arry[1] }
	(hmove-vmove).times {puts dir_arry[0]}
elsif vmove>hmove
	puts vmove
	hmove.times{puts dir_arry[0]+dir_arry[1] }
	(vmove-hmove).times{puts dir_arry[1]}
end

s1 = gets
s2 = gets
dst1 = s2[0].ord - s1[0].ord
dst2 = s2[1].to_i - s1[1].to_i

puts [dst2.abs, dst1.abs].max
while dst2 != 0 or dst1 != 0 do
    if dst1 > 0 then
        printf "R"
        dst1 -= 1
    end
    if dst1 < 0 then
        printf "L"
        dst1 += 1
    end

    if dst2 > 0 then
        printf "U"
        dst2 -= 1
    end
    if dst2 < 0 then
        printf "D"
        dst2 += 1
    end
    puts
end

def get_path(src, dest)
  s_x, s_y = src.chars
  d_x, d_y = dest.chars
  path = []
  while s_x != d_x || s_y != d_y
    move = ''
    if (s_x > d_x)
      s_x = (s_x.ord - 1).chr
      move += 'L'
    elsif (s_x < d_x)
      s_x.next!
      move += 'R'
    end

    if (s_y > d_y)
      s_y = (s_y.ord - 1).chr
      move += 'D'
    elsif (s_y < d_y)
      s_y.next!
      move += 'U'
    end

    path << move
  end
  path
end

if __FILE__ == $0
  path = get_path(gets, gets)
  puts path.size
  path.each { |m| puts m }
end

start_point = gets.chomp
end_point = gets.chomp

character_start_point = start_point[0]
number_start_point = start_point[1].to_i

character_end_point = end_point[0]
number_end_point = end_point[1].to_i

vertical_moves_count = (number_start_point-number_end_point).abs
vertical_moves_character = number_start_point > number_end_point ? 'D' : 'U'

horizontal_moves_count = (character_start_point.ord - character_end_point.ord).abs
horizontal_moves_character = character_start_point.ord < character_end_point.ord ? 'R' : 'L'

max_steps = vertical_moves_count > horizontal_moves_count ? vertical_moves_count : horizontal_moves_count

puts max_steps

while max_steps > 0
  print horizontal_moves_character if horizontal_moves_count > 0
  print vertical_moves_character if vertical_moves_count > 0
  puts
  horizontal_moves_count -= 1
  vertical_moves_count -= 1
  max_steps -= 1
end

def f(x,y,gx,gy)
	if x==gx && y==gy then
		return ""
	else
		res=""
		x1=x
		y1=y
		if x<gx then
			x1=x+1
			res+="R"
		elsif x>gx
			x1=x-1
			res+="L"
		end
		if y<gy then
			y1=y+1
			res+="U"
		elsif y>gy then
			y1=y-1
			res+="D"
		end
		return res+"\n"+f(x1,y1,gx,gy)
	end

end

h=	Hash["a",1,"b",2,"c",3,"d",4,
		 "e",5,"f",6,"g",7,"h",8]

s1=gets.chomp
s2=gets.chomp
if s1==s2 then
	puts "0\n"
else
	x=f(h[s1[0]],s1[1].to_i,h[s2[0]],s2[1].to_i).split()
	puts x.size
	puts x*"\n"
end

start = gets().chomp!
finish =  gets().chomp!
LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h"]
h_distance, v_distance = [LETTERS.index(finish[0,1]) - LETTERS.index(start[0,1]), finish[1,1].to_i - start[1,1].to_i]
moves = Array.new(7){""}
h_distance.abs().times {
|i|
  h_distance > 0 ? moves[i] << "R" : moves[i] << "L"
}
v_distance.abs().times {
|i|
  v_distance > 0 ? moves[i] << "U" : moves[i] << "D"
}
moves = moves.select(){|elem| elem != ""}
puts moves.length, moves

start = gets().chomp!
finish =  gets().chomp!
LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h"]
h_distance = LETTERS.index(finish[0,1]) - LETTERS.index(start[0,1])
v_distance = finish[1,1].to_i - start[1,1].to_i
moves = Array.new(7){""}
h_distance.abs().times {
|i|
  h_distance > 0 ? moves[i] << "R" : moves[i] << "L"
}
v_distance.abs().times {
|i|
  v_distance > 0 ? moves[i] << "U" : moves[i] << "D"
}
moves = moves.select(){|elem| elem != ""}
puts moves.length, moves

def num(x)
    if x == "a"
        return 1
    elsif x == "b"
        return 2
    elsif x == "c"
        return 3
    elsif x == "d"
        return 4
    elsif x == "e"
        return 5
    elsif x == "f"
        return 6
    elsif x == "g"
        return 7
    else
        return 8
    end
end

def simple(h,v)
    step = []
    if h > 0 then
        step += ["R"]*h
    elsif h < 0 then
        step += ["L"]*h.abs
    elsif v > 0
        step += ["U"]*v
    elsif v < 0
        step += ["D"]*v.abs
    end
    return step
end

k = gets.chomp
t = gets.chomp

step = []

h = num(t[0]) - num(k[0])
v = t[1].to_i - k[1].to_i

d = (0-v).abs < (0-h).abs ? v : h

if d != 0 then
    if h == d then
        if h > 0 && v > 0 then
            step += ["RU"]*h
        elsif h > 0 && v < 0 then
            step += ["RD"]*h
        elsif h < 0 && v > 0 then
            step += ["LU"]*h.abs
        else
            step += ["LD"]*h.abs
        end
        if v > 0 then
            v -= h.abs
        else
            v += h.abs
        end
        h = 0
    else
        if h > 0 && v > 0 then
            step += ["RU"]*v
        elsif h > 0 && v < 0 then
            step += ["RD"]*v.abs
        elsif h < 0 && v > 0 then
            step += ["LU"]*v
        else
            step += ["LD"]*v.abs
        end
        if h > 0 then
            h -= v.abs
        else
            h += v.abs
        end
        v = 0
    end
end

step += simple(h,v)

puts step.size
step.size.times do |i|
    puts step[i]
end

s,t = readlines.join.split
sx,sy = s[0].ord - 'a'.ord, s[1].to_i-1
gx,gy = t[0].ord - 'a'.ord, t[1].to_i-1
a=[""]*9
f = lambda{|r,c| r.times{|i| a[i] += c}}
f.call(gx-sx,'R')
f.call(sx-gx,'L')
f.call(sy-gy,'D')
f.call(gy-sy,'U')
a.select!{|i| i != ""}
puts a.size
puts a

# require 'pry-byebug'
file = File.exist?('in.in') ? File.new('in.in','r') : STDIN

DX = [0, 1, 0, -1, 1, -1, 1, -1]
DY = [1, 0, -1, 0, 1, -1, -1, 1]
MOV = ["R", "D", "L", "U", "RD", "LU", "LD", "RU"]

def inside?(i, j, grid)
  i>=0 && i<= grid.size-1 && j>=0 && j <=grid[0].size-1
end

map = {"a"=> 0, "b"=> 1, "c"=> 2, "d"=> 3, "e"=> 4,"f"=> 5, "g"=> 6, "h" => 7}

s2,s1 = file.gets.chomp.split('')
t2,t1 = file.gets.chomp.split('')

s1 = (s1.to_i-1-7).abs
s2 = map[s2]
t1 = (t1.to_i-1-7).abs
t2 = map[t2]

# puts "#{s1}#{s2}"
# puts "#{t1}#{t2}"

grid = Array.new(8) { Array.new(8) }
dist = Array.new(8) { Array.new(8, 100) }
queue = [[s1, s2]]
dist[s1][s2]=0
grid[s1][s2]=[]

while(queue.size != 0)
  x, y  = queue.shift
  8.times do |i|
    new_x = x+DX[i]
    new_y = y+DY[i]
    if inside?(new_x, new_y, grid) && dist[new_x][new_y]==100

      if dist[x][y]+1 < dist[new_x][new_y]
        dist[new_x][new_y]  = dist[x][y]+1
        grid[new_x][new_y] = grid[x][y] + [MOV[i]]
      end

      # dist[new_x][new_y] = [dist[new_x][new_y],dist[x][y]+1].min
      break if new_x == t1 && new_y == t2
      # binding.pry if dist[new_x][new_y] == 7
      queue << [new_x, new_y]
    end
  end
end
puts dist[t1][t2]
grid[t1][t2].each do |e|
  puts e
end

s,t = readlines.join.split
sx,sy = s[0].ord - 'a'.ord, s[1].to_i-1
gx,gy = t[0].ord - 'a'.ord, t[1].to_i-1

dx    = (sx-gx).abs
dy    = (sy-gy).abs
xchar = sx < gx ? 'R' : 'L'
ychar = sy < gy ? 'U' : 'D'

ans = []
cnt = 0
while dx > 0 && dy > 0
  ans << (xchar+ychar)
  dx -= 1
  dy -= 1
end

while dx > 0
  ans << xchar
  dx -= 1
end

while dy > 0
  ans << ychar
  dy -= 1
end

puts ans.size
puts ans

start = gets
start_x = start[0].ord - 97
start_y = start[1].to_i - 1

finish = gets
finish_x = finish[0].ord - 97
finish_y = finish[1].to_i - 1

result = []

if start_x < finish_x
	# go right
	(finish_x - start_x).times do
		result << ["R"]
	end
else
	# go left
	(start_x - finish_x).times do
		result << ["L"]
	end
end

if start_y < finish_y
	# go up
	(finish_y - start_y).times do |index|
		if result[index].nil?
			result << ["U"]
		else
			result[index][0]<< "U"
		end
	end
else
	# go down
	(start_y - finish_y).times do |index|
		if result[index].nil?
			result << ["D"]
		else
			result[index][0]<< "D"
		end
	end
end

puts result.length
puts result

source = gets.chomp!
destination = gets.chomp!
h = []
v = []
while true
	if source[0] < destination[0]
		h << 'R'
		source[0] = (source[0].ord + 1).chr
	elsif source[0] > destination[0]
		h << 'L'
		source[0] = (source[0].ord - 1).chr
	else
		h << ''
	end

	if source[1] < destination[1]
		v << 'U'
		source[1] = (source[1].to_i + 1).to_s
	elsif source[1] > destination[1]
		v << 'D'
		source[1] = (source[1].to_i - 1).to_s
	else
		v << ''
	end

	break if source == destination

end
if h.size == 1 && v.size == 1 && h[0] == '' && v[0] == ''
	puts 0
else
	puts h.size
	h.each_index {|index| puts h[index] + v[index]}
end

#!usr/bin/env ruby

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

start = gets.chomp
finish = gets.chomp
x1 = start[0]
x2 = finish[0]

y1 = start[1]
y2 = finish[1]

count = 0
moves = []

while !(x1 == x2 && y1 == y2) do
 move = ""

 if x1 < x2
  move += "R"
  x1 = x1.next
 elsif x1 > x2
  move += "L"
  x1 = (x1.ord - 1).chr
 end

 if y1 < y2
  move += "U"
  y1 = y1.next
 elsif y1 > y2
  move += "D"
  y1 = (y1.ord - 1).chr
 end
 count += 1
 moves << move
 end

puts count
moves.each { |mv| puts mv }

s = STDIN.readline
t = STDIN.readline

print [(s[0].ord-t[0].ord).abs,(s[1].ord-t[1].ord).abs].max
print ?\n

while s != t ;
	if s[0] < t[0] ;
		print ?R
		s[0] = (s[0].ord+1).chr
	elsif s[0] > t[0] ;
		print ?L
		s[0] = (s[0].ord-1).chr
	end
	if s[1] < t[1] ;
		print ?U
		s[1] = (s[1].ord+1).chr
	elsif s[1] > t[1] ;
		print ?D
		s[1] = (s[1].ord-1).chr
	end
	print ?\n
end

s=gets.split[0].bytes.to_a
t=gets.split[0].bytes.to_a
sx=s[0]-97
sy=56-s[1]
tx=t[0]-97
ty=56-t[1]
puts [(sx-tx).abs,(sy-ty).abs].max
loop do
        if sx==tx && sy==ty then
                break
        end
        if sx<tx then
                print "R"
                sx+=1
        elsif sx>tx then
                print "L"
                sx-=1
        end
        if sy<ty then
                print "D"
                sy+=1
        elsif sy>ty then
                sy-=1
                print "U"
        end
        puts
end

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

class Node
  attr_accessor :distance, :visited, :prev, :x, :y, :cost

  def initialize(x=0, y=0, cost=1)
    @distance = Float::INFINITY
    @visited = false
    @prev = nil
    @x = x
    @y = y
    @cost = cost
  end
end

def make_graph(x, y)
  (0...x).map { |x| (0...y).map { |y| Node.new(x, y) } }
end

def find_unvisited(graph)
  graph.flatten { |y| y.visited == false }
end

def min(unvisited, graph)
  min = unvisited.map { |node| node.distance }.each_with_index.min
  unvisited[min[1]]
end

def in_range(x, y, graph)
  x >= 0 && y >= 0 && x < graph.size && y < graph[0].size && !graph[x][y].visited
end

def get_neighbors(x, y, graph)
  l = [x-1, y]
  r = [x+1, y]
  t = [x, y+1]
  b = [x, y-1]
  lt = [x-1, y+1]
  rt = [x+1, y+1]
  rb = [x+1, y-1]
  lb = [x-1, y-1]

  [l,r,t,b,lt,rt,rb,lb].select { |neighbor| in_range(neighbor[0], neighbor[1], graph) }
end

def visit(node, graph)
  neighbors = get_neighbors(node.x, node.y, graph)
  neighbors.each do |n|
    neighbor = graph[n[0]][n[1]]
    neighbor.visited = true
    dist = node.distance + neighbor.cost
    if dist < neighbor.distance
      neighbor.distance = dist
      neighbor.prev = node
    end
  end
end

def dijkstra(graph, source, target)
  graph[source[0]][source[1]].distance = 0
  unvisited = find_unvisited(graph)

  while unvisited.any?
    current_node = min(unvisited, graph)
    return current_node if current_node.x == target[0] && current_node.y == target[1]
    unvisited.delete(current_node)
    visit(current_node, graph)
  end
end

def convert_source(coord)
  [coord[0].ord - 96 - 1, Integer(coord[1]) -1]
end

def to_directions(from, to)
  return if to == nil
  str = ""
  if to.x > from.x
    str << "R"
  end
  if to.x < from.x
    str << "L"
  end
  if to.y > from.y
    str << "U"
  end
  if to.y < from.y
    str << "D"
  end
  str
end

def get_answer_nodes(root)
  nodes = []
  current_node = root
  while !current_node.nil?
    nodes << current_node
    current_node = current_node.prev
  end
  nodes.reverse
end

def format_answer(answer)
  nodes = get_answer_nodes(answer)
  directions = [nodes.size-1]
  nodes.each_with_index do |node, i|
    directions << to_directions(nodes[i], nodes[i+1])
  end
  directions
end

def solve
  graph = make_graph(8, 8)
  source = gets
  target = gets
  answer = dijkstra(graph, convert_source(source.chomp), convert_source(target.chomp))
  puts format_answer(answer).join("\n")
end

solve()

s,t = gets.strip.bytes.to_a, gets.strip.bytes.to_a
moves = []
while s != t
  move = ""
  if s[0] < t[0]
    s[0] += 1
    move += "R"
  elsif s[0] > t[0]
    s[0] -= 1
    move += "L"
  end
  if s[1] < t[1]
    s[1] += 1
    move += "U"
  elsif s[1] > t[1]
    s[1] -= 1
    move += "D"
  end
  moves << move
end

puts moves.size
for s in moves do
  puts s
end

coord_src = gets
coord_dest = gets

coord_src_x = 1 + coord_src[0].ord - 'a'.ord
coord_src_y = coord_src[1].to_i
coord_dest_x = 1 + coord_dest[0].ord - 'a'.ord
coord_dest_y = coord_dest[1].to_i

#puts coord_src_x.to_s + " " + coord_src_y.to_s
#puts coord_dest_x.to_s + " " + coord_dest_y.to_s

moves = []

# Firstly, move diagonally in the correct direction.
while (coord_src_x != coord_dest_x && coord_src_y != coord_dest_y) do
  if coord_src_x > coord_dest_x
    coord_src_x -= 1
    if coord_src_y > coord_dest_y
      moves.push("LD")
      coord_src_y -= 1
    else
      moves.push("LU")
      coord_src_y += 1
    end
  else
   coord_src_x += 1
    if coord_src_y > coord_dest_y
      moves.push("RD")
      coord_src_y -= 1
    else
      moves.push("RU")
      coord_src_y += 1
    end
  end
end

# Now it is just a straightaway
if(coord_src_x > coord_dest_x)
  (coord_src_x - coord_dest_x).times { moves.push("L") }
elsif (coord_src_x < coord_dest_x)
  (coord_dest_x - coord_src_x).times { moves.push("R") }

elsif(coord_src_y > coord_dest_y)
  (coord_src_y - coord_dest_y).times { moves.push("D") }
elsif (coord_src_y < coord_dest_y)
  (coord_dest_y - coord_src_y).times { moves.push("U") }
end

puts moves.size
moves.each { |move| puts move }

input = STDIN.read.split("\n")
a, b = input[0].split(''), input[1].split('')
a[1], b[1] = a[1].to_i, b[1].to_i

if a == b
	STDOUT.print 0
	exit
end

if a[0] > b[0]
	x_dir = "L"
elsif a[0] < b[0]
	x_dir = "R"
end

if a[1] > b[1]
	y_dir = "D"
elsif a[1] < b[1]
	y_dir = "U"
end

str = ""
count = 0

while true do

	if a[0] != b[0]
		a[0].next! if x_dir == "R"
		a[0] = (a[0].ord - 1).chr if x_dir == "L"
		str << x_dir
	end

	if a[1] != b[1]
		a[1] += 1 if y_dir == "U"
		a[1] -= 1 if y_dir == "D"
		str << y_dir
	end

	count += 1
	str << "\n"

	break if a == b

end

STDOUT.print count, "\n", str

input = STDIN.read.split("\n")
a, b = input[0].split(''), input[1].split('')
a[0], b[0], a[1], b[1] = a[0].ord, b[0].ord, a[1].to_i, b[1].to_i

if a == b
	STDOUT.print 0
	exit
end

x_dir = a[0] > b[0] ? "L" : "R"
y_dir = a[1] > b[1] ? "D" : "U"

str, count = '', 0

loop do

	if a[0] != b[0]
		x_dir == "R" ? a[0] += 1 : a[0] -= 1
		str << x_dir
	end

	if a[1] != b[1]
		y_dir == "U" ? a[1] += 1 : a[1] -= 1
		str << y_dir
	end

	count += 1
	str << "\n"

	break if a == b

end

STDOUT.print count, "\n", str

input = STDIN.read.split("\n")
a, b = input[0].split(''), input[1].split('')
a[1], b[1] = a[1].to_i, b[1].to_i

if a == b
	STDOUT.print 0
	exit
end

x_dir = a[0] > b[0] ? "L" : "R"
y_dir = a[1] > b[1] ? "D" : "U"

str, count = '', 0

while true do

	if a[0] != b[0]
		a[0] = x_dir == "R" ? a[0].next : (a[0].ord - 1).chr
		str << x_dir
	end

	if a[1] != b[1]
		y_dir == "U" ? a[1] += 1 : a[1] -= 1
		str << y_dir
	end

	count += 1
	str << "\n"

	break if a == b

end

STDOUT.print count, "\n", str

# require 'pry-byebug'
file = File.exist?('in.in') ? File.new('in.in','r') : STDIN

DX = [0, 1, 0, -1, 1, -1, 1, -1]
DY = [1, 0, -1, 0, 1, -1, -1, 1]
MOV = ["R", "D", "L", "U", "RD", "LU", "LD", "RU"]

def inside?(i, j, grid)
  i>=0 && i<= grid.size-1 && j>=0 && j <=grid[0].size-1
end

map = {"a"=> 0, "b"=> 1, "c"=> 2, "d"=> 3, "e"=> 4,"f"=> 5, "g"=> 6, "h" => 7}

s1,s2 = file.gets.chomp.split('')
t1,t2 = file.gets.chomp.split('')

return puts 0 if s1==t1 && s2==t2

s1 = map[s1]
s2 = (s2.to_i-1-7).abs
t1 = map[t1]
t2 = (t2.to_i-1-7).abs

# puts "#{s1}#{s2}"
# puts "#{t1}#{t2}"

grid = Array.new(8) { Array.new(8) }
dist = Array.new(8) { Array.new(8, 100) }
queue = [[s1, s2]]
dist[s1][s2]=0
grid[s1][s2]=[]

while(queue.size != 0)
  x, y  = queue.shift
  8.times do |i|
    new_x = x+DX[i]
    new_y = y+DY[i]
    if inside?(new_x, new_y, grid) && dist[new_x][new_y]==100

      if dist[x][y]+1 < dist[new_x][new_y]
        dist[new_x][new_y]  = dist[x][y]+1
        grid[new_x][new_y] = grid[x][y] + [MOV[i]]
      end

      # dist[new_x][new_y] = [dist[new_x][new_y],dist[x][y]+1].min
      break if new_x == t1 && new_y == t2
      # binding.pry if dist[new_x][new_y] == 7
      queue << [new_x, new_y]
    end
  end
end
puts dist[t1][t2]
grid[t1][t2].each do |e|
  puts e
end

#!usr/bin/env ruby

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

start = gets.chomp
finish = gets.chomp

while ! start.eql? finish do
 move = ""

 if start[0] < finish[0]
  move += "U"
  start[0] = start[0].next
 elsif start[0] > finish[0]
  move += "D"
  start[0] = (start[0].ord - 1).chr
 end

 if start[1] < finish[1]
  move += "R"
  start[1] = start[1].next
 elsif start[1] > finish[1]
  move += "L"
  start[1] = (start[1].ord - 1).chr
 end

 puts move
end

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

class Node
  attr_accessor :distance, :visited, :prev, :x, :y, :cost

  def initialize(x=0, y=0, cost=1)
    @distance = Float::INFINITY
    @visited = false
    @prev = nil
    @x = x
    @y = y
    @cost = cost
  end
end

def make_graph(x, y)
  (0...x).map { |x| (0...y).map { |y| Node.new(x, y) } }
end

def find_unvisited(graph)
  graph.flatten { |y| y.visited == false }
end

def min(unvisited, graph)
  min = unvisited.map { |node| node.distance }.each_with_index.min
  unvisited[min[1]]
end

def in_range(x, y, graph)
  x >= 0 && y >= 0 && x < graph.size && y < graph[0].size && !graph[x][y].visited
end

def get_neighbors(x, y, graph)
  l = [x-1, y]
  r = [x+1, y]
  t = [x, y+1]
  b = [x, y-1]
  lt = [x-1, y+1]
  rt = [x+1, y+1]
  rb = [x+1, y-1]
  lb = [x-1, y-1]

  [l,r,t,b,lt,rt,rb,lb].select { |neighbor| in_range(neighbor[0], neighbor[1], graph) }
end

def visit(node, graph)
  neighbors = get_neighbors(node.x, node.y, graph)
  neighbors.each do |n|
    neighbor = graph[n[0]][n[1]]
    neighbor.visited = true
    dist = node.distance + neighbor.cost
    if dist < neighbor.distance
      neighbor.distance = dist
      neighbor.prev = node
    end
  end
end

def dijkstra(graph, source, target)
  graph[source[0]][source[1]].distance = 0
  unvisited = find_unvisited(graph)

  while unvisited.any?
    current_node = min(unvisited, graph)
    return current_node if current_node.x == target[0] && current_node.y == target[1]
    unvisited.delete(current_node)
    visit(current_node, graph)
  end
end

def convert_source(coord)
  [coord[0].ord - 96 - 1, Integer(coord[1]) -1]
end

def to_directions(from, to)
  return if to == nil
  str = ""
  if to.x > from.x
    str << "R"
  end
  if to.y > from.y
    str << "U"
  end
  if to.y < from.y
    str << "D"
  end
  if to.x < from.x
    str << "L"
  end
  str
end

def get_answer_nodes(root)
  nodes = []
  current_node = root
  while !current_node.nil?
    nodes << current_node
    current_node = current_node.prev
  end
  nodes.reverse
end

def format_answer(answer)
  nodes = get_answer_nodes(answer)
  directions = [nodes.size-1]
  nodes.each_with_index do |node, i|
    directions << to_directions(nodes[i], nodes[i+1])
  end
  directions
end

def solve
  graph = make_graph(8, 8)
  source = gets
  target = gets
  answer = dijkstra(graph, convert_source(source.chomp), convert_source(target.chomp))
  puts format_answer(answer).join("\n")
end

solve()

s = gets
t = gets
sx = s[0..0].ord
sy = s[1..1].to_i
tx = t[0..0].ord
ty = t[1..1].to_i
dx = sx-tx
dy = sy-ty
step = [dx.abs,dy.abs].max
puts step
step.times do
  if dx<0
    print "R"
    dx += 1
  elsif dx>0
    print "L"
    dx -= 1
  end
  if dy<0
    print "U"
    dy += 1
  elsif dy>0
    print "D"
    dy += 1
  end
  puts
end

class King
  def initialize(s, t)
    @start = s
    @end = t
  end

  def get_path
    result = []
    horizontal = (@start[0] == @end[0])
    vertical = (@start[1] == @end[1])
    if @start == @end
      result << 0
    elsif horizontal
      result = [steps_x.abs] + [direction.last]*steps_x.abs
    elsif vertical
      result = [steps_y.abs] + [direction.first]*steps_y.abs
    else
      current = @start
      steps = 0
      until horizontal || vertical
        current = move_diag(current)
        horizontal = (current[0] == @end[0])
        vertical = (current[1] == @end[1])
        result << direction.join
        steps += 1
      end
      if vertical
        current_steps = (current[0].ord.to_i - @end[0].ord.to_i).abs
        result += [direction.last]*current_steps
        steps += current_steps
      elsif horizontal
        current_steps = (current[1].to_i - @end[1].to_i).abs
        result += [direction.first]*current_steps
        steps += current_steps
      end
      result.unshift(steps)
    end
    result
  end

  def move_diag(position)
    x_inc = steps_x == 0 ? 0 : steps_x/steps_x.abs
    y_inc = steps_y == 0 ? 0 : steps_y/steps_y.abs
    [(position[0].ord+x_inc).chr, (position[1].to_i + y_inc)].join
  end

  def direction
    [direction_y, direction_x]
  end

  def direction_x
    steps_x > 0 ? 'D' : 'U'
  end

  def direction_y
    steps_y > 0 ? 'L' : 'R'
  end

  def steps_x
    @start[1].to_i - @end[1].to_i
  end

  def steps_y
    @start[0].ord.to_i - @end[0].ord.to_i
  end
end

s, t = [gets.chomp, gets.chomp]
game = King.new(s, t)
puts game.get_path

class King
  def initialize(s, t)
    @start = s
    @end = t
  end

  def get_path
    result = []
    horizontal = (@start[0] == @end[0])
    vertical = (@start[1] == @end[1])
    if @start == @end
      result << 0
    elsif horizontal
      result = [steps_x] + [direction.last]*steps_x.abs
    elsif vertical
      result = [steps_y] + [direction.first]*steps_y.abs
    else
      current = @start
      steps = 0
      until horizontal || vertical
        current = move_diag(current)
        horizontal = (current[0] == @end[0])
        vertical = (current[1] == @end[1])
        result << direction.join
        steps += 1
      end
      if vertical
        current_steps = (current[0].ord.to_i - @end[0].ord.to_i).abs
        result += [direction.last]*current_steps
        steps += current_steps
      elsif horizontal
        current_steps = (current[1].to_i - @end[1].to_i).abs
        result += [direction.first]*current_steps
        steps += current_steps
      end
      result.unshift(steps)
    end
    result
  end

  def move_diag(position)
    x_inc = steps_x == 0 ? 0 : steps_x/steps_x.abs
    y_inc = steps_y == 0 ? 0 : steps_y/steps_y.abs
    [(position[0].ord+x_inc).chr, (position[1].to_i + y_inc)].join
  end

  def direction
    [direction_y, direction_x]
  end

  def direction_x
    steps_x > 0 ? 'D' : 'U'
  end

  def direction_y
    steps_y > 0 ? 'L' : 'R'
  end

  def steps_x
    @start[1].to_i - @end[1].to_i
  end

  def steps_y
    @start[0].ord.to_i - @end[0].ord.to_i
  end
end

s, t = [gets.chomp, gets.chomp]
game = King.new(s, t)
puts game.get_path

class King
  def initialize(s, t)
    @start = s
    @end = t
  end

  def get_path
    result = []
    horizontal = (@start[0] == @end[0])
    vertical = (@start[1] == @end[1])
    if @start == @end
      result << 0
    elsif horizontal
      result = [steps_x] + [direction.first]*steps_x.abs
    elsif vertical
      result = [steps_y] + [direction.last]*steps_y.abs
    else
      current = @start
      steps = 0
      until horizontal || vertical
        current = move_diag(current)
        horizontal = (current[0] == @end[0])
        vertical = (current[1] == @end[1])
        result << direction.join
        steps += 1
      end
      if vertical
        current_steps = (current[0].ord.to_i - @end[0].ord.to_i).abs
        result += [direction.last]*current_steps
        steps += current_steps
      elsif horizontal
        current_steps = (current[1].to_i - @end[1].to_i).abs
        result += [direction.first]*current_steps
        steps += current_steps
      end
      result.unshift(steps)
    end
    result
  end

  def move_diag(position)
    x_inc = steps_x == 0 ? 0 : steps_x/steps_x.abs
    y_inc = steps_y == 0 ? 0 : steps_y/steps_y.abs
    [(position[0].ord+x_inc).chr, (position[1].to_i + y_inc)].join
  end

  def direction
    [direction_y, direction_x]
  end

  def direction_x
    steps_x > 0 ? 'D' : 'U'
  end

  def direction_y
    steps_y > 0 ? 'L' : 'R'
  end

  def steps_x
    @start[1].to_i - @end[1].to_i
  end

  def steps_y
    @start[0].ord.to_i - @end[0].ord.to_i
  end
end

s, t = [gets.chomp, gets.chomp]
game = King.new(s, t)
puts game.get_path

s1 = gets
s2 = gets
dst1 = s2[0].ord - s1[0].ord
dst2 = s2[1].to_i - s1[1].to_i

puts [dst2.abs, dst1.abs].max
while dst2 != 0 and dst1 != 0 do
    if dst1 > 0 then
        printf "R"
        dst1 -= 1
    end
    if dst1 < 0 then
        printf "L"
        dst1 += 1
    end

    if dst2 > 0 then
        printf "U"
        dst2 -= 1
    end
    if dst2 < 0 then
        printf "D"
        dst2 += 1
    end
    puts
end

start = gets().chomp!
finish =  gets().chomp!
LETTERS = ["a", "b", "c", "d", "e", "f", "g", "h"]
h_distance, v_distance = [LETTERS.index(finish[0,1]) - LETTERS.index(start[0,1]), finish[1,1].to_i - start[1,1].to_i]
moves = Array.new(7){""}
h_distance.abs().times {
|i|
  h_distance > 0 ? moves[i] << "R" : moves[i] << "L"
}
v_distance.abs().times {
|i|
  v_distance > 0 ? moves[i] << "U" : moves[i] << "D"
}
moves.select(){|elem| elem != ""}
puts moves.length, moves

s,t = readlines.join.split
sx,sy = s[0].ord - 'a'.ord, s[1].to_i-1
gx,gy = t[0].ord - 'a'.ord, t[1].to_i-1
a=[""]*9
f = lambda{|r,c| r.times{|i| a[i] += c}}
f.call(sx-gx,'R')
f.call(gx-sx,'L')
f.call(sy-gy,'D')
f.call(gy-sy,'U')
a.select!{|i| i != ""}
puts a.size
puts a

a, b = gets.chop.split(''), gets.chop.split('')
a[1], b[1] = a[1].to_i, b[1].to_i

if a[0] > b[0]
	x_dir = "L"
elsif a[0] < b[0]
	x_dir = "R"
end

if a[1] > b[1]
	y_dir = "D"
elsif a[1] < b[1]
	y_dir = "U"
end

str = ""
count = 0

while true do

	if a[0] != b[0]
		a[0].next! if x_dir == "R"
		a[0].prev! if x_dir == "L"
		str << x_dir
	end

	if a[1] != b[1]
		a[1] += 1 if y_dir == "U"
		a[1] -= 1 if y_dir == "D"
		str << y_dir
	end

	count += 1
	str << "\n"

	break if a == b

end

STDOUT.print count, "\n", str


#exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},'/usr/bin/ruby', $0) if !ENV['RUBY_THREAD_VM_STACK_SIZE']

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

hx = {}
hy = {}
a = inp
b = inp
c = inp
x = [a[0],a[2],b[0],b[2],c[0],c[2]].sort
y = [a[1],a[3],b[1],b[3],c[1],c[3]].sort
x.each.with_index do |d,i|
  hx[d] = i
end
y.each.with_index do |d,i|
  hy[d] = i
end
t = na2(x.size,y.size,false)
(hx[a[0]]...hx[a[2]]).each do |x|
  (hy[a[1]]...hy[a[3]]).each do |y|
    t[x][y] = true
  end
end
(hx[b[0]]...hx[b[2]]).each do |x|
  (hy[b[1]]...hy[b[3]]).each do |y|
    t[x][y] = false
  end
end
(hx[c[0]]...hx[c[2]]).each do |x|
  (hy[c[1]]...hy[c[3]]).each do |y|
    t[x][y] = false
  end
end

puts (t.flatten.include?(true))? "YES" : "NO"

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 bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} 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
########### ( ˘ω˘ )ｽﾔｧ… ###########
x1,y1,x2,y2=gsmi
x3,y3,x4,y4=gsmi
x5,y5,x6,y6=gsmi

# full cover
if (x3<=x1&&y3<=y1&&x4>=x2&&y4>=y2)||(x5<=x1&&y5<=y1&&x6>=x2&&y6>=y2)
  putsend('NO')
end
# half cover
# たて
if (y3<=y1&&y4>=y2 &&y5<=y1&&y6>=y2) && ((x5<=x2&&x6>=x2&&x3<=x1&&x4>=x1&&x4>=x5)||(x3<=x2&&x4>=x2&&x5<=x1&&x6>=x1&&x6>=x3))
  putsend('NO')
end
# よこ
if (x3<=x1&&x4>=x2 &&x5<=x1&&x6>=x2) && ((y5<=y2&&y6>=y2&&y3<=y1&&y4>=y1&&y4>=y5)||(y3<=y2&&y4>=y2&&y5<=y1&&y6>=y1&&y6>=y3))
  putsend('NO')
end

putsend('YES')

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 bs(ar,eq,n) en=(eq==1 ? :>= : :>); ar.bsearch_index{|x|x.send(en,n)} 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
########### ( ˘ω˘ )ｽﾔｧ… ###########
x1,y1,x2,y2=gsmi
x3,y3,x4,y4=gsmi
x5,y5,x6,y6=gsmi

# full cover
if (x3<=x1&&y3<=y1&&x4>=x2&&y4>=y2)||(x5<=x1&&y5<=y1&&x6>=x2&&y6>=y2)
  putsend('NO')
end
# half cover
# たて
if (y3<=y1&&y4>=y2 &&y5<=y1&&y6>=y2) && ((x5<=x2&&x6>=x2&&x3<=x1&&x4>=x1&&x4>=x5)||(x3<=x2&&x4>=x2&&x5<=x1&&x6>=x1&&x6>=x4))
  putsend('NO')
end
# よこ
if (x3<=x1&&x4>=x2 &&x5<=x1&&x6>=x2) && ((y5<=y2&&y6>=y2&&y3<=y1&&y4>=y1&&y4>=y5)||(y3<=y2&&y4>=y2&&y5<=y1&&y6>=y1&&y6>=y4))
  putsend('NO')
end

putsend('YES')


#!/usr/bin/env ruby
puts gets.to_i.to_s(8).chars.count('1')

a=gets.chomp.to_i.to_s(8)
b=a.count("1")
puts "#{b}"

# print number of ones in BASE 8 notaion of a
p gets.to_i.to_s(8).chars.count ?1

n = gets.to_i

puts n.to_s(8).count('1')

# print number *** BASE 8 notaion of a
p gets.to_i % 8

# print number *** BASE 8 notaion of a
s = gets.to_i.to_s 8
p s.chars.map(&:to_i).reduce(:+) / s.size

#!/usr/bin/env ruby
puts gets.to_i.to_s(8)[-1]


n, k = gets.strip.split.map(&:to_i)
remainder = n / k
ans = k * remainder + k
puts ans

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

x = (n/k).to_i

puts (x+1)*k

n,k = gets.split(' ').map(&:to_i)
puts ((n/k) * k) + k

# cook your code here

a1,b1=gets.chomp.split

n = a1.to_i
k = b1.to_i

n = n + k - n%k

puts n

n, k = gets.strip.split.map(&:to_i)
mod = n % k
remainder = 0
remainder = n / k if mod != 0
remainder = mod if mod ==
ans = n + remainder
ans += k if remainder == 0
puts ans

n, k = gets.strip.split.map(&:to_i)
mod = n % k
remainder = mod
remainder = n / k if mod != 0
ans = n + remainder
ans += k if remainder == 0
puts ans


# Codeforces Beta Round #80
# Problem A -- Blackjack
cards = [0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 15, 4]
n = gets.to_i - 10
puts (0 <= n and n <= 11) ? cards[n] : 0

#!/usr/bin/env ruby

def solve n
  diff = n - 10
  if 1 < diff and diff < 10
    return 4
  end
  if diff == 1 or diff == 11
    return 4
  end
  if diff == 10
    return 4*3+3
  end
  return 0 # if diff < 0 and 11 < diff
end

#n = STDIN.gets.split.map {|i| i.to_i }

puts solve(STDIN.gets.to_i)

n = gets.chomp.to_i - 10
if n < 1 || n > 11
  puts 0
elsif n == 10
  puts 15
else
  puts 4
end

need = STDIN.readline.to_i - 10
if need == 10
  puts 15
elsif need >= 1 and need <= 11
  puts 4
else
  puts 0
end

n = gets.to_i
if n <= 10 or n >= 22
  puts 0
else
  if n== 20
    puts 15
  else
    puts 4
  end
end

#104A
n=gets.to_i
if n <= 10
    puts "0"
elsif n >= 11 and n <= 19
    puts "4"
elsif n == 20
    puts "15"
elsif n == 21
    puts"4"
else
    puts "0"
end

a=gets.chomp.to_i
a=a-10
if a<=0 || a>=12
puts "0"
elsif a==10
puts "15"
else
puts "4"
end

def blackjack
  c = { }
  1.upto(11) { |i| c[i] = 4 }
  c[10] = 15

  goal = gets.to_i
  if goal-10 < 1
    puts 0
  else
    puts (c.has_key?(goal-10)) ? c[goal-10] : 0
  end
end

blackjack

case gets.chomp.to_i
  when 11..19, 21
    puts 4
  when 20
    puts 15
  else
    puts 0
end

s=gets.to_i
need=s-10

data=[10]*(3*4-1)+[1, 11]
for i in 2..10
	data+=[i]*4
end

puts data.count(need)

def blackjack
  c = { }
  1.upto(11) { |i| c[i] = 4 }
  c[10] = 15

  goal = gets.to_i
  if goal-10 < 1
    puts 0
  else
    puts c[goal-10]
  end
end

blackjack

#!/usr/bin/env ruby

def solve n
  diff = n - 10
  return 0 if diff < 0 and 10 < diff
  if 1 < diff and diff < 10
    return 4
  end
  if diff == 1
    return 4
  end
  if diff >= 10
    return 4*3+3
  end
end

#n = STDIN.gets.split.map {|i| i.to_i }

puts solve(STDIN.gets.to_i)

#!/usr/bin/env ruby

def solve n
  return 0 if n < 11
  diff = n - 10
  if 1 < diff and diff < 10
    return 4
  end
  if diff == 1
    return 4
  end
  if diff >= 10
    return 4*3+3
  end
end

#n = STDIN.gets.split.map {|i| i.to_i }

puts solve(STDIN.gets.to_i)

#!/usr/bin/env ruby

def solve n
  diff = n - 10
  return 0 if diff < 0 and 11 < diff
  if 1 < diff and diff < 10
    return 4
  end
  if diff == 1 or diff == 11
    return 4
  end
  if diff >= 10
    return 4*3+3
  end
end

#n = STDIN.gets.split.map {|i| i.to_i }

puts solve(STDIN.gets.to_i)


# http://codeforces.com/contest/592/problem/A
# A. PawnChess

cols = [].tap do |arr|
  8.times { arr << gets.chomp.chars }
end
b_idx = []
w_idx = []
cols.transpose.each do |row|
  b = row.rindex('B')
  w = row.rindex('W')
  b_idx << 7 - b if b && (w.nil? || (b > w))

  b = row.index('B')
  w = row.index('W')
  w_idx << w if w && (b.nil? || (b > w))
end

if !b_idx.empty? && (w_idx.empty? || b_idx.min < w_idx.min)
  puts 'B'
else
  puts 'A'
end

Board = Array.new( 8 ) do | i |
	gets.chomp.split( "" )
end
.transpose.freeze;

a = 8; b = 8
Board.each do |row|
	8.times do | i |
		if row[i] != '.'
			if row[i] == 'W'
				a = [ a, i ].min
			end
			break
		end
	end
	7.downto( 0 ) do | i |
		if row[i] != '.'
			if row[i] == 'B'
				b = [ b, 7 - i ].min
			end
			break
		end
	end
end

puts ( a <= b ? "A" : "B" )

matr=[]
8.times{matr<<gets.split("")}
a,b=9,9

8.times do |j|
  tmp=0
  8.times do |i|
    if matr[i][j] == "W"
      tmp=i
      a=[tmp,a].min
      break
    elsif matr[i][j] == "B"
      break
    end
  end
end

8.times do |j|
  tmp=0
   (0..7).to_a.reverse.each do |i|
    if matr[i][j] == "B"
      tmp=7-i
    b=[tmp,b].min
      break
    elsif matr[i][j] == "W"
      break
    end
  end
end

puts a>b ? "B" : "A"

#! /usr/bin/env ruby

board = 8.times.collect { $stdin.gets.chomp }

w = 100
b = 100
for c in 0..7
  for r in 0..7
    board[r][c] == 'B' and break
    board[r][c] == 'W' and w = [w, r].min
  end
  for r in (0..7).reverse_each
    board[r][c] == 'W' and break
    board[r][c] == 'B' and b = [b, 7-r].min
  end
end

puts (w <= b ? 'A': 'B')

#!/usr/bin/env ruby

require 'matrix'

rows = 8.times.map do gets.chars.to_a end
MATRIX = Matrix.rows(rows)

def win_in_colA(col_no)
  (0..7).each do |row_no|
    if MATRIX[row_no, col_no] == 'W'
      return row_no
    elsif MATRIX[row_no, col_no] == 'B'
      return 9
    end
  end
  return 9
end

def win_in_colB(col_no)
  (0..7).to_a.reverse.each do |row_no|
    if MATRIX[row_no, col_no] == 'B'
      return 7-row_no
    elsif MATRIX[row_no, col_no] == 'W'
      return 9
    end
  end
  return 9
end

steps_for_A = (0..7).map do |col_n|
  win_in_colA(col_n)
end

steps_for_B = (0..7).map do |col_n|
  win_in_colB(col_n)
end

who_won = (steps_for_B.min < steps_for_A.min) ? 'B' : 'A'
puts who_won

field = []
while line = gets
  field << line.chomp.split("")
end
field = field.transpose
stepA = []
stepB = []
field.each do |r|
  a = r.rindex("W")
  b = r.rindex("B")
  unless b.nil? then
    if a.nil? or (a < b) then
      stepB << 7 - b
    end
  end
  a = r.index("W")
  b = r.index("B")
  unless a.nil? then
    if b.nil? or (a < b) then
      stepA << a
    end
  end
end
if stepB.empty? or (stepA.min <= stepB.min) then
  puts "A"
elsif stepA.empty? or (stepA.min > stepB.min) then
  puts "B"
end

a = Array.new(8)
c = [0] * 8
for x in 0..7
    a[x] = gets
end
flag = 0
for x in 0..7
    for y in 0..7
        if a[x][y] == "W" and c[y] == 0
            w = x;
            flag = 1;
            break;
        end
        if a[x][y] == "B"
            c[y] = 1;
        end
    end
    if flag == 1
        break
    end
end
c = [0] * 8
flag = 0
for x in 0..7
    for y in 0..7
        if a[7 - x][y] == 'B' and c[y] == 0
            b = x;
            flag = 1;
            break;
        end
        if a[7 - x][y] == 'W'
            c[y] = 1;
        end
    end
    if flag == 1
        break;
    end
end
if w > b
    print "B\n"
else
    print "A\n"
end

n, a1, a2, min, c = [], [], [], 99999, ''
(0..7).each do |_|
  n << gets.chomp.split('')
end
(0..7).each do |i|
  arr, a1, a2 = [], [], []
  (0..7).each do |j|
    arr << n[j][i]
  end
  x = Array.new arr
  y = Array.new arr
  x.uniq!.delete('.')
  y.reverse!.uniq!.delete('.')
  a1 = x
  a2 = y
  if a1.size == 0
  	next
  elsif a1.size == 1
  	d = a1.first == 'W' ? arr.index('W') : arr.reverse.index('B')
  	if (d < min) || (d == min && a1.first == 'W')
  		min = d
  		c = a1.first
  	end
  else
		if a1.first == 'W' && arr.index('W') <= min
			min = arr.index('W')
			c = 'W'
		end
		if a2.first == 'B' && arr.reverse.index('B') < min
			min = arr.reverse.index('B')
			c = 'B'
		end
  end
end
puts c == 'W' ? 'A' : 'B'

class Solver
	def main
		f = []
		8.times { f << gets }
		ans_w = 10
		ans_b = 10
		8.times do |i|
			8.times do |j|
				if f[i][j] == "W" then
					flag = true
					tmp = i - 1
					while tmp >= 0 do
						flag = false if f[tmp][j] != '.'
						tmp -= 1
					end
					ans_w = [ans_w, i].min if flag
				elsif f[i][j] == "B" then
					flag = true;
					tmp = i + 1
					while tmp < 8 do
						flag = false if f[tmp][j] != '.'
						tmp += 1
					end
					ans_b = [ans_b, 7 - i].min if flag
				end
			end
		end
		puts ans_w <= ans_b ? "A" : "B"
	end
end

Solver.new.main

# http://codeforces.com/contest/592/problem/A
# A. PawnChess

cols = [].tap do |arr|
  8.times { arr << gets.chomp.chars }
end
rows = cols.transpose.reject do |row|
  row.include?('B') && row.include?('W')
end

b_indexes = rows.map { |row| row.rindex('B') }.compact.map { |idx| 8 - idx }
w_indexes = rows.map { |row| row.index('W') }.compact

if b_indexes.min < w_indexes.min
  puts 'B'
else
  puts 'A'
end

# http://codeforces.com/contest/592/problem/A
# A. PawnChess

cols = [].tap do |arr|
  8.times { arr << gets.chomp.chars }
end
rows = cols.transpose.reject do |row|
  row.include?('B') && row.include?('W')
end

b_indexes = rows.map { |row| row.rindex('B') }.compact.map { |idx| 7 - idx }
w_indexes = rows.map { |row| row.index('W') }.compact

if w_indexes.empty? || b_indexes.min < w_indexes.min
  puts 'B'
else
  puts 'A'
end

# http://codeforces.com/contest/592/problem/A
# A. PawnChess

cols = [].tap do |arr|
  8.times { arr << gets.chomp.chars }
end
b_idx = []
w_idx = []
rows = cols.transpose.reject do |row|
  b = row.rindex('B')
  w = row.rindex('W')
  if b && (w.nil? || (b > w))
    b_idx << 7 - b
  end

  b = row.index('B')
  w = row.index('W')
  if w && (b.nil? || (w > b))
    w_idx << w
  end
end

if !b_idx.empty? && (w_idx.empty? || b_idx.min < w_idx.min)
  puts 'B'
else
  puts 'A'
end

#!/usr/bin/env ruby

require 'matrix'

rows = 8.times.map do gets.chars.to_a end
MATRIX = Matrix.rows(rows)

def win_in_colA(col_no)
  (0..7).each do |row_no|
    if MATRIX[row_no, col_no] == 'W'
      return row_no
    elsif MATRIX[row_no, col_no] == 'B'
      return 9
    end
  end
  return 9
end

def win_in_colB(col_no)
  (0..7).to_a.reverse.each do |row_no|
    if MATRIX[row_no, col_no] == 'B'
      return 7-row_no
    elsif MATRIX[row_no, col_no] == 'W'
      return 9
    end
  end
  return 9
end

steps_for_A = (0..7).map do |col_n|
  win_in_colA(col_n)
end
print steps_for_A
puts

steps_for_B = (0..7).map do |col_n|
  win_in_colB(col_n)
end
print steps_for_B

who_won = (steps_for_B.min < steps_for_A.min) ? 'B' : 'A'
puts who_won

#!/usr/bin/env ruby

require 'matrix'

rows = 8.times.map do gets.chars.to_a end
MATRIX = Matrix.rows(rows)

def win_in_colB(col_no)
  (0..7).each do |row_no|
    if MATRIX[row_no, col_no] == 'B'
      return row_no+1
    elsif MATRIX[row_no, col_no] == 'W'
      return 9
    end
  end
  return 9
end

def win_in_colA(col_no)
  (0..7).to_a.reverse.each do |row_no|
    if MATRIX[row_no, col_no] == 'W'
      return 8-row_no
    elsif MATRIX[row_no, col_no] == 'B'
      return 9
    end
  end
  return 9
end

steps_for_A = (0..7).map do |col_n|
  win_in_colA(col_n)
end

steps_for_B = (0..7).map do |col_n|
  win_in_colB(col_n)
end

who_won = (steps_for_B.min < steps_for_A.min) ? 'B' : 'A'
puts who_won

field = []
while line = gets
  field << line.chomp.split("")
end
field = field.transpose
stepA = []
stepB = []
field.each do |r|
  a = r.rindex("W")
  b = r.rindex("B")
  unless b.nil? then
    if a.nil? or (a < b) then
      stepB << 7 - b
    end
  end
  a = r.index("W")
  b = r.index("B")
  unless a.nil? then
    if b.nil? or (a < b) then
      stepA << 7 - a
    end
  end
end
if stepB.empty? or (stepA.min < stepB.min) then
  puts "A"
elsif stepA.empty? or (stepA.min > stepB.min) then
  puts "B"
end

a = Array.new(8)
for x in 0..7
    a[x] = gets
end
for x in 0..7
    for y in 0..7
        if a[7 - x][y] == 'B'
            print "B\n"
            exit
        end
        if a[7 - x][y] == 'W'
            print "A\n"
            exit
        end
    end
end

n, a1, a2, min, c = [], [], [], 99999, ''
(0..7).each do |_|
  n << gets.chomp.split('')
end
(0..7).each do |i|
  arr, a1, a2 = [], [], []
  (0..7).each do |j|
    arr << n[j][i]
  end
  x = Array.new arr
  y = Array.new arr
  x.uniq!.delete('.')
  y.reverse!.uniq!.delete('.')
  a1 = x
  a2 = y
  if a1.size == 0
  	next
  elsif a1.size == 1
  	d = a1.first == 'W' ? arr.index('W') : arr.reverse.index('B')
  	if d < min || (d == min && c == 'W')
  		min = d
  		c = a1.first
  	end
  else
		if a1.first == 'W' && arr.index('W') <= min
			min = arr.index('W')
			c = 'W'
		end
		if a2.first == 'B' && arr.reverse.index('B') < min
			min = arr.reverse.index('B')
			c = 'B'
		end
  end
end
puts c == 'W' ? 'A' : 'B'

arr, arr1, arr2, index, min, result, c = [], [], [], 1000000, 99999, '', ''
(0..7).each do |_|
  arr << gets.chomp.split('')
end
(0..7).each do |i|
  arr1 = []
  (0..7).each do |j|
    arr1 << arr[j][i]
  end
  arr2 = Array.new arr1
  arr2.uniq!.delete('.')
  if arr2[0] && arr2.size == 1
    c = arr2[0]
    if c == 'W'
      index = arr1.index(c)
    else c == 'B'
      index = arr1.reverse.index(c)
    end
  end
  if index < min
    min = index
    result = c
  end
end
puts result == 'W' ? 'A' : 'B'

arr, arr1, arr2, index, min, result, c = [], [], [], 1000000, 99999, '', ''
(0..7).each do |_|
  arr << gets.chomp.split('')
end
(0..7).each do |i|
  arr1 = []
  (0..7).each do |j|
    arr1 << arr[j][i]
  end
  arr2 = Array.new arr1
  arr2.uniq!.delete('.')
  if arr2[0] && arr2.size == 1
    c = arr2[0]
    if c == 'W'
      index = arr1.index(c)
    else c == 'B'
      index = arr1.reverse.index(c)
    end
  end
  min = index; result = c if index < min
end
p result == 'W' ? 'A' : 'B'

arr, arr1, arr2, index, min, result, c = [], [], [], 1000000, 99999, '', ''
(0..7).each do |_|
  arr << gets.chomp.split('')
end
(0..7).each do |i|
  arr1 = []
  (0..7).each do |j|
    arr1 << arr[j][i]
  end
  arr2 = Array.new arr1
  arr2.uniq!.delete('.')
  if arr2[0] && arr2.size == 1
    c = arr2[0]
    if c == 'W'
      index = arr1.index(c)
    else c == 'B'
      index = arr1.reverse.index(c)
    end
  end
  if index < min
    min = index
    result = c
  end
end
p result == 'W' ? 'A' : 'B'

arr, arr1, arr2, index, min, result, c = [], [], [], 1000000, 99999, '', ''
(0..7).each do |_|
  arr << gets.chomp.split('')
end
(0..7).each do |i|
  arr1 = []
  (0..7).each do |j|
    arr1 << arr[j][i]
  end
  arr2 = Array.new arr1
  arr2.uniq!.delete('.')
  if arr2[0] && arr2.size == 1
    c = arr2[0]
    if c == 'W'
      index = arr1.index(c)
    else c == 'B'
      index = arr1.reverse.index(c)
    end
  end
  if index < min
    min = index
    result = c
  end
end
p result == 'W' ? :A : :B

class Solver
	def main
		map = []
		8.times do
			map << gets.chomp
		end
		move_a = 9
		move_b = 9

		8.times do |i|
			up_most_w = 10
			down_most_b = -1
			8.times do |j|
				up_most_w = [up_most_w, j].min if map[j][i] == "W"
				down_most_b = [down_most_b, j].max if map[j][i] == "B"
			end
			if up_most_w == 10 && down_most_b != -1 then
				move_b = [move_b, 7 - down_most_b].min
			elsif up_most_w != 10 && down_most_b == -1 then
				move_a = [move_a, up_most_w].min
			elsif up_most_w != 10 && down_most_b != -1 then
				if up_most_w < down_most_b then
					move_a = [move_a, up_most_w].min
					move_b = [move_b, 7 - down_most_b].min
				end
			end
		end

		if move_a <= move_b then
			puts "A"
		else
			puts "B"
		end
	end
end

Solver.new.main


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

class Solver
  def initialize(n, k, x, a)
    @n = n
    @k = k
    @x = x
    @a = a
  end

  def cnt(l, r)
    ans = 0
    flag = false
    while true do
      sum = 0
      while l>-1 && @a[l] == @a[r]
        l -= 1
        sum += 1
      end
      l += 1
      while r < @n && @a[l] == @a[r]
        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
end

solver = Solver.new(n, k, x, a)
ans = 0
for i in 0..n-1
  ans = [ans, solver.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
maxi = -1
for i in 0...n - 1
  #print a[i].to_s + ' '
  if a[i] != x || a[i + 1] != x
    next
  end
  l = i - 1
  r = i + 2
  cnt = 3
  while l >= 0 && r < n && a[l] == a[r]
    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
    #print ' (' + cnt.to_s + ' ' + p1.to_s + ' ' + p2.to_s + ') '
    max = cnt
    maxi = i
  end
end
if max < 3
  max = 1
end
puts max - 1

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)

# 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

# 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 - 2
  if a[i + 1] != x || a[i + 2] != 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

# 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
  r = i
  if a[i] == x && a[i + 1] == x
    l = i - 1
    r = i + 2
  end
  if a[i] == x && i > 0 && a[i - 1] == x
    l = i - 2
    r = i + 1
  end
  if a[i + 1] == x && i + 2 < n && a[i + 2] == x
    l = i
    r = i + 3
  end
  if l == i && r == i
    next
  end
  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


LIMIT = 1000000007

@res = []
l = 1
while l < LIMIT
  @res << l
  l = l * 2
end

def power i
  return @res[i] if i < @res.size
  half_power = power(i/2)
  partial = (half_power * half_power) % LIMIT
  if i % 2 == 1
    partial = (partial * 2) % LIMIT
  end
  partial
end

years = gets.to_i

if years == 0
  puts 1
else
  partial = power(years-1)
  puts (partial * (((2 * partial) % LIMIT) + 1)) % LIMIT
end

# 2^(n-1) * (2^n +1)

$p = 1000000007
def mul(a,b)
  n = a.size
  c = Array.new(n){Array.new(n){0}}
  n.times do |i|
    n.times do|j|
      n.times do |k|
        c[i][j] += a[i][k] * b[k][j]
        c[i][j] %= $p
      end
    end
  end
  c
end

def po(m)
  e = [[3,1],[1,3]]
  ret = [[1,0],[0,1]]

  while m > 0
    if m % 2 == 1
      ret = mul(ret,e)
    end
    e = mul(e,e)
    m /= 2
  end

  ret
end

def work(n)
    if n == 1
      puts 3
    else
      ret = po(n)
      ans = ret[0][0]
      puts ans % $p
    end
end

n = gets.to_i
work n
#10.times{|x| work x+1}

def pow(a,k)
  n = 1000000007
  b = 1
  while (k!= 0) do
    if (k % 2 == 0 ) then
      k/=2
      a = (a*a) % n
    else
      k-=1
      b = (b*a) % n
    end
  end
  return b
end

n = gets.to_i
k = pow(2,n)
k = (k*(k-1)/2) % 1000000007
if (n == 0) then
  puts "1"
else
  ans = (pow(4,n) - k) % 1000000007
  puts ans
end

def pow(a,k)
  n = 1000000007
  b = 1
  while (k!= 0) do
    if (k % 2 == 0 ) then
      k/=2
      a = (a*a) % n
    else
      k-=1
      b = (b*a) % n
    end
  end
  return b
end

n = gets.to_i
if (n == 0) then
  puts "1"
else
  ans = pow(4,n)/2 + pow(2,n-1)
  puts ans
end

def pow(a,k)
  n = 1000000007
  b = 1
  while (k!= 0) do
    if (k % 2 == 0 ) then
      k/=2
      a = (a*a) % n
    else
      k-=1
      b = (b*a) % n
    end
  end
  return b
end

n = gets.to_i
if (n == 0) then
  puts "1"
else
  ans = (pow(4,n)/2 + pow(2,n-1)) % 1000000007
  puts ans
end


#!/usr/bin/env ruby

N = gets.to_i

def total_sections
  return 1 if N == 3
  return 4 if N == 4

  sections_without_2_triangles = (3..N-2).map do |second_vertice|
    third_vertice = second_vertice + 1

    lines_from_second = N - second_vertice - 1
    lines_from_third = third_vertice - 3

    lines_from_second + lines_from_third + 1
  end.inject(:+)

  sections_without_2_triangles + (N-2)*2
end

puts total_sections

angles = gets.to_i
puts (angles - 2) * (angles - 2)

n = gets.chomp.to_i
puts n ** 2 - 4 * n + 4

class Solver
	def main
		n = gets.to_i
		puts (n - 2) ** 2
	end
end

Solver.new.main

n = gets.to_i
puts n * (n - 3) - (n - 4)

n = gets.chomp.to_i
if n == 3 then
  puts 1
else
  a1 = 1
  4.upto(n).each do |a|
    a1 += 3 + 2*(a-4)
  end
  puts a1
end

#! /usr/bin/env ruby

n = $stdin.gets.to_i
puts (n-2)**2

n=gets.chomp.to_i
n=(n-1)*(n-3)+1
puts n.inspect


mas = gets.split(" ")
n, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i
per, ch = k-n-m+2, 2*(m-1)
if k < (n+m-1)
	finvar = k < n ? [k+1, 1] : [n, k-n+2]
else
	is = per % (m-1) == 0 ? (n-per/(m-1)) : (n-per/(m-1)-1)
	prom = per % ch
	if prom == 0
		prom = ch
	end
	finvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]
end
puts finvar[0], finvar[1]

mas = gets.split(" ")
n, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i
per, ch = k-n-m+2, 2*(m-1)
if k < (n+m-1)
	finvar = k < n ? [k+1, 1] : [n, k-n+2]
else
	if per % (m-1) == 0
		is = n - per/(m-1)
	else
		is = n - per/(m-1) - 1
	end
	prom = per % ch
	if prom == 0
		prom = ch
	end
	finvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]
end
puts finvar[0], finvar[1]

n, m, k = gets.split.map(&:to_i)
if k < n
    puts "#{k + 1} 1"
else
    hoge = (m - 1) * 2
    k -= n
    r = n - k / hoge * 2
    tmp = k % hoge
    c = 0
    if tmp < m - 1
        c = tmp + 2
    else
        c = 2 * (m - 1) - tmp + 1
        r -= 1
    end
    puts "#{r} #{c}"
end

mas = gets.split(" ")
n, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i
per, ch = k-n-m+2, 2*(m-1)
if k < (n+m-1)
	finvar = k < n ? [k+1, 1] : [n, k-n+2]
else
	is = per % (m-1) == 0 ? (n-per/(m-1)) : (n-per/(m-1)-1)
	prom = per % ch == 0 ? ch : (per % ch)
	finvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]
end
puts finvar[0], finvar[1]

mas = gets.split(" ")
n, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i
if k < (n+m - 1)
	finvar = k < n ? [k+1, 1] : [n, k-n+2]
else
	is = n - (Float(k-(n+m-2))/(m-1)).ceil
	ncheck = n % 2
	ischeck = is % 2
	if (ncheck ^ ischeck) == 0
		finvar = [is, 2 + ((k - (n+m-2)) % (m))]
	else
		if (per = ((k - (n+m-2)) % (m-1))) == 0
			finvar = [is, 2]
		else
			finvar = [is, m + 1 - per]
		end
	end
end
puts finvar[0], finvar[1]

mas = gets.split(" ")
n, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i
if k < (n+m - 1)
	finvar = k < n ? [k+1, 1] : [n, k-n+2]
else
	is = n - (Float(k-(n+m-2))/(m-1)).ceil
	finvar = [is, 2 + ((k - (n+m-2)) % (m-1))]
end
puts finvar[0], finvar[1]

mas = gets.split(" ")
n, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i
if k < (n+m - 1)
	finvar = k < n ? [k+1, 1] : [n, k-n+2]
else
	is = n - (Float(k-(n+m-2))/(m-1)).ceil
	prom = (k-n-m+2) % (2*(m-1))
	if prom == 0
		prom = 2*(m-1)
	end
	finvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]
end
puts finvar[0], finvar[1]

mas = gets.split(" ")
n, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i
per, ch = k-n-m+2, 2*(m-1)
if k < (n+m-1)
	finvar = k < n ? [k+1, 1] : [n, k-n+2]
else
	if per % (m-1) == 0
		is = n - per/(m-1)
	else
		is = n - (Float(per)/(m-1)).floor - 1
	end
	prom = per % ch
	if prom == 0
		prom = ch
	end
	finvar = prom <= (m-1) ? [is, m-prom+1] : [is, 1+prom-(m-1)]
end
puts finvar[0], finvar[1]

mas = gets.split(" ")
n, m, k = mas[0].to_i, mas[1].to_i, mas[2].to_i
if k < (n+m - 1)
	finvar = k < n ? [k+1, 1] : [n, k-n+2]
else
	is = n - (Float(k-(n+m-2))/(m-1)).ceil
	ncheck = n % 2
	ischeck = is % 2
	if (ncheck ^ ischeck) == 0
		finvar = [is, 2 + ((k - (n+m-2)) % (m-1))]
	else
		if (per = ((k - (n+m-2)) % (m-1))) == 0
			finvar = [is, 2]
		else
			finvar = [is, m + 1 - per]
		end
	end
end
puts finvar[0], finvar[1]


N, M, R = gets.split.map(&:to_i)
S = gets.split.map(&:to_i)
B = gets.split.map(&:to_i)

s = S.min
cnt = R / s
b = B.max
diff = b - s

money = R + diff * cnt
puts [money, R].max

n,m,r = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).min
b = gets.split.map(&:to_i).max
p a < b ? (r/a)*b + r % a : r

n,m,r = gets.split.map(&:to_i)
s = gets.split.map(&:to_i).min
b = gets.split.map(&:to_i).max
if s > b
    puts r
else
    puts r%s+(r/s)*b
end

n, m, r = gets.chomp.split.map(&:to_i)
buy = gets.chomp.split.map(&:to_i).min
sell = gets.chomp.split.map(&:to_i).max

if sell > buy
  shares = r / buy
  profit = shares * (sell - buy)
  r += profit
end

puts r


#!/usr/bin/ruby
# Made With LOVE <3

n = gets.to_i
i=1
s=0
while i<=n
s = s + n - (i-1)
i*=10
end

puts s

# cook your code here

a = gets.to_i
b = 0
ans = 0

until a < b
    ans = ans + a - b;
    b = 10*b + 9
end

puts ans

def f(n)
    result, total, k = 0, 10, 1

    while n >= total do
       result += k * (total - total / 10)
       k += 1
       total *= 10
    end

    result + (n - total / 10 + 1) * k
end

puts f(gets.to_i)

n = gets.chomp

digit_count = n.length
n = n.to_i

result = (n - (10 ** (digit_count - 1) - 1)) * digit_count

result += (1..(digit_count - 1)).inject(0) do |sum, count|
	sum + (9 * 10 ** (count - 1)) * count
end

puts result

n = gets.to_i
ans = 0
len = 1
base = 10
while true
    if n < base then
        ans += (n - base / 10 + 1) * len
        break
    else
        ans += base / 10 * 9 * len
    end
    len += 1
    base *= 10
end
puts ans

# http://codeforces.com/contest/552/problem/B
n = gets.chomp.to_i
sum = 0

(0...n.to_s.chars.length).each do |idx|
  d = [9 * (10 ** idx), n].min
  n -= d
  sum += d * (idx + 1)
end

puts sum

# coding: utf-8

# 총 기록해야하는 숫자의 개수를 의미를 가리킵니다.
# n = 13의 경우
# n[1..9]: 1, 2, 3, 4, 5, 6, 7, 8, 9 -> 9글자
# n[10..13]: 10, 11, 12, 13 -> 8글자
# 총 합쳐서 17글자가 필요합니다.

n = gets.to_i
t = 0
for i in 1..10
    s, e = 10**(i-1), (10**i) - 1
    #p [s,e]
    if e < n
        t += (e - s + 1) * i # 10 ~ 99 -> 총 몇개의 숫자가 존재할까, 89개가 아니라 90개
    else
        if s <= n
            t += (n - s + 1) * i
        else
            break
        end
    end
end

puts t

number = gets.chomp.to_i
result = 0
maxDigit = 10
divisor = 1000000000

until number / divisor != 0
	maxDigit -= 1
	divisor /= 10
end

nowDigit = 1

until nowDigit == maxDigit
	result += (9 * (10**(nowDigit - 1))) * nowDigit

	nowDigit += 1
end

result += ((number - (10**(maxDigit - 1))) + 1) * maxDigit

puts result

a=gets.chomp
l=a.length-1
if l==0
puts a
else
ans=9
2.upto l do |i|
ans+= (9*(10**(i-1)))*i
end
ans+=(a.to_i-("9"*l).to_i)*(l+1)
puts ans.inspect
end

n = gets.chomp
ans = 0
num = 9
(1...n.size).each do |i|
    ans += i*num
    num *= 10
end
ans += n.size*(n.to_i-10**(n.size-1)+1)
puts ans

n = gets.to_i
ans = 0
n.to_s.chars.size.times do |i|
  a = [9 * (10 ** i), n].min
  n -= a
  ans += a * (i + 1)
end
p ans

a=gets.to_i
r=9
ans=0
while a>0
	ans+=a
	a-=r
	r*=10
end

puts ans

#!/usr/bin/env ruby

num = ARGF.gets.chomp
length = num.length
count = 0
if length > 1
    num = (num.to_i - ('9' * (length - 1)).to_i).to_s
end

count += (num.to_i) * length

length -= 1
while (length > 0) do
    count += (9 * 10**(length - 1)) * length
    length -= 1
end

puts count

n = gets.to_i
d = n.to_s.length

ans = n * d
1.upto(d - 1) do |i|
	ans -= (d - i) * 9 * 10 ** (i - 1)
end
puts ans

n = gets.to_i
s = 1
ans = 0
while s.to_s.length < n.to_s.length
  ans += s * 9 * s.to_s.length
  s *= 10
end
ans += (n - s + 1) * n.to_s.length
p ans

#!/usr/bin/env ruby

num = ARGF.gets.chomp
length = num.length
count = 0
if length > 1
    num = num[1..-1]
end
count += (num.to_i + 1) * length
if length == 1
    count -= 1
end

length -= 1
while (length > 0) do
    count += (9 * 10**(length - 1)) * length
    length -= 1
end

puts count

n = gets.chomp

digit_count = n.length
n = n.to_i

result = (n - (10 ** (digit_count - 1) - 1)) * digit_count

result += (1..(digit_count - 1)).inject(0) do |sum, count|
	sum + ('9' * count).to_i * count
end

result

n = gets.chomp

digit_count = n.length
n = n.to_i

result = (n - (10 ** (digit_count - 1) - 1)) * digit_count

result += (1..(digit_count - 1)).inject(0) do |sum, count|
	sum + ('9' * count).to_i * count
end

puts result

#!/usr/bin/ruby
# Made With LOVE <3

n = gets.to_i
i=1
s=0
while i<n
s += n - (i-1)
i*=10
end

puts s

# coding: utf-8

# 총 기록해야하는 숫자의 개수를 의미를 가리킵니다.
# n = 13의 경우
# n[1..9]: 1, 2, 3, 4, 5, 6, 7, 8, 9 -> 9글자
# n[10..13]: 10, 11, 12, 13 -> 8글자
# 총 합쳐서 17글자가 필요합니다.

n = gets.to_i
t = 0
for i in 1..10
    s, e = 10**(i-1), (10**i) - 1
    #p [s,e]
    if e < n
        t += (e - s + 1) * i # 10 ~ 99 -> 총 몇개의 숫자가 존재할까, 89개가 아니라 90개
    else
        if s < n
            t += (n - s + 1) * i
        else
            break
        end
    end
end

puts t


a=gets.chomp.to_i
ans=0
loop do
if a%2==1
    ans+=1
end
a=a/2
break if a==0
end
puts "#{ans}"

user_input = gets.chomp
user_input = user_input.to_i
count = 0
while user_input != 0
  count += user_input & 1
  user_input = user_input >> 1
end
print count

class Solver
	def main
		n = gets.to_i
		ans = (0..30).to_a.count { |i| n[i] == 1 }
		puts ans
	end
end

Solver.new.main

#!/usr/bin/ruby

n = gets.to_i
ans = 0
while n > 0
  # p  "n=#{n}, ans=#{ans}"
  ans+=1 if n % 2 == 1
  n/=2
end

puts ans

p sprintf("%b", gets.chomp).gsub('0', '').length

#! /usr/bin/env ruby

x = gets.to_i
puts x.to_s(2).count('1')

a = gets.to_i
sum = 0
(0..48).each {|n| sum += a[n]}
puts sum

n = gets.chomp.to_i

c = 0

while n > 1

  if n % 2 == 0
    n /= 2
  else
    c += 1
    n -= 1
  end
end

puts c + 1

x = gets.to_i
ans = 0
while x>0
  x=x&(x-1)
  ans += 1
end
print ans

n=gets.to_i.to_s(2)
p n.chars.count{|e|
	e=="1"
}

n = gets.to_i
r = 0
while n > 0
	if n % 2 > 0
		r += 1
	end
	n = n / 2
end
p r

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

n = gets.to_i

ans = 0
while (n > 0) do
  ans += 1 if n % 2 == 1
  n /= 2
end

p ans

x = gets.chomp.to_i

rtn = 0
while 0 < x
  rtn += x % 2
  x /= 2
end
puts rtn

num = gets.chomp.to_i
count = 0
until num == 0
  count += num%2
  num = num/2
end
p count

a = gets.to_i
ans = 0
c = 2**30
while c > 0
  ans += a / c
  a %= c
  c /= 2
end
puts ans

#!/usr/bin/ruby

n = gets.to_i
x = 1
while x*2 <= n
  x*=2
end

puts 1 + n - x

a = gets.to_i
puts a.odd? && a != 1 ? 2 : 1


n, k = gets.split(/\s+/).map {|x| x.to_i}
class Integer
  def num_at_position (k)
    chet_num, ostatok = self.divmod(2)
    nechet_num = chet_num + ostatok
    if k > nechet_num
      return (k - nechet_num) * 2
    else
      return k * 2 - 1
    end
  end
end

puts n.num_at_position(k)

def run
  n, k = $stdin.gets.split.map(&:to_i)

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

run if $0 == __FILE__

n, k = gets.chomp.split.map &:to_i
if k > (n / 2.0).ceil
  puts 2 * (k - (n / 2.0).ceil)
else
  puts 2 * k - 1
end

class A
  def initialize
    n, k = gets.split(' ').map(&:to_i)
    d = 0

    if n.even?
      if k <= n/2
        puts 2*k-1
      else
        puts 2*(k-n/2)
      end
    else
      if k <= n/2+1
        puts 2*k-1
      else
        puts 2*(k-(n/2+1))
      end
    end
  end
end

a = A.new

a=gets.chomp.split(" ")
odd=(a[0].to_i/2.0).ceil
even=(a[0].to_i/2.0)
if a[1].to_i<=odd
ans=2*(a[1].to_i-1)+1
puts "#{ans}"
else
ans=2*(a[1].to_i-odd)
puts "#{ans}"
end

n, k = gets.chomp.split(/ /).map(&:to_i)
mid = n / 2
mid += 1 if n.odd?
ans = (k - mid) * 2
ans = (2 * k) - 1 if mid >= k
puts "#{ans}"

n,k=gets.split.map{|e| e.to_i}
e=n/2+n%2
puts (k<=e)?2*k-1:(k-e)*2

n, k = gets.chomp.split.map(&:to_i)
a = n.odd? ? n/2+1 : n/2
puts k <= a ? 2*k-1 : 2*(k-a)

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

t = (n.to_f / 2).ceil

if k < t
  puts 1 + 2 * k
else
  puts 2 + 2 * (k - t)
end

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

if d % 2 == 0
  ot = d/2
  if n <= ot
    puts (2*n) - 1
  else
    puts 2*(n-ot)
  end
else
  ot = (d/2.0).ceil
  if n <= ot
    puts (2*n) - 1
  else
    puts 2*(n-ot)
  end
end

n,k=gets.split.map(&:to_i)
odd=(n+1)/2
puts k<=odd ? 2*k-1 : 2*(k-odd)

num = gets.chomp
num = num.split
numbers = num[0].to_i
position = num[1].to_i

if position <= (numbers/2) + (numbers%2)
	new_number = (position * 2) - 1
else
	new_number = (position - ((numbers/2) + (numbers%2))) * 2
end

print new_number

#puts "Enter the total number and position to find the number\n"
n, v = gets.split.map(&:to_i)
if n%2 == 0
    m = n/2
else
    m = n/2 + 1
end
if v <= m
    puts (2*v)-1
else
    puts 2*v - (2*m)
end

n,k = gets.split(" ").map(&:to_i)
even_count = n /2
odd_count = n / 2
odd_count += 1 if n % 2 != 0
ans = k > odd_count ? (k - odd_count) * 2 : k * 2 - 1
puts ans

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

if a >= b * 2 - 1 - a % 2
  puts b * 2 - 1
else
  puts (b - a/2 - a % 2) * 2
end

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

if k <= n / 2 + (n % 2 == 1 ? 1 : 0)
	puts k * 2 - 1
else
	if n % 2 == 1
		puts (k - n / 2 - 1) * 2
	else
		puts (k - n / 2) * 2
	end
end

n, k = gets.chomp.split(' ').collect { |i| i.to_i }

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

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

mid = (n+1)/2
if k>mid
 puts 2*(k-mid)
else
 puts (k*2)-1
end

n,k = gets.split(" ").map(&:to_i)
m = (n/2.0).ceil()
if(k<=m)
    print((2*k)-1)
else
    print(2*(k-m))
end

s = gets.split(' ')	#Танцы с бубном

n = s[0].to_i
k = s[1].to_i

f = k - n/2 - n%2

if f > 0
	puts 2 * f
else
	puts n - 1 + n % 2 + 2 * f
end

n, k = gets.strip.split(" ").collect{|v| v.to_i}
if k <= (n / 2.0).ceil then
  puts ((k-1)*2+1)
else
  puts ((k-(n/2.0).ceil)*2)
end

input = gets.split
n = input[0].to_i
k = input[1].to_i
half = (n/2.0).ceil

val = 0
if k > half
    val = 2
    k -= half
else
    val = 1
end

val += 2*(k-1)

print val

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

if 2*k-1 <= n
  puts 2*k-1
else
  puts 2*k - n - n%2
end

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

mid = n/2 + n%2

if k > mid
  puts (k-mid)*2
else
  puts 2*k-1
end

#!/usr/bin/env ruby

n, k = gets.split.map(&:to_i)
puts k > (n + 1) / 2 ? (k - (n + 1) / 2) * 2 : 2 * k - 1

g = gets.split(' ')

n = g[0].to_f
k = g[1].to_i

if k > (n/2).ceil
    if n.modulo(2) == 0
        i = 2*k - n
    else
        i = 2*k - n - 1
    end
else
    i = 2*k - 1
end

puts i.to_i

n,k =gets.split(' ').map{|i| i.to_i()}
ans=k+k-1
if(ans>n)
	ans=(k-((n+1)>>1))<<1
end
p ans

n, k = gets.split.map { |x| x.to_i }
evens = n / 2
odds = n - evens
offset = 0
if k > odds
	k -= odds
	offset = 1
end

puts k * 2 - 1 + offset

input = gets.chomp.split(' ').map {|item| item.to_i}

n = input[0]
k = input[1]

maxOdd = (n + 1) / 2

puts (2 * k) - 1 if k <= maxOdd
puts (2* (k - maxOdd)) if k > maxOdd

n, k = gets.split(' ').map(&:to_i)
ofs = (n+1)/2
if k <= ofs
  puts 2*k-1
else
  puts 2*(k-ofs)
end

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

n, k = *sin.readline.split.map{|e| e.to_i}
sout.puts k <= (n + 1) / 2 ? (2 * k - 1) : ((k - (n + 1) / 2) * 2)

STDIN.each_line { |l|
    l.strip!
    t = l.split(/\s+/)
    n = t[0].to_i
    k = t[1].to_i

    if k <= (n + 1) / 2 then
        puts 2 * k - 1
    else
        puts 2 * (k - (n + 1) / 2)
    end
}

n_k = gets.split.map &:to_i

n = n_k[0]
k = n_k[1]

half_n = n.even? ? n / 2 : n / 2 + 1

kth_element = k <= half_n ? 2 * k - 1 : 2 * (k - half_n)

puts kth_element

n,k = gets.split.map(&:to_i)
t=(n/2.0).ceil
p k>t ? 2*(k-t) : 2*k-1

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

cs = (n+1)/2
if k > cs
    puts (k-cs)*2
else
    puts (k*2)-1
end

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

if n%2==0
    if k <= n/2
        puts 2*(k-1)+1
    else
        k -= n/2
        puts 2*(k)
    end
else
    if k <= n/2+1
        puts 2*(k-1)+1
    else
        k -= n/2+1
        puts 2*(k)
    end
end

#!/usr/bin/env ruby
n, k = gets.split(' ').map(&:to_i)
odd = (n + 1) / 2
even = n / 2
if k <= odd
  puts k * 2 - 1
else
  puts (k - odd) * 2
end

def run
  n, k = $stdin.gets.split.map(&:to_i)

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

run if $0 == __FILE__

n, k = gets.chomp.split.map &:to_i
if k > (n / 2.0).ceil
  puts 2 * (n - (n / 2.0).ceil)
else
  puts 2 * k - 1
end

n, k = gets.chomp.split.map(&:to_i)
if k < n / 2
  puts 2 * (k-1) + 1
else
  puts 2 * ((k-1) / 2)
end

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

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

n,k=gets.split.map(&:to_i)
puts (2*k<=n ? 2*k-1 : k/2*2)

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

if k <= n / 2
	puts k * 2 - 1
else
	if n % 2 == 1
		puts (k - n / 2 - 1) * 2
	else
		puts (k - n / 2) * 2
	end
end

s = gets.split(' ')	#Танцы с бубном

n = s[0].to_i
k = s[1].to_i

a = 1
i = 1

while a <= n  && i < k
	a += 2
	i += 1
end

if i < k
	a = 2
end

while i < k
	a += 2
	i += 1
end

puts a

n = gets.to_i
k = gets.to_i

a = 1
i = 1

while a <= n  && i < k
	a += 2
	i += 1
end

if i < k
	a = 2
end

while i < k
	a += 2
	i += 1
end

puts a

input = gets.split
n = input[0].to_i
k = input[1].to_i
half = (n/2.0).ceil

val = 0
if k > half
    val = 2
    k -= half
else
    val = 1
end

for i in 1..k-1
    val += 2*(k-1)
end

print val

g = gets.split(' ')

n = g[0].to_f
k = g[1].to_i

if k > (n/2).ceil
    i = 2*k - n
else
    i = 2*k - 1
end

puts i

input = gets.chomp.split(' ').map {|item| item.to_i}

n = input[0]
k = input[1]

maxOdd = (n - 1) / 2

puts (2 * k) - 1 if k <= maxOdd
puts (k / 2) + maxOdd if k > maxOdd

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

if n%2==0
    if k <= n/2
        puts 2*(k-1)+1
    else
        puts 2*(k-1-n/2)
    end
else
    if k < n/2
        puts 2*(k-1)+1
    else
        puts 2*(k-1-n/2)
    end
end

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

if n%2==0
    if k <= n/2
        puts 2*(k-1)+1
    else
        puts 2*(k-n/2)
    end
else
    if k <= n/2+1
        puts 2*(k-1)+1
    else
        puts 2*(k-n/2)
    end
end

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

if n%2==0
    if k <= n/2
        puts 2*(k-1)+1
    else
        puts 2*(k-n/2)
    end
else
    if k < n/2
        puts 2*(k-1)+1
    else
        puts 2*(k-1-n/2)
    end
end


n = gets().to_i
arr = []
n.times do
  arr += [gets().to_i]
end
cur = "0" * n
last = "1" * n
f = false
while (cur.to_i(10) < last.to_i(10))
  d = 0
  arr.each_with_index do |e, ind|
    if cur[ind] == '0'
      d -= e
    else
      d += e
    end
  end
  if (d % 360 == 0)
    f = true
    break
  end
  cur = (cur.to_i(2) + 1).to_s(2)
  # puts cur
  cur = ("0" * (n - cur.size)) + cur
end
if f
  puts "YES"
else
  puts "NO"
end

N = gets.to_i
as = [0]
bs = nil
N.times {
  rot = gets.to_i
  bs = as.map{ |a| [(a+rot)%360, (a-rot+360)%360]}.flatten.uniq
  as,bs = bs,as
}
puts as.include?(0) ? "YES" : "NO"

n,*a=$<.read.split.map &:to_i
s=a.reduce :+
puts (1<<n).times.any?{|i|t=n.times.select{|j|i[j]>0}.map{|j|a[j]}.reduce 0,:+;(s-2*t)%360==0} ? :YES : :NO

# Utility

# Better use B-tree but eff that
def spin(angle, initial = [0])
  return Array.new(initial.length * 2) { |i| initial[i / 2] + angle * (-1)**(i % 2) }
end

# Input
n = gets.to_i
a = Array.new(n) { |i| gets.to_i }

# Processing
variants = [a[0]]
(n - 1).times do |i|
  variants = spin(a[1 + i], variants)
end

able_to_open = variants.detect { |el| el % 360 == 0 }

# Output
puts(able_to_open ? "YES" : "NO")

n,*a=$<.read.split.map &:to_i
s=a.reduce :+
puts (1<<n).times.any?{|i|t=n.times.select{|j|i[j]>0}.map{|j|a[j]}.reduce 0,:+;t%360==0} ? :YES : :NO

n,*a=$<.read.split.map &:to_i
s=a.reduce :+
puts (1<<n).times.any?{|i|t=n.times.select{|j|i[j]>0}.map{|j|a[j]}.reduce 0,:+;t*2==s} ? :YES : :NO


n = gets.to_i
s = gets.chomp
c = Hash.new(0)
for i in 0..n-1
  c[s[i]] += 1
end
puts (n == 1 || c.values.any?{|i|i > 1}) ? "Yes" : "No"

n=gets.to_i
puts n>gets.chomp.chars.uniq.size||n==1?:Yes: :No

N = gets.to_i
S = gets.chomp.split('').sort
if N == 1
    puts 'Yes'
    exit
end

(N-1).times do |i|
    if S[i] == S[i+1]
        puts 'Yes'
        exit
    end
end
puts 'No'

useless = gets.chomp
line = gets.chomp
a = Array.new(26,0)
if(line.size == 1)
	print ("Yes")
	exit
end
for i in 0...line.size
	a[line[i].ord - 97] += 1
end

for i in 0...26
	if(a[i] > 1)
		print("Yes")
		exit
	end
end
print("No")

n = gets.split()[0].to_i
s = gets.split()[0]
mx = 0
('a'..'z').each do |x|
    mx = [mx, (s.count x)].max
end
puts ((mx > 1 or s.length == 1) ? 'Yes' : 'No')

n = gets.to_i
str = gets.chomp

if n==1
  puts "Yes"
  exit
end

if n>26
  puts "Yes"
else
  hash = Hash.new(0)
  str.each_char {|x| hash[x]+=1}

  if hash.values.max==1
    puts "No"
  else
    puts "Yes"
  end
end

n=gets.to_i
puts n>gets.chars.uniq.size||n==1?:Yes: :No

n = gets.to_i
s = gets.chomp
c = Hash.new(0)
for i in 0..n-1
  c[s[i]] += 1
end
puts c.values.any?{|i|i > 1} ? "YES" : "NO"

useless = gets.chomp
line = gets.chomp
a = Array.new(26,0)

for i in 0...line.size
	a[line[i].ord - 97] += 1
end

for i in 0...26
	if(a[i] > 1)
		print("Yes")
		exit
	end
end
print("No")

n = gets.to_i
str = gets.chomp

if n==1
  puts "Yes"
end

#if n>26
#  puts "Yes"
#  exit
#else
  hash = Hash.new(0)
  str.each_char {|x| hash[x]+=1}

  if hash.values.max<2
    puts "No"
  else
    puts "Yes"
  end
#end

n = gets.to_i
str = gets.chomp

if n==1
  puts "Yes"
end

if n>26
  puts "Yes"
  exit
else
  hash = Hash.new(0)
  str.each_char {|x| hash[x]+=1}

  if hash.values.max<2
    puts "No"
  else
    puts "Yes"
  end
end

n = gets.to_i
str = gets.chomp

if n>26
  puts "Yes"
  exit
else
  hash = Hash.new(0)
  str.each_char {|x| hash[x]+=1}

  if hash.values.max<2
    puts "No"
  else
    puts "Yes"
  end
end


n1,n2,k1,k2=gets.split.map{|e| e.to_i}
if n1>n2 then
	puts "First"
else
	puts "Second"
end

pa=Array.new
str=gets.to_s
pa=str.split
n1=pa[0].to_i
n2=pa[1].to_i
if n1<=n2
  puts "Second"
else
  puts "First"
end

a, b, c, d = gets.split.map{|i| i.to_i}
puts a > b ? 'First' : 'Second'

n1, n2 = *gets.split.map(&:to_i)
puts n1 <= n2 ? "Second" : "First"

n1, n2, k1, k2 = gets.split.map { |x| x.to_i }
if n1 > n2
	puts 'First'
else
	puts 'Second'
end

a, b = gets.strip.split.map( &:to_i )
puts a <= b ? "Second" : "First"

#!/usr/bin/ruby

input = STDIN.readline.chomp
input = input.split(' ')
if input[0].to_i > input[1].to_i
    puts "First"
elsif input[0] == input[1]
    puts "Second"
else
    puts "Second"
end

#!/usr/bin/ruby

input = STDIN.readline.chomp
input = input.split(' ')
if input[0].to_i > input[1].to_i
    puts "First"
elsif input[0].to_i == input[1].to_i
    puts "Second"
else
    puts "Second"
end

n1,n2,k1,k2=gets.chomp.split

n1 = n1.to_i
n2 = n2.to_i

case n1<=>n2
    when 0
        print "Second";
    when 1
        print "First";
    when -1
        print "Second";
end

n,m,k,l=gets.split.map &:to_i
puts n>m ? "First" : "Second"

n1, n2, k1, k2 = $stdin.readline.split.map(&:to_i)

if n1>n2
    puts "First"
else
    puts "Second"
end

#le roi est mort is here
k, l, c, d = gets.split.map &:to_i
if k > l
  puts "First"
else
  puts "Second"
end

#!/usr/bin/ruby
# coding: utf-8

a, b, c, d = gets.split.map &:to_i
puts (a > b) ? "First" : "Second"

n, m = gets.split.map &:to_i
if n == m
  puts "Second"
else
  if [n, m].max == n
    puts "First"
  else
    puts "Second"
  end
end

n, m, a, b = gets.split().map(&:to_i)
if n>m
  puts "First"
else
  puts "Second"
end

n1, n2, k1, k2 = gets.split.map(&:to_i)

if n1 > n2
  puts 'First'
else
  puts 'Second'
end

n,m,k,l = gets.split.map(&:to_i)
puts n > m ? 'First' : 'Second'

#!/usr/bin/ruby

input_line = gets

params = input_line.split(' ')
n1 = params[0].to_i
n2 = params[1].to_i
k1 = params[2].to_i
k2 = params[3].to_i

if (n1<=n2)
    puts 'Second'
else
    puts 'First'
end

n1, n2, k1, k2 = gets.split.map &:to_i

puts (n1 > n2) ? "First" : "Second"

s = gets.split(" ").map { |e| e.to_i }
puts "First" if s[0] > s[1]
puts "Second" if s[0] <= s[1]

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

if n1 <= n2
	print "Second"
elsif n1 > n2
	print "First"
end

arr = $stdin.readline.split(" ")
n1=  Float("#{arr[0]}")
n2 = Float("#{arr[1]}")
k1 = Float("#{arr[2]}")
k2 = Float("#{arr[3]}")
if (n2 + 1 > n1 )
    puts "Second"
else
    puts "First"
end

arr = $stdin.readline.split(" ")
n1 = arr[0].to_i
n2 = arr[1].to_i
puts n2 + 1 > n1 ? 'Second' : 'First'

arr = $stdin.readline.split(" ")
n1=  arr[0].to_i
n2 = arr[1].to_i
if (n2 + 1 > n1 )
    puts "Second"
else
    puts "First"
end

a,b,c,d=gets.chomp.split.map &:to_i
puts (a>b)? :First: :Second

n1, n2, k1, k2 = gets.split.map(&:to_i)
puts n1 > n2 ? "First" : "Second"

input = gets.split(" ")
n1 = input[0].to_i
n2 = input[1].to_i
if n1 > n2
  puts "First"
else
  puts "Second"
end

n_1, n_2, k_1, k_2 = gets.split.map{|x| x.to_i}
puts(n_1 > n_2 ? 'First' : 'Second')

a , b , c ,d = gets.split.map {|i| i.to_i}

if a > b
    puts "First"
else
    puts "Second"
end

a, b = gets.strip.split
puts a <= b ? "Second" : "First"

# cook your code here

n1,n2,k1,k2=gets.chomp.split

case n1<=>n2
    when 0
        print "Second";
    when 1
        print "First";
    when -1
        print "Second";
end

a,b,c,d=gets.split &:to_i
puts (a>b)? :Second: :First

a,b,c,d=gets.split &:to_i
puts (a<=b)? :Second: :First

a,b,c,d=gets.split &:to_i
puts (a>b)? :First: :Second

n_1, n_2, k_1, k_2 = gets.split
puts(n_1 > n_2 ? 'First' : 'Second')

pa=Array.new
str=gets.to_s
pa=str.split
n1=pa[0]
n2=pa[1]
if n1<=n2
  puts "Second"
else
  puts "First"
end


b = gets.to_i
g = gets.to_i
n = gets.to_i

cnt=0

if b>=n && g>=n
  cnt = n+1
elsif b<n && g<n
  diff = n-[b,g].max
  cnt = [b,g].min-diff+1
  cnt = 0 if cnt<0
else
  cnt = [b,g].min+1
end

puts cnt

b = gets.to_i
g = gets.to_i
n = gets.to_i

ans = 0
(0..n).each do |bb|
  gg = n - bb
  ans += 1 if bb <= b && gg <= g
end
puts ans

b = gets.to_i
g = gets.to_i
n = gets.to_i

cnt=0

if b>=n && g>=n
  cnt = n+1
else
  cnt = [b,g].min+1
end

puts cnt


a=gets.chomp.split(" ")
pow=a[0].to_i
price=a[1].to_i
apple=0
half=0
0.upto(pow-1) do |i|
k=gets.chomp
if k.length!=4
apple=apple+2**i
half+=1
end
end

ans=(apple-(0.5*half))*price
puts "#{ans.to_i}"

N, P = gets.split.map(&:to_i)
A = N.times.map{ gets.chomp }

x = A.reverse.reduce(0){|acc, a| (a == 'half') ? (acc * 2) : (acc * 2 + 1)}

ans = 0
N.times do
  if x % 2 == 0
    ans += P * (x/2)
  else
    ans += P * (x/2) + P/2
  end
  x /= 2
end

puts ans

#!/usr/bin/ruby
n,p=gets.split.map(&:to_i)
m=r=0
$<.map(&:chomp).reverse.each{|e|
	m+=1 if e.end_with?('plus')
	r+=m*p/2
	m*=2
}
p r

n, p = gets.split(' ').map(&:to_i)
rest = 0
sum = 0
records = []

for i in 1..n
  records.unshift(gets.to_s.chomp)
end

records.each do |record|
  if record == 'half'
    rest = rest * 2
    sum += rest * p / 2
  else
    rest = ( rest + 0.5 ) * 2
    sum += rest * p / 2
  end

end

puts sum.to_i

n, p = gets.chomp.split.map(&:to_i)
apples = 1.0
com = []
n.times do
  com << gets.chomp
end
halfplus = 1
com.pop
com.reverse.each do |c|
  if c == "halfplus" then
    apples += 0.5
    apples *= 2
    halfplus += 1
  else
    apples *= 2
  end
end

puts ((apples - halfplus * 0.5) * p).to_i


def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

require 'prime'
n = inp[0]

d = Prime.prime_division(n)
if(d.size == 1 )
  p d[0][0]
else
  p 1
end

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

require 'set'

n = gets.to_i

dividers = Set.new []

i = 2
size = n

while i * i <= n
  if n % i == 0
    dividers.add(i)
    n /= i
    i -= 1
  end
  i += 1
end

dividers.add(n) if n > 1

arr = []
dividers.each { |num| arr << num }

if arr[0] == size
  puts size
elsif arr.size == 1
  puts arr[0]
else
  puts 1
end

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
(2..((n**0.5).ceil)).each do |d|
  if (n%d ==0)
    p d
    exit
  end
end
p n

def inpf() a=gets.chomp.split(" ").map(&:to_f)end

def inps() a=gets.chomp.split(" ")end

def copy(a) Marshal.load(Marshal.dump(a)) end

def kaijo(n,r = 10**9+7)(n < 2)? 1 : (2..n).inject{|memo,u|memo=(memo*u)%r} end

def na(n,d=0) Array.new(n,d)end

def na2(n,m,d=0) Array.new(n){Array.new(m,d)}end

def na3(n,m,l,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end

def inp() a=gets.chomp.split(" ").map(&:to_i)end

def r_up(a, b) (a+b-1)/b end

def sum(a) a.inject(:+) end

n = inp[0]
(2..((n**0.5).ceil)).each do |d|
  if (n%d ==0)
    if ( n/d  == d)
      p d
    else
      p 1
    end
    exit
  end
end
p n


a,b,n = gets.split.collect{|i| i.to_i}

for i in (2..n)
  tmp = a + b
  a = b
  b = tmp
end

puts b

x,y,z=gets.split.map(&:to_i)
(z-1).times{x,y=y,x+y}
p y

a, b, c = gets.split.map(&:to_i)
c.times do
    a, b = b, a + b
end
p a

n = gets.chomp.split(" ")
kol = n[2].to_i
k = Array.new(kol+1)
k[0] = n[0].to_i
k[1] = n[1].to_i

for i in(0..kol-2)
	k[i+2] = k[i] + k[i+1]
end

if kol == 1 then
	k[kol] = k[1]
end

puts k[kol]

x,y,z=gets.split.map(&:to_i)
(z-1).times{x,y=y,z+y}
p y


Mod = (1e9 + 7).to_i

n = gets.to_i

ans1 = 1
ans2 = 1

n.times do
	ans1 *= 27
	ans2 *= 7

	ans1 %= Mod
	ans2 %= Mod
end

ans = (ans1 - ans2 + Mod) % Mod
puts ans


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

n = gets.to_i
a = gets.split(" ").map(&:to_i).sort.reverse
x = a[0]
ans = 0
a.each do |k|
    k = [k, x].min
    ans += k
    x = k-1
    break if x == 0
end
p ans

gets
h={}
gets.split.map(&:to_i).each{|e| h[e] ? h[e]+=1 : h[e]=1}
f=->(n){n*(n+1)/2}
res=0
x=10**9*2
h.sort.reverse.each{|k,v|
    a=f[x=[k, x].min]
    b=f[[x-v, 0].max]
    res+=a-b
    x=[x-v, 0].max
}
puts res

n = gets.chomp.to_i
as = gets.chomp.split.map(&:to_i)
ans = 0

as.sort!.reverse!
b = as[0]
as.each do |a|
  ans += [a, b].min
  b = [[a - 1, b - 1].min, 0].max
end

puts ans

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

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

  r << v
end

puts r.inject(&:+)

class Solver
	def main
		n = gets.to_i
		arr = gets.split.map { |x| x.to_i }
		arr = arr.sort.reverse

		ans = 0
		last = 1 << 30
		arr.each do |x|
			x = last - 1 if x >= last
			ans += x if x >= 0
			last = x
		end
		puts ans
	end
end
Solver.new.main

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

gets
a=gets.split.map &:to_i
h = {}
a.sort.each{|x|
  x -= 1 while h[x]
  h[x] = true
}
if h.find 0
  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(&:+)


w,b=gets.split.map(&:to_i)
$dp=Array.new(1002){Array.new(1002){Array.new(2,-1)}}
#t=0 姫 t=1 ドラゴン
def solve(w,b,t)
        return 0 if b<0 || w<0
        return 0 if w+b==0
        return $dp[w][b][t] if $dp[w][b][t]>=0
        res=0.0
        if t==0 then
                res+=w.to_f/(w+b)
                res+=b.to_f/(w+b)*solve(w,b-1,1-t)
        else
                #Wを取る
                res=0
                #Bを取る
                tb=b-1
                tw=w
                if tb+tw==0 then
                        res=0
                else
                        res+=b.to_f/(w+b)*tb.to_f/(tb+tw)*solve(w,b-2,1-t)
                        res+=b.to_f/(w+b)*tw.to_f/(tb+tw)*solve(w-1,b-1,1-t)
                end
        end
        return $dp[w][b][t]=res
end
p solve(w,b,0)

Memo = {}# Array.new(1001*1001)

def f(w, b)
  return 0 if w==0
  ix = w*1001 + b
  return Memo[ix] if Memo[ix]
  res = 1.0*w/(w+b)
  if b>1
    m = 1.0*b*(b-1)/(w+b)/(w+b-1)
    wr = 1.0*w/(w+b-2)
    wp = f(w-1, b-2)
    br = 1.0-wr
    bp = 0
    bp = f(w, b-3) if b>2
    res += m * (wr*wp + br*bp)
  end
  Memo[ix] = res
  #puts "for w=#{w} b=#{b}: #{res}"
  res
end

w,b = readline.split(' ').map(&:to_i)
puts f(w,b)

Memo = Array.new(1001*1001)

def f(w, b)
  return 0 if w==0
  ix = w*1001 + b
  return Memo[ix] if Memo[ix]
  res = 1.0*w/(w+b)
  if b>1
    m = 1.0*b*(b-1)/(w+b)/(w+b-1)
    wr = 1.0*w/(w+b-2)
    wp = f(w-1, b-2)
    br = 1.0-wr
    bp = 0
    bp = f(w, b-3) if b>2
    res += m * (wr*wp + br*bp)
  end
  Memo[ix] = res
  #puts "for w=#{w} b=#{b}: #{res}"
  res
end

w,b = readline.split(' ').map(&:to_i)
puts f(w,b)


r, c, n, k = gets.split.map(&:to_i)
pos = n.times.map{gets.split.map(&:to_i)}

photos = 0
for top in 1..r do
  for left in 1..c do
    for down in top..r do
      for right in left..c do
        alts = pos.count do |x, y|
          x >= top && x <= down && y >= left && y <= right
        end
        photos += 1 if alts >= k
      end
    end
  end
end
puts photos

buf = gets.split(' ')
r,c,n,k = buf[0].to_i, buf[1].to_i, buf[2].to_i, buf[3].to_i
a=Array.new(22)
for i in 0..r
	a[i]=Array.new(22, 0)
end
for i in 1..n
	buf = gets.split(' ')
	x, y = buf[0].to_i, buf[1].to_i
	a[x][y]=1
end
for i in 1..r
	for j in 1..c
		a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1]
	end
end
ans=0
for x1 in 1..r
	for y1 in 1..c
		for x2 in x1..r
			for y2 in y1..c
				tot = a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1]
				ans+=1 if tot>=k
			end
		end
	end
end
puts ans

l1 = gets.chomp
vals1 = l1.split(' ').map {|x| x.to_i}

r = vals1[0]
c = vals1[1]
n = vals1[2]
k = vals1[3]

violas = []
columns = []
c.times {|x| columns << 0}
r.times {|x| col = []; c.times {|y| col << 0}; violas << col }
minx = r
miny = c
maxx = -1
maxy = -1
n.times {
  indices = gets.chomp.split(' ').map {|x| x.to_i - 1}
  violas[indices[0]][indices[1]] = 1
  minx = indices[1] if indices[1] < minx
  miny = indices[0] if indices[0] < miny
  maxx = indices[1] if indices[1] > maxx
  maxy = indices[0] if indices[0] > maxy
}

Rect = Struct.new(:x, :y, :x2, :y2)

rectangles = []
(0..r-1).each do |y|
  (0..c-1).each do |x|
    (y..r-1).each do |y2|
      (x..c-1).each do |x2|
        v = 0
        (y..y2).each do |yi|
          (x..x2).each do |xi|
            v += violas[yi][xi]
          end
        end
        if v >= k
          rectangles << Rect.new(x, y, x2, y2) unless rectangles.any? {|r|
            r.x == x && r.y == y && r.x2 == x2 && r.y2 == y2
          }
        end
      end
    end
  end
end
puts rectangles.length


x,y,z,a,b,c=gets.split.map &:to_i
d=(x-y).abs
puts d*a<((x-z).abs+d)*b+3*c ? :No : :Yes

def solution
  x, y, z, stairs, elv, elv_doors = read_ints

  elv_time = ((z-x).abs + (x-y).abs) * elv + elv_doors * 3
  stair_time = (y-x).abs * stairs

  puts elv_time <= stair_time ? "YES" : "NO"

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']

class A
  def self.run(s)
    x, y, z, t1, t2, t3 = s.split.map(&:to_i)
    walk = (x-y).abs * t1
    lift = (x-z).abs * t2 + t3*2 + (x-y).abs * t2 + t3
    if lift <= walk
      true
    else
      false
    end
  end
end

if A.run(gets.chomp)
  puts 'YES'
else
  puts 'NO'
end

x,y,z,t1,t2,t3 = gets.split.map { |e| Integer(e)  }
stair  = t1 * (x - y).abs
elevator =  t2 * (z - x).abs +  t3*2 + t2*(x-y).abs + t3
puts (if elevator <= stair then "YES" else "NO" end)

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

foot = (x-y).abs * t1
ev = (x-z).abs*t2+(x-y).abs*t2+t3*3

if foot < ev
  puts 'NO'
else
  puts 'YES'
end

line = gets.chomp

x, y, z, t1, t2, t3 = line.split.map(&:to_i)

elevator_time = ( (z-x).abs + (x-y).abs ) * t2 + 3 * t3
stair_time = (y-x).abs * t1

# puts elevator_time
# puts stair_time

if stair_time >= elevator_time
    puts "YES"
else
    puts "NO"
end

x, y, z, t1, t2, t3 = gets.split.map &:to_i
puts ((x - y).abs + (x - z).abs)*t2 + 3*t3 <= (x - y).abs*t1 ? 'YES' : 'NO'

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

x = xyzts[0]
y = xyzts[1]
z = xyzts[2]
t1 = xyzts[3]
t2 = xyzts[4]
t3 = xyzts[5]

st = (x-y).abs*t1
et = (x-z).abs*t2 + 3*t3 + (x-y).abs*t2

if et<=st
  puts "YES"
else
  puts "NO"
end


# cook your code here

n = gets.chomp

if (n[-1].to_i)%2==0
    puts "2"
else
    puts "1"
end

n = gets.chomp.to_i
puts n % 2 == 0 ? 2 : 1


x = gets.chomp.split(' ')
n = x[0].to_i
k = x[1].to_i
if k == 1
  puts n
else
  ans = 0
  i = 0
  while 2**i <= n
    ans += 2 ** i
    i += 1
  end
  puts ans
end

n,k=gets.split.map &:to_i
p k==1 ? n : 2**n.to_s(2).size-1

#!/usr/bin/ruby
include Math

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

if k == 1 then
	puts n
else
	puts (1 << n.to_s(2).length) - 1
end

#!/usr/bin/ruby
include Math

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

if k == 1 then
	puts n
else
	puts (1 << n.to_s(2).length) - 1
end


n,*a=$<.read.split.map &:to_i
puts a.each_cons(2).all?{|x,y|(x-y).abs<2} ? :YES : :NO

gets
puts (gets.split.map(&:to_i).each_cons(2).any? { |a| (a[0] - a[1]).abs > 1 } ? :NO : :YES)

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

bad = false
1.upto(n - 1){|i|
    if (a[i] - a[i-1]).abs >= 2 then
        bad = true;
    end
}

if bad then
    puts "NO"
else
    puts "YES"
end


candies, friends = gets.strip.split(' ').map(&:to_i)

result = []
number = candies/friends
redundant = candies%friends
friends.times do |f|
  result << number
end
if redundant != 0
  for i in 0...redundant
    result[i] += 1
  end
  result = result.reverse
end

print result.join(' ')

n, m = gets.split.map(&:to_i)
r, n = n % m, n / m
r.times{print "#{n+1} "}
(m-r).times{print "#{n} "}

#!/usr/bin/ruby
n,m=gets.split.map(&:to_i)
puts m.times.map{|i|n/m+(i<n%m ? 1 : 0)}*' '

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

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

candies = input[0]
friends = input[1]

c = candies / friends
leftover = candies - c * friends

puts ("#{c} " * (friends - leftover) + "#{c + 1} " * leftover).rstrip

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

a = Array.new(m, 0)
for i in 0...n
  a[i%m] += 1
end

for i in a
  print i, " "
end


n=gets.to_i
s=gets.split('')
idx=0
ans=""
ctr=1
while idx<n do
  ans+=s[idx]
  idx+=ctr
  ctr+=1
end
puts ans

n=gets.to_i
i=x=0
s=gets.chomp
while i<n
print s[i]
i+=x+=1
end

# Input
n = gets.to_i
t = gets.chomp

# Processing
m = (((8*t.length + 1)**0.5 - 1) / 2).round
str = ""
m.times do |i|
  str << t[(i + 2) * (i + 1) / 2 - 1]
end

# Output
puts str

n = gets.to_i
s = gets.chomp
ans = ''
j = 0
(1..n).each do |i|
  j += i
  if s[j-1].nil?
    break
  end
  ans += s[j-1]
end
puts ans

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

def decrypt(n, t)
  s = ""
  c = 1
  i = 0
  while i < n do
    s += t[i]
    i += c
    c += 1
  end
  return s
end

n = gets.chomp.to_i
t = gets.chomp

puts decrypt(n, t)

n = gets.to_i
t = gets.strip
i = 0
d = 1
s = ''
while i < t.size
    s += t[i]
    i += d
    d += 1
end
puts s

n = gets.to_i
str = gets.chomp

newstr = ""

i = 0
(1..n).each do |x|
  newstr += str[i]
  i += x
  break if i>=str.length
end

puts newstr

gets
s = gets.chomp

result = ''
1.upto(10) do |i|
  break if s.empty?

  result += s[0]

  s.replace s[i..-1]
end

puts result


n = gets.to_i
x = 0
y = 0
for i in 1..Math.sqrt(n).round
  if (n%i === 0)
    x = i
    y = n/i
  end
end
print x
print " "
print y

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)
  return [1,1] if n == 1
  return [0,0] if n == 0
  primes = n.prime_division
  minimum_pair(1, 1, primes)
end

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

n=gets.to_i
x, y=1, n
a=1
d=n-1
while a<=n
    if n % a==0 and n/a>=a and n/a-a<d
        x=a
        y=n/a
        d=y-x
    end
    a+=1
end
puts [x, y]*' '

class RectangleLike
  class << self
    def from_area(area)
      width = Math.sqrt(area).to_i
      new(area, width)
    end
  end

  attr_reader(:area, :width)
  def initialize(area, width)
    @area = area
    @width = width
  end

  def next
    if(not valid?)
      return RectangleLike.new(area, width - 1).next
    else
      return self
    end
  end

  def length
    (area / width).to_i
  end

  def valid?
    area == width * length
  end

  def to_s
    "#{width} #{length}"
  end

end

puts RectangleLike.from_area(gets.strip.to_i).next

n=gets.to_i
r=i=1
while i*i<=n
r=i if n%i==0
i+=1
end
puts '%d %d'%[r,n/r]

n = gets.to_i
a = (1..n).select { |x| x * x <= n && n % x == 0 }.last
puts [a, n / a].join(' ')

n = gets.to_i
a, b = 1, n
(1..Math.sqrt(n)).each do |i|
  a, b = i, n / i if n % i == 0
end
puts "#{a} #{b}"

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