import java.util.Scanner;
public class Main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int a = n % 10;
int b = n / 10 % 10;
int c = n / 100;
int t;
if(a > b){
t = a;
a = b;
b = t;
}if(b > c){
t = b;
b = c;
c = t;
}if(a > b){
t = a;
a = b;
b = t;
}
int s = c - a;
System.out.println(s);
sc.close();
}
}
/**************************************************************
Problem: 1667
User: admin
Language: Java
Result: Accepted
Time:838 ms
Memory:39576 kb
****************************************************************/