#include <bits/stdc++.h>
int main() {
  int mx = -1;
  char str[64];
  gets(str);
  for (int a = 0, i = 0; str[i]; ++i) {
    a = a * 10 + str[i] - '0';
    if (a > 1000000) break;
    if (str[i + 1])
      for (int j = i + 1, b = 0; str[j]; ++j) {
        b = b * 10 + str[j] - '0';
        if (b > 1000000) break;
        if (str[j + 1]) {
          int c = 0;
          if (str[j + 1] != '0' || !str[j + 2])
            for (int k = j + 1; str[k]; ++k) {
              c = c * 10 + str[k] - '0';
              if (c > 1000000) {
                c = -100000000;
                break;
              }
            }
          else
            c = -100000000;
          if (mx < a + b + c) mx = a + b + c;
        }
        if (str[i + 1] == '0') break;
      }
    if (str[0] == '0') break;
  }
  printf("%d", mx);
  return 0;
}
