#include <bits/stdc++.h>
using namespace std;
const int inf = -10000000;
char s[100];
int n, i, j, ans;
int calc(int l, int r) {
  if (r - l + 1 > 7) return inf;
  if (r - l && s[l] == '0') return inf;
  int a = 0, i;
  for (i = l; i <= r; i++) a = a * 10 + s[i] - '0';
  if (a > 1000000) return inf;
  return a;
}
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  ans = -1;
  for (i = 1; i < n; i++)
    for (j = i + 1; j < n; j++)
      ans = max(ans, calc(1, i) + calc(i + 1, j) + calc(j + 1, n));
  cout << ans << endl;
  return 0;
}
