#include <bits/stdc++.h>
char str[32] = {0};
int tt(int x, int y) {
  if (y - x + 1 > 7) {
    return -1;
  }
  int i = 0, now = 0;
  for (i = x; i <= y; i++) {
    now = now * 10 + str[i] - '0';
    if (!now) {
      break;
    }
  }
  if (!now) {
    if (i == y) {
      return now;
    }
    return -1;
  }
  if (now > 1000000) {
    return -1;
  }
  return now;
}
int main() {
  int ans = 0, len = 0, i = 0, j = 0, now1 = 0, now2 = 0, now3 = 0, now = 0;
  while (scanf("%s", str) == 1) {
    ans = -1;
    len = strlen(str);
    for (i = 0; i + 2 < len; i++) {
      for (j = i + 1; j + 1 < len; j++) {
        now1 = tt(0, i);
        now2 = tt(i + 1, j);
        now3 = tt(j + 1, len - 1);
        if (now1 == -1 || now2 == -1 || now3 == -1) {
          continue;
        }
        now = now1 + now2 + now3;
        if (now > ans) {
          ans = now;
        }
      }
    }
    printf("%d\n", ans);
  }
  return 0;
}
