import datetime date = datetime.datetime(year=2015, month=1, day=1) c=0 while date.year==2015: if date.month == (date.day//10+date.day%10): c+=1 date += datetime.timedelta(days=1) print(c)