#include <bits/stdc++.h>
using namespace std;
string number;
const int maxn = 1000000;
int maxSum(int p, int qsum, int n) {
  if (n == 3) {
    if (p == -1)
      return qsum;
    else
      return -1;
  }
  int qn = 0;
  int maxans = -1;
  for (int i = p, bs = 1; i >= 0 && bs <= maxn; --i, bs *= 10) {
    if (number[i]) {
      qn += number[i] * bs;
      if (qn <= maxn)
        maxans = max(maxans, maxSum(i - 1, qsum + qn, n + 1));
      else
        break;
    } else if (i == p) {
      maxans = max(maxans, maxSum(i - 1, qsum + qn, n + 1));
    }
  }
  return maxans;
}
int main() {
  cin >> number;
  for (int l = 0; l < number.size(); ++l) number[l] -= '0';
  cout << maxSum(number.size() - 1, 0, 0) << endl;
  return 0;
}
