#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = -1;
  if (n <= 21)
    for (int i = 1; i < n - 1; ++i)
      for (int j = i; j < n - 1; ++j) {
        if (i > 7 || (j - i + 1) > 7 || (n - (j + 1)) > 7) continue;
        long long a = 0, b = 0, c = 0;
        for (int k = 0; k < i; ++k) a = a * 10 + s[k] - '0';
        for (int k = i; k <= j; ++k) b = b * 10 + s[k] - '0';
        for (int k = j + 1; k < n; ++k) c = c * 10 + s[k] - '0';
        if (i > 1 && s[0] == '0' || (j - i + 1) > 1 && s[i] == '0' ||
            j != n - 2 && s[j + 1] == '0')
          continue;
        if (a <= 1000000 && b <= 1000000 && c <= 1000000)
          ans = max(ans, (int)(a + b + c));
      }
  cout << ans << endl;
  return 0;
}
