require "date" year = Date.new(2015, 1, 1) count = 0 365.times do |i| year += i # 月と日付を取得して、分割すればよい if year.month[0] + year.month[1] == year.day[0] + year.day[1] count += 1 end end puts count