N=gets.to_i a=[b=c=1] a<=b+=c+=1 if a[-1]==N p 1 exit end h=N/2 a.each_with_index{|d,i| break if d>h i.upto(a.size-1){|j| if N==t=d+a[j] p 2 exit end break if t>N } } p 3