#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int res = -1;
  for (int i = 1; i < s.size(); i++) {
    for (int j = 1; i + j < s.size(); j++) {
      int p1;
      string P1 = s.substr(0, i);
      if (P1.size() > 1 && P1[0] == '0')
        p1 = -1;
      else if (P1.size() >= 7 && P1 != "1000000")
        p1 = -1;
      else
        istringstream(P1) >> p1;
      int p2;
      string P2 = s.substr(i, j);
      if (P2.size() > 1 && P2[0] == '0')
        p2 = -1;
      else if (P2.size() >= 7 && P2 != "1000000")
        p2 = -1;
      else
        istringstream(P2) >> p2;
      int p3;
      string P3 = s.substr(i + j, s.size());
      if (P3.size() > 1 && P3[0] == '0')
        p3 = -1;
      else if (P3.size() >= 7 && P3 != "1000000")
        p3 = -1;
      else
        istringstream(P3) >> p3;
      if (p1 == -1 || p2 == -1 || p3 == -1) continue;
      res = max(res, p1 + p2 + p3);
    }
  }
  cout << res << endl;
  return 0;
}
