def evaluate_expression(s): def parse_nonzero_digit(s, index): return int(s[index]), index + 1 def parse_digit(s, index): if s[index] == '0': return 0, index + 1 else: return parse_nonzero_digit(s, index) def parse_positive_number(s, index): if s[index] == '0': return parse_digit(s, index) else: value, next_index = parse_nonzero_digit(s, index) while next_index < len(s) and s[next_index].isdigit(): digit, next_index = parse_digit(s, next_index) value = value * 10 + digit return value, next_index def parse_number(s, index): if s[index] == '-': value, next_index = parse_number(s, index + 1) return -value, next_index elif s[index].isdigit(): return parse_positive_number(s, index) else: raise ValueError("Invalid number format") def parse_factor(s, index): if s[index] == '(': value, next_index = parse_expression(s, index + 1) if s[next_index] == ')': return value, next_index + 1 else: raise ValueError("Mismatched parentheses") else: return parse_number(s, index) def parse_term(s, index): left, next_index = parse_factor(s, index) while next_index < len(s) and (s[next_index] == '*' or s[next_index] == '/'): operator = s[next_index] right, next_index = parse_factor(s, next_index + 1) if operator == '*': left *= right else: raise ValueError("Unsupported operator: '/'") return left, next_index def parse_expression(s, index): left, next_index = parse_term(s, index) while next_index < len(s) and (s[next_index] == '+' or s[next_index] == '-'): operator = s[next_index] right, next_index = parse_term(s, next_index + 1) if operator == '+': left += right else: left -= right return left, next_index result, _ = parse_expression(s, 0) return result n=int(input()) expression = str(input()) result = evaluate_expression(expression) print(result)