require "time" t = DateTime.new(2015, 1, 1) def f(x) res = 0 while x > 0 res += x % 10 x /= 10 end res end res = 0 while t.year == 2015 t = t.next_day(1) res += 1 if t.month == f(t.day) end puts res