import sys

def num_days(month, year):
	if month in [1,3,5,7,8,10,12]:
		return 31
	elif month == 2:
		if year % 4 == 0:
			return 29
		else:
			return 28
	else:
		return 30

def find_date(text):
	map = {};
	
	for i in range(len(text) - 9):
		sub_date = text[i:i+10]
		
		if sub_date[2] == '-' and sub_date[5] == '-' and sub_date[0:2].isdigit() and sub_date[3:5].isdigit() and sub_date[6:].isdigit():
			day = int(sub_date[0:2])
			month = int(sub_date[3:5])
			year = int(sub_date[6:])
			
			if 2013 <= year <= 2015 and 1 <= month <= 12 and 1 <= day <= num_days(month, year):
				if sub_date in map:
					map[sub_date] = map[sub_date] + 1
				else:
					map[sub_date] = 1
	
	return max( [(value, key) for (key, value) in map.items()])

def main():
	text = raw_input()
	
	(count, date) = find_date(text)
	
	print date
	
if __name__ == "__main__":
	main()
