#include <bits/stdc++.h>
using namespace std;
int main() {
  string in;
  cin >> in;
  int sz = in.size();
  long long max = -1;
  for (int i = 1; i <= sz - 2; i++) {
    for (int j = 1; j <= sz - 1 - i; j++) {
      long long x, y, z;
      {
        stringstream ss(in.substr(0, i));
        ss >> x;
      }
      {
        stringstream ss;
        ss << in.substr(i, j);
        ss >> y;
      }
      {
        stringstream ss;
        ss << in.substr(i + j, sz - i - j);
        ss >> z;
      }
      if ((in.substr(0, i)[0] == '0' && i > 1) ||
          (in.substr(i, j)[0] == '0' && j > 1) ||
          (in.substr(i + j, sz - i - j)[0] == '0' && sz - i - j > 1))
        continue;
      if (x <= 1000000 && y <= 1000000 && z <= 1000000 && x + y + z > max)
        max = x + y + z;
    }
  }
  cout << max;
  return 0;
}
