class Yukicoder def initialize a, b = gets.chomp.split(' ').map(&:to_i) if a < b puts b - 2 else puts 2000000000 - a + a - b - 1 end end end Yukicoder.new