#include <bits/stdc++.h>
using namespace std;
char s[50];
int swim(char* pos, int mach = 1, int sum = 0) {
  int res = -1, nm = 0;
  if (mach > 3)
    if (strlen(pos) == 0)
      return sum;
    else
      return -1;
  for (int i = 1; i <= 7 && pos[i - 1]; i++) {
    char t = pos[i];
    pos[i] = '\0';
    sscanf(pos, "%d", &nm);
    pos[i] = t;
    if (nm > 1e6) break;
    res = max(res, swim(pos + i, mach + 1, nm + sum));
    if (pos[0] == '0') break;
  }
  return res;
}
int main() {
  cin >> s;
  cout << swim(s, 1);
  return 0;
}
