#include <bits/stdc++.h>
using namespace std;
const int M = 1000000;
int parse(char *s, int from, int count) {
  if (s[from] == '0' && count > 1) {
    return -1;
  }
  int result = 0;
  for (int i = 0; i < count; i++) {
    result = result * 10 + (s[from + i] - '0');
  }
  return result;
}
int main() {
  char s[30 + 1];
  cin >> s;
  int n = strlen(s);
  int result = -1;
  for (int i = 1; i <= 7 && i <= n - 2; i++) {
    for (int j = 1; j <= 7 && i + j <= n - 1; j++) {
      if (n - (i + j) <= 7) {
        int a = parse(s, 0, i);
        int b = parse(s, i, j);
        int c = parse(s, i + j, n - (i + j));
        if (a >= 0 && a <= M && b >= 0 && b <= M && c >= 0 && c <= M &&
            a + b + c > result) {
          result = a + b + c;
        }
      }
    }
  }
  cout << result << "\n";
  return 0;
}
