#include <bits/stdc++.h>
using namespace std;
const int MAXN = (int)1e5 + 7;
const int INF = (int)1e9 + 7;
string s;
bool check(int l, int r, int &sum) {
  int len = r - l + 1;
  if (len > 7) return false;
  if (s[l] == '0' && len > 1) return false;
  int c = 0;
  for (int i = l; i <= r; i++) {
    c = c * 10 + s[i] - 48;
  }
  if (c > 1000000) return false;
  sum = c;
  return true;
}
int main() {
  cin >> s;
  int ans = -1;
  for (int i = 1; i + 1 < s.length(); i++) {
    for (int j = i + 1; j < s.length(); j++) {
      int a, b, c;
      if (check(0, i - 1, a) && check(i, j - 1, b) &&
          check(j, s.length() - 1, c)) {
        ans = max(ans, b + c + a);
      }
    }
  }
  cout << ans;
  return 0;
}
