require "date" count = 0 (Date.new(2005,1,1)..Date.new(2005,12,31)).each do |d| count += 1 if d.day.to_s.rjust(2,"0").split("").map(&:to_i).inject(&:+) == d.month end puts count