#include using namespace std; int main() { string S; cin >> S; sort(S.begin(), S.end()); cout << S[2] - S[0] << endl; }