fibonacci_list = { 1=>1, 2=>1 } (3..80).each{|n| fibonacci_list[n] = fibonacci_list[n-1] + fibonacci_list[n-2] } n, m = gets.split.map(&:to_i) diff = fibonacci_list[n] - m count = 0 3.upto(n){|i| if diff >= fibonacci_list[n-i+1] diff -= fibonacci_list[n-i+1] count += 1 end } puts diff == 0 ? count : -1