#include <bits/stdc++.h>
using namespace std;
string s;
int mynum(int x, int y) {
  int temp;
  stringstream ss;
  ss << (s.substr(x, y - x));
  ss >> temp;
  if (temp > 1000000 || (y - x != 1 && s[x] == '0') || x == y) return -1;
  return temp;
}
int main() {
  int mx = -1, x, y, z;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    for (int j = i + 1; j < s.length(); j++) {
      x = mynum(0, i);
      y = mynum(i, j);
      z = mynum(j, s.length());
      if (x != -1 && y != -1 && z != -1 && x + y + z > mx) mx = x + y + z;
    }
  }
  cout << mx;
  return 0;
}
