#include <bits/stdc++.h>
using namespace std;
char x[55];
int swim(char *c = x, int res = 0, int round = 0) {
  int l = strlen(c);
  if (round == 2) {
    if (l == 0 || l > 7 || (c[0] == '0' && l > 1)) return -1;
    int ba2y;
    sscanf(c, "%d", &ba2y);
    if (ba2y > 1000000) return -1;
    return ba2y + res;
  }
  int ma3aya = 0;
  int nateg = -1;
  for (; c[0]; c++) {
    ma3aya *= 10;
    ma3aya += c[0] - '0';
    nateg = max(nateg, swim(c + 1, ma3aya + res, round + 1));
    if (ma3aya == 0 || (ma3aya * 10) + (c[1]) - '0' > 1000000) break;
  }
  return nateg;
}
int main() {
  scanf("%s", &x);
  printf("%d", swim());
  return 0;
}
