#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline string tostr(const _T& a) {
  ostringstream os("");
  os << a;
  return os.str();
}
template <class T>
T sqr(T x) {
  return x * x;
}
int toint(string a) {
  stringstream s;
  s << a;
  int b;
  s >> b;
  return b;
}
int main() {
  string s;
  cin >> s;
  int m = -1;
  for (int i = 1; i < s.size() && i <= 7; i++) {
    for (int j = 1; i + j < s.size() && j <= 7; j++) {
      string a1 = (s.substr(0, i));
      string a2 = (s.substr(i, j));
      string a3 = s.substr(i + j);
      if (a1.size() > 7 || a2.size() > 7 || a3.size() > 7) continue;
      if (a1.size() > 1 && a1[0] == '0') continue;
      if (a2.size() > 1 && a2[0] == '0') continue;
      if (a3.size() > 1 && a3[0] == '0') continue;
      int aa = toint(a1);
      int bb = toint(a2);
      int cc = toint(a3);
      if (aa > 1000000 || bb > 1000000 || cc > 1000000) continue;
      m = max(m, aa + bb + cc);
    }
  }
  cout << m << endl;
}
