#include <bits/stdc++.h>
using namespace std;
string stri;
bool ok = false;
int mmax = 0;
void check(int start, int end) {
  if (start >= end || start > 7 || (end - start) > 7 || (stri.size() - end) > 7)
    return;
  int probe, now = 0;
  string ev[3];
  ev[0] = stri.substr(0, start);
  ev[1] = stri.substr(start, end - start);
  ev[2] = stri.substr(end);
  for (int i = 0; i < 3; i++) {
    if (ev[i][0] == '0' && ev[i].size() > 1) return;
    sscanf(ev[i].c_str(), "%d", &probe);
    if (probe > 1000000) return;
    now += probe;
  }
  ok = true;
  if (mmax < now) {
    mmax = now;
  }
}
int main() {
  cin >> stri;
  if (stri.size() > 21) {
    printf("-1\n");
    return 0;
  }
  for (int i = 1; i < 8 && i < (stri.size() - 1); i++) {
    for (int j = i; j < (stri.size()); j++) {
      check(i, j);
    }
  }
  if (ok)
    printf("%d\n", mmax);
  else
    printf("-1\n");
  return 0;
}
