import re import sys def extract_area_code(line: str) -> str: # While this regex seems complicated, it essentially enforces either of two possible formats # Returning the area code captured in group(1) p = re.compile(r'^[+0](\d{2})\s(?:\d-\d{3}-\d{3}|\d{3}-\d{2}-\d{2})$') m = p.match(line) return m.group(1) if m else "" if __name__ == "__main__": for line in sys.stdin: stripped_line = line.strip() print(extract_area_code(stripped_line))