#include <bits/stdc++.h>
using namespace std;
void fun() {}
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int ans = -1;
  int max = s.length();
  for (int i = 1; i < max; i++) {
    for (int j = 1; i + j < max; j++) {
      int k = max - i - j;
      int sum = 0;
      if ((s[0] == '0' && i != 1) || (s[i] == '0' && j != 1) ||
          (s[i + j] == '0' && k != 1) || (i > 7 || j > 7 || k > 7))
        continue;
      int a = stoi(s.substr(0, i));
      int b = stoi(s.substr(i, j));
      int c = stoi(s.substr(i + j, k));
      if (a > 1000000 || b > 1000000 || c > 1000000) continue;
      sum = a + b + c;
      ans = std::max(ans, sum);
    }
  }
  cout << ans;
}
