#C14833. Evaluate Simple Arithmetic Expression

    ID: 44526 Type: Default 1000ms 256MiB

Evaluate Simple Arithmetic Expression

Evaluate Simple Arithmetic Expression

You are given a single-line arithmetic expression consisting of non-negative integers and the operators + and -. Your task is to evaluate this expression and output the result.

The expression will have its tokens (numbers and operators) separated by one or more spaces. You are not allowed to use built‑in evaluation functions like eval(). Process the expression from left to right using standard arithmetic rules.

inputFormat

Input is a single line containing an arithmetic expression with non-negative integers and the operators '+' and '-'. The tokens are separated by spaces. Extra spaces may appear and should be handled correctly.

outputFormat

Print a single integer that is the result of evaluating the given expression.## sample

3 + 5 - 2
6