#include <bits/stdc++.h>
using namespace std;
const int MAX = (int)1e6;
char s[31], a[31], b[31], c[31];
int main() {
  scanf("%s", s);
  long long ans = -1;
  int len = strlen(s), i, j, k, an, bn, cn, A, B, C;
  for (i = 0; i < len - 2; i++) {
    for (j = i + 1; j < len - 1; j++) {
      an = bn = cn = 0;
      for (k = 0; k <= i; k++) {
        a[an++] = s[k];
      }
      a[an] = '\0';
      for (k = i + 1; k <= j; k++) {
        b[bn++] = s[k];
      }
      b[bn] = '\0';
      for (k = j + 1; k < len; k++) {
        c[cn++] = s[k];
      }
      c[cn] = '\0';
      if (strlen(a) <= 7 && strlen(b) <= 7 && strlen(c) <= 7) {
        sscanf(a, "%d", &A);
        sscanf(b, "%d", &B);
        sscanf(c, "%d", &C);
        if (A <= MAX && B <= MAX && C <= MAX) {
          if ((strlen(a) > 1 && a[0] == '0') ||
              (strlen(b) > 1 && b[0] == '0') || (strlen(c) > 1 && c[0] == '0'))
            continue;
          ans = max(ans, (long long)A + B + C);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
