#include <bits/stdc++.h>
using namespace std;
int sst(string g) {
  int f;
  stringstream ss;
  ss << g;
  ss >> f;
  return f;
}
int main() {
  string s, s1, s2, s3;
  cin >> s;
  int max = -1, h = 0;
  int t = s.size(), x, y, z;
  if (t < 3) {
    cout << "-1" << endl;
    return 0;
  }
  for (int i = 0; i < t - 1; i++) {
    for (int j = i + 1; j < t - 1; j++) {
      s1 = s.substr(0, i + 1);
      s2 = s.substr(i + 1, j - i);
      s3 = s.substr(j + 1, t - j - 1);
      x = sst(s1);
      y = sst(s2);
      z = sst(s3);
      if (s1.size() == 0 || s2.size() == 0 || s3.size() == 0) continue;
      if (s1[0] == '0' && s1.size() > 1) continue;
      if (s2[0] == '0' && s2.size() > 1) continue;
      if (s3[0] == '0' && s3.size() > 1) continue;
      if (x <= 1000000 && y <= 1000000 && z <= 1000000 && x + y + z > max) {
        max = x + y + z;
        h = 1;
      }
    }
  }
  if (h = 1)
    cout << max;
  else
    cout << "-1";
  return 0;
}
