#include <bits/stdc++.h>
using namespace std;
int str2int(string s) {
  istringstream ss(s);
  int t;
  ss >> t;
  return t;
}
int main() {
  string s;
  cin >> s;
  int ans = -1;
  for (int i = 1; i < s.length(); i++) {
    string s1 = s.substr(0, i);
    if (s1.length() > 1 && s1[0] == '0') continue;
    int t1 = str2int(s1);
    if (t1 > 1000000) continue;
    for (int j = 1; j < s.length(); j++) {
      if (i + j >= s.length()) continue;
      string s2 = s.substr(i, j);
      string s3 = s.substr(i + j);
      if (s2.length() > 1 && s2[0] == '0') continue;
      if (s3.length() > 1 && s3[0] == '0') continue;
      int t2 = str2int(s2);
      int t3 = str2int(s3);
      if (t2 > 1000000) continue;
      if (t3 > 1000000) continue;
      int temp = t1 + t2 + t3;
      if (temp > ans) ans = temp;
    }
  }
  cout << ans;
}
