#include <bits/stdc++.h>
using namespace std;
const int INF = 1e6;
char str[35];
long long a, b, c, result, ans = -1;
long long myget(int s, int e) {
  long long tmp = 0;
  for (int i = s; i <= e; i++) {
    tmp = tmp * 10 + str[i] - '0';
  }
  return tmp;
}
int main() {
  scanf("%s", str);
  int len = strlen(str);
  for (int i = 0; i < len; i++) {
    for (int j = i + 1; j < len - 1; j++) {
      if ((i + 1) > 7 || (j - (i + 1) + 1) > 7 || (len - 1 - (j + 1) + 1) > 7)
        continue;
      int l1 = i - 0 + 1, l2 = j - (i + 1) + 1, l3 = len - 1 - (j + 1) + 1;
      if ((str[0] == '0' && l1 != 1) || (str[i + 1] == '0' && l2 != 1) ||
          (str[j + 1] == '0' && l3 != 1))
        continue;
      a = myget(0, i);
      b = myget(i + 1, j);
      c = myget(j + 1, len - 1);
      if (a > INF || b > INF || c > INF) continue;
      result = a + b + c;
      if (result > ans) ans = result;
    }
  }
  printf("%I64d\n", ans);
  return 0;
}
