#include <bits/stdc++.h>
using namespace std;
int cmp(void const *x, void const *y) {
  long a = *(long *)x;
  long b = *(long *)y;
  return a - b;
}
long n, m = -1, k, l, i, j, t, a, b, c;
char s[100];
bool ter(long a, long b, long c, long n) {
  long t = -3;
  if (a <= 1000000 && b <= 1000000 && c <= 1000000) t = 0;
  while (1) {
    t++;
    a /= 10;
    if (a == 0) break;
  }
  while (1) {
    t++;
    b /= 10;
    if (b == 0) break;
  }
  while (1) {
    t++;
    c /= 10;
    if (c == 0) break;
  }
  if (t == n) return 1;
  return 0;
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (i = 1; i < n; i++)
    for (j = 0; j < n; j++) {
      if (i < j) {
        a = 0;
        b = 0;
        c = 0;
        for (k = 0; k < i; k++) {
          a = a * 10 + s[k] - 48;
          if (a > 10000007) break;
        }
        for (k = i; k < j; k++) {
          b = b * 10 + s[k] - 48;
          if (b > 10000007) break;
        }
        for (k = j; k < n; k++) {
          c = c * 10 + s[k] - 48;
          if (c > 10000007) break;
        }
        if (ter(a, b, c, n)) {
          if (m < a + b + c) m = a + b + c;
        }
      }
    }
  printf("%ld\n", m);
}
