#include <bits/stdc++.h>
#pragma comment(linker, "/stack:64000000")
using namespace std;
int main() {
  int i, j, jr, k, ii, jj, kk;
  string str, buf;
  int ans = -1, sum;
  cin >> str;
  if (str.size() <= 21 && str.size() >= 3)
    for (i = 0; i < str.size() - 2; i++) {
      j = i + 1;
      for (jr = j; jr < str.size() - 1; jr++) {
        k = jr + 1;
        sum = 0;
        buf.clear();
        for (ii = 0; ii <= i; ii++) {
          buf.push_back(str[ii]);
        }
        if ((*buf.begin() == '0' && buf.size() > 1) || buf.size() > 7 ||
            atoi(buf.c_str()) > 1000000)
          continue;
        sum += atoi(buf.c_str());
        buf.clear();
        for (jj = j; jj < k; jj++) {
          buf.push_back(str[jj]);
        }
        if ((*buf.begin() == '0' && buf.size() > 1) || buf.size() > 7 ||
            atoi(buf.c_str()) > 1000000)
          continue;
        sum += atoi(buf.c_str());
        buf.clear();
        for (kk = k; kk < str.size(); kk++) {
          buf.push_back(str[kk]);
        }
        if ((*buf.begin() == '0' && buf.size() > 1) || buf.size() > 7 ||
            atoi(buf.c_str()) > 1000000)
          continue;
        sum += atoi(buf.c_str());
        if (sum > 3000000) continue;
        ans = max(ans, sum);
      }
    }
  cout << ans;
  return 0;
}
