#include <bits/stdc++.h>
using namespace std;
int parse(string s) {
  if (s.size() > 1 && s[0] == '0') return 1 << 30;
  if (s.size() > 7) return 1 << 30;
  istringstream ss(s);
  int x;
  ss >> x;
  return x;
}
int main() {
  string s;
  cin >> s;
  if (s.size() < 3) {
    cout << -1 << endl;
  } else {
    int n = s.size();
    int mx = -1;
    for (int i = 1; i < n; ++i) {
      for (int j = i + 1; j < n; ++j) {
        int s1 = parse(s.substr(0, i));
        if (s1 > 1000000) continue;
        int s2 = parse(s.substr(i, j - i));
        if (s2 > 1000000) continue;
        int s3 = parse(s.substr(j));
        if (s3 > 1000000) continue;
        mx = max(mx, s1 + s2 + s3);
      }
    }
    cout << mx << endl;
  }
}
