import datetime def calc(u): res = 0 while u > 0: res += u % 10 u = u // 10 return res s = datetime.datetime(2015, 1, 1) res = 0 while s.year == 2015: if calc(s.day) == s.month: res += 1 s = s + datetime.timedelta(days=1) print(res)