#import"bits/stdc++.h" using namespace std;string s;main(){cin>>s;cout<<*max_element(begin(s),end(s))-*min_element(begin(s),end(s));}