#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m,k,l,o,p;
	cin>>n;
	m=n/1000+n%1000/100*10+n%100/10*100+n%10*1000;
	cout<<n-m;
}
/**************************************************************
	Problem: 1702
	User: zhengzihao
	Language: C++
	Result: Accepted
	Time:10 ms
	Memory:2072 kb
****************************************************************/