#include <bits/stdc++.h>
using namespace std;
char ln[50];
int dp[50][3];
bool vis[50][3];
int dfs(int p, int s) {
  if (s == 3) {
    if (ln[p])
      return -1;
    else
      return 0;
  }
  if (vis[p][s]) return dp[p][s];
  vis[p][s] = 1;
  if (ln[p] == '0') return dp[p][s] = dfs(p + 1, s + 1);
  int i, r = -1, t = 0, q;
  for (i = p; ln[i]; i++) {
    t = t * 10 + ln[i] - '0';
    if (t > 1000000) break;
    q = dfs(i + 1, s + 1);
    if (q != -1 && (t + q) > r) r = t + q;
  }
  return dp[p][s] = r;
}
int main() {
  gets(ln);
  cout << dfs(0, 0) << '\n';
  return 0;
}
