#include <bits/stdc++.h>
using namespace std;
long long int magic(string j, long long int i, long long int k) {
  if (i > 10 || k > i + 10 || k < int(j.length() - 10)) return -1;
  string a, b, c;
  a = j.substr(0, i);
  b = j.substr(i, k - i);
  c = j.substr(k, j.length() - k);
  if (a.length() > 1 && a[0] == '0') return -1;
  if (b.length() > 1 && b[0] == '0') return -1;
  if (c.length() > 1 && c[0] == '0') return -1;
  stringstream ss;
  long long int x, y, z;
  ss << a;
  ss >> x;
  ss.clear();
  ss << b;
  ss >> y;
  ss.clear();
  ss << c;
  ss >> z;
  if (x > 1000000 || y > 1000000 || z > 1000000) return -1;
  return x + z + y;
}
int main() {
  long long int ans = -1, i, k;
  string j;
  cin >> j;
  for (i = 1; i < j.length() - 1; i++) {
    for (k = i + 1; k < j.length(); k++) {
      ans = max(magic(j, i, k), ans);
    }
  }
  cout << ans << endl;
  return 0;
}
