#include <bits/stdc++.h>
char str[35];
int val(char s[]) {
  if (s[0] == '0' && strlen(s) > 1) return -1;
  if (strlen(s) > 6 && strcmp(s, "1000000")) return -1;
  return atoi(s);
}
char *substr(int a, int b) {
  char *t = (char *)malloc(40);
  int i, j = 0;
  for (i = a; i <= b; i++) t[j++] = str[i];
  t[j] = 0;
  return t;
}
int main() {
  int i, j, max = -1, x1, x2, x3, len;
  scanf(" %s", str);
  len = strlen(str);
  for (i = 1; i < len; i++) {
    for (j = i + 1; j < len; j++) {
      x1 = val(substr(0, i - 1));
      x2 = val(substr(i, j - 1));
      x3 = val(substr(j, len - 1));
      if (x1 == -1 || x2 == -1 || x3 == -1) continue;
      max = ((max > x1 + x2 + x3) ? max : x1 + x2 + x3);
    }
  }
  printf("%d\n", max);
  return 0;
}
