@a = Hash.new() def solve(n) if n == 0 return 1 end if @a.has_key?(n) return @a[n] end @a[n] = solve(n / 3) + solve(n / 5) return @a[n] end p solve(gets.to_i)