#include <bits/stdc++.h>
using namespace std;
char score[22];
int maxScore = -1;
int i, j, k;
int current;
int temp;
int convert(int start, int end) {
  if ((score[start] == '0' && start != end) || start > end ||
      end - start + 1 > 7)
    return -1;
  int i;
  int number = 0;
  for (i = start; i <= end; ++i) number = number * 10 + (score[i] - '0');
  if (number > 1000000) return -1;
  return number;
}
int main() {
  cin >> score;
  for (i = 0; score[i]; ++i) {
    for (j = i + 1; score[j]; ++j) {
      current = 0;
      if ((temp = convert(0, i)) != -1)
        current += temp;
      else
        continue;
      if ((temp = convert(i + 1, j)) != -1)
        current += temp;
      else
        continue;
      if ((temp = convert(j + 1, strlen(score) - 1)) != -1)
        current += temp;
      else
        continue;
      maxScore = (current > maxScore) ? current : maxScore;
    }
  }
  cout << maxScore << endl;
  return 0;
}
