#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  long long mx = -1;
  int n = s.length();
  for (int i = 1; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      long long a = atoi(s.substr(0, i).c_str());
      long long b = atoi(s.substr(i, j - i).c_str());
      long long c = atoi(s.substr(j, n - j).c_str());
      if (a > 1e6 || b > 1e6 || c > 1e6) continue;
      if ((s[0] == '0' && i > 1) || (s[i] == '0' && j - i > 1) ||
          (s[j] == '0' && n - j > 1))
        continue;
      mx = max(mx, a + b + c);
    }
  }
  (mx == INT_MIN) ? cout << -1 << "\n" : cout << mx << "\n";
  return 0;
}
