#include <bits/stdc++.h>
using namespace std;
template <class T>
T abs(T x) {
  return x > 0 ? x : -x;
}
int n;
int m;
string s;
long long cool(string s) {
  if (s == "0") return 0;
  if (s[0] == '0') return -1;
  long long x = 0;
  for (int i = 0; i < ((int)(s).size()); i++) x = x * 10 + s[i] - '0';
  return x;
}
int main() {
  cin >> s;
  int n = ((int)(s).size());
  int ans = -1;
  for (int a = 1; a <= 10 && a < n; a++)
    for (int b = 1; b <= 10 && a + b < n; b++) {
      int c = n - a - b;
      if (c > 10) continue;
      long long x = cool(s.substr(0, a));
      long long y = cool(s.substr(a, b));
      long long z = cool(s.substr(a + b, c));
      if (x >= 0 && x <= 1000000 && y >= 0 && y <= 1000000 && z >= 0 &&
          z <= 1000000)
        ans = max((long long)ans, x + y + z);
    }
  printf("%d\n", ans);
  return 0;
}
