#include <iostream>
#include <cstdlib>
using namespace std;
int main(){
int n , x , y;
cin >> n;
x = n;
int nrc = 0;
do
{
nrc ++;
x /= 10;
}
while(x);
int p = 1;
y = 0;
for(int i = 1 ; i <= nrc / 2 ; ++i){
y += n % 10 * p;
p *= 10;
n /= 10;
}
if(nrc % 2 ==1)
n /= 10;
x = n;
cout << abs(x-y);
return 0;
}