require 'date' c = 0 Date.new(2015,1,1).upto(Date.new(2015,12,31)) do |date| d = date.day c += 1 if date.month == (d / 10) + (d % 10) end puts c