#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  cout.tie(0);
  string s, a, b, c, d;
  int n;
  long long ans = -1, somma;
  cin >> s;
  n = s.length();
  for (int i = 1; i < min(8, n - 1); i++) {
    a = s.substr(0, i);
    b = s.substr(i, n - i);
    for (int j = 1; j < n - i; j++) {
      c = b.substr(0, j);
      d = b.substr(j, n - i - j);
      if (((a[0] != '0') || ((a[0] == '0') && (a.length() == 1))) &&
          ((d[0] != '0') || ((d[0] == '0') && (d.length() == 1))) &&
          ((c[0] != '0') || ((c[0] == '0') && (c.length() == 1))) &&
          (a.length() < 8) && (c.length() < 8) && (d.length() < 8)) {
        if ((stoll(a) < 1000001) && (stoll(c) < 1000001) &&
            (stoll(d) < 1000001)) {
          somma = stoll(a) + stoll(c) + stoll(d);
          ans = max(ans, somma);
        }
      }
    }
  }
  cout << ans;
  return 0;
}
