package test; import java.util.Arrays; import java.util.Scanner; public class No437 { void run() { Scanner sc = new Scanner(System.in); String s = sc.next(); System.out.println(max(s)); } int max(String s){ char[] ss = s.toCharArray(); int n = s.length(); int max = 0; for (int i = 0; i < n; i++) { for (int j = i+1; j < n; j++) { for (int k = j+1; k < n; k++) { if(ss[i] != '0' && ss[i] != ss[j] && ss[j] == ss[k]){ StringBuilder sb = new StringBuilder(); sb.append(ss[i]).append(ss[j]).append(ss[k]); int t = Integer.parseInt(sb.toString()); StringBuilder sb2 = new StringBuilder(s); sb2.deleteCharAt(k); sb2.deleteCharAt(j); sb2.deleteCharAt(i); max = Math.max(max, t+max(sb2.toString())); } } } } return max; } void debug(Object... o) { System.out.println(Arrays.deepToString(o)); } public static void main(String[] args) { new No437().run(); } }