#include using namespace std; #define intl long long #define LOOPIDX(size) for(int i = 0;i < size;i++) #define LOOPFROMIDX(begin,size) for(int i = begin;i < size;i++) #define LOOPIDXREV(size) for(int i = size-1;i >= 0;i--) #define REP(time) for(int t = 1;t <= time;t++) #define INPUT(v) cin >> v; #define PRINT(v) cout << v << endl; #define PRINTF(v) printf("%.10f\n",v) template T gcd(T x,T y) { if(x == 0 || y == 0) return max(x,y); while(true) { if(x % y == 0) return y; auto mod = x % y; x = y; y = mod; } return y; } int main() { string abc = ""; cin >> abc; string s = ""; s += abc[0]; int M = stoi(s); int m = stoi(s); for(auto s : abc) { string cs = ""; cs += s; M = max(M,stoi(cs)); m = min(m,stoi(cs)); } cout << M - m << endl; return 0; }