#include <bits/stdc++.h>
using namespace std;
char s[100];
int l;
int calc(int x, int y) {
  if (s[0] == '0' && x > 0) return -1;
  if (s[x + 1] == '0' && y - x > 1) return -1;
  if (s[y + 1] == '0' && l - 1 - y > 1) return -1;
  int ret = 0, k = 0;
  for (int i = 0; i <= x; i++) {
    k = k * 10 + s[i] - '0';
    if (k > 1000000) return -1;
  }
  ret += k;
  k = 0;
  for (int i = x + 1; i <= y; i++) {
    k = k * 10 + s[i] - '0';
    if (k > 1000000) return -1;
  }
  ret += k;
  k = 0;
  for (int i = y + 1; i < l; i++) {
    k = k * 10 + s[i] - '0';
    if (k > 1000000) return -1;
  }
  ret += k;
  return ret;
}
int main() {
  int ans = -1;
  scanf("%s", s);
  l = strlen(s);
  for (int i = 0; i < l - 2; i++)
    for (int j = i + 1; j < l - 1; j++) {
      int k = calc(i, j);
      if (ans < k) ans = k;
    }
  printf("%d\n", ans);
  return 0;
}
