#include <bits/stdc++.h>
using namespace std;
int getNum(string s) {
  int sum = 0;
  for (int i = 0; i < ((int)(s).size()); i++) sum = sum * 10 + s[i] - '0';
  return sum;
}
string t, s;
string getString(int i, int j) {
  t = "";
  for (int ii = i; ii <= j; ii++) t += s[ii];
  return t;
}
int main() {
  cin >> s;
  int i, j, res = -1;
  for (i = 0; i < ((int)(s).size()); i++)
    for (j = i + 1; j < ((int)(s).size()); j++) {
      if (i + 1 > j || j + 1 > ((int)(s).size()) - 1 ||
          i + 1 > ((int)(s).size()))
        continue;
      string fr = getString(0, i), mid = getString(i + 1, j),
             rear = getString(j + 1, ((int)(s).size()) - 1);
      if (((int)(fr).size()) == 0 || ((int)(mid).size()) == 0 ||
          ((int)(rear).size()) == 0)
        continue;
      if (((int)(fr).size()) > 7 || ((int)(mid).size()) > 7 ||
          ((int)(rear).size()) > 7)
        continue;
      if ((fr[0] == '0' && ((int)(fr).size()) > 1) ||
          (mid[0] == '0' && ((int)(mid).size()) > 1) ||
          (rear[0] == '0' && ((int)(rear).size()) > 1))
        continue;
      int num1 = getNum(fr), num2 = getNum(mid), num3 = getNum(rear);
      if (num1 > 1000000 || num2 > 1000000 || num3 > 1000000) continue;
      res = max(res, num1 + num2 + num3);
    }
  cout << res << endl;
  return 0;
}
