require 'date' d = Date.new(2015,1,1) ans = 0 while d.year == 2015 t = d.day.to_s.split('').map(&:to_i).inject(:+) if t == d.month ans += 1 end d += 1 end p ans