#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU def gs(); gets.chomp; end def gi(); gets.to_i; end def gss(); gets.chomp.split; end def gis(); gss.map(&:to_i); end N, M = gis v = [0, 1, 1] (3..N).each do |i| v << v[i - 1] + v[i - 2] end h = {0 => 0} v.each do |x| t = h.dup h.each do |k,v| z = k + x if t.key? z t[z] = [t[z], v + 1].min else t[z] = v + 1 end end h = t end ans = h[v[N] - M] puts ans.nil? ? -1 : ans