#include <iostream>
using namespace std;
int main() {
int x,y,z,a,b,b1,u;
cin >> x;
cout << endl;
y=x;
while(x>0)
{
x/=10;
z++;
}
for(int i=1;i<=z;i++)
{
u=y%10;
if(i%2==0)
b+=u;
else
b1+=u;
y/=10;
}
a=b-b1;
if(a<0)
a*=-1;
cout << a << endl;;
return 0;
}