package no437; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s = sc.next(); int n = s.length(); boolean[] isCWW = new boolean[1000]; for(int i=100;i<1000;i++) { isCWW[i] = i % 111 != 0 && i % 100 % 11 == 0; } int[] x = new int[n]; for(int i=0;i> i & 1) == 1) continue; for(int j=i+1;j> j & 1) == 1) continue; for(int k=j+1;k> k & 1) == 1) continue; int a = x[i] * 100 + x[j] * 10 + x[k]; if (!isCWW[a]) continue; int nm = m | (1 << i) | (1 << j) | (1 << k); dp[nm] = Math.max(dp[nm], dp[m] + a); } } } } int max = 0; for(int i=0;i<1<