~/algor $ cat problems/raqamlar-almashinuvchi-yigindisi
Alternating digit sum
Easy
1000 ms
64 MB
29%
A positive integer $n$ is given. Starting from the last digit, add and subtract its digits in turn: the last digit is added, the one before it is subtracted, the one before that is added, and so on. For example, for $1234$: $4 - 3 + 2 - 1 = 2$.
Input
One positive integer $n$.
Output
One integer — the alternating sum.
Note
$1 \le n \le 10^{18}$
Examples
Input #1
1234
Output #1
2
Input #2
909
Output #2
18