def s(g, n) return -1 if n>g return 1 if n==g r=0 a1 = s(g, n+1) a2 = s(g, n+2) r += a1 if a1>0 r += a2 if a2>0 r end puts s(gets.to_i, 0)