# https://www.hackerrank.com/challenges/backreferences-to-failed-groups/problem

Regex_Pattern = r"^\d\d(-?)\d\d\1\d\d\1\d\d$"	# Do not delete 'r'.

import re

print(str(bool(re.search(Regex_Pattern, input()))).lower())

# https://www.hackerrank.com/challenges/backreferences-to-failed-groups/problem

Regex_Pattern = r"^\d\d(-?)\d\d\1\d\d\1\d\d$"	# Do not delete 'r'.

import re

print(str(bool(re.search(Regex_Pattern, input()))).lower())

# https://www.hackerrank.com/challenges/backreferences-to-failed-groups/problem # Do not delete 'r'.