143165576
 1919020031
 1204252996
 210637432
 724264821
 1741
 619489590
 1199537418
 1075765759
 747976826
 638486017
 58438190
 1285316221
 186925426
 1180540990
 833393692
 1818960378
 2000000000
 0
 1309028227
 514714359
 624205168
 1795248373
 643201595
 1304312649

14 3 3 4 5 2 4 4 2 4 6 4 3 4 5 3 5 4 1 5 3 4 5 5 8
import java.util.Scanner;

public class B {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        sc.close();
        char[] chs = str.toCharArray();
        int sum = 0;
        boolean was[] = new boolean[str.length()];
        for(int i = 0; i < str.length(); i++) {
        	if(was[i]) {
        		continue;
        	}
        	for(int j = i+1; j < str.length(); j++) {
        		if(chs[i] == chs[j]) {
        			if(was[j]) {
        				continue;
        			}
        			sum+= Integer.parseInt(chs[i] + "")*2;
        			for(int x = i+1; x < j; x++) {
        				sum-= Integer.parseInt(chs[x] + "");
        			}
        			was[j] = true;
        			break;
        		}
        	}
        }
        System.out.println(sum);
	}
}