#include <bits/stdc++.h>
using namespace std;
int dp[35][3];
int N;
string T;
int convert(int a, int b) {
  if (T[a] == '0' && a != b) return 1000001;
  int ans = 0;
  for (int i = (a); i <= (b); i++) {
    ans *= 10;
    ans += (T[i] - '0');
    if (ans > 1000000) return 1000001;
  }
  if (ans == 0) {
    if (a == b) return 0;
    return 1000001;
  }
  return ans;
}
int main() {
  cin >> T;
  N = T.length();
  int ans = -1;
  for (int i = 0; i < N; i++) {
    int a1 = convert(0, i - 1);
    if (a1 > 1000000) continue;
    for (int j = 0; j < N; j++) {
      if (j <= i) continue;
      int a2 = convert(i, j - 1);
      int a3 = convert(j, N - 1);
      if (a2 > 1000000) continue;
      if (a3 > 1000000) continue;
      ans = max(ans, a1 + a2 + a3);
    }
  }
  cout << ans << endl;
  return 0;
}
