#include <bits/stdc++.h>
using namespace std;
struct Counter {
  static int k;
  Counter() { k++; }
  ~Counter() { k--; }
};
int Counter::k = 0;
template <typename T>
void pr(const string& name, T t) {
  cout << name << " = " << t << endl;
}
template <typename T, typename... Types>
void pr(const string& names, T t, Types... rest) {
  auto comma_pos = names.find(',');
  cout << names.substr(0, comma_pos) << " = " << t << ", ";
  auto next_name_pos = names.find_first_not_of(" \t\n", comma_pos + 1);
  pr(string(names, next_name_pos), rest...);
}
void mod(long long& a, long long b) {
  a %= b;
  if (a < 0) a += b;
}
const long long MOD = 1000000007;
int DP[35];
string S;
int get(int l, int r) {
  if (r - l > 6) return -99999999;
  if (S[l] == '0' && r > l) return -99999999;
  int ret = 0;
  for (int i = (l); i <= (r); i++) ret = 10 * ret + S[i] - '0';
  return ret <= 1000000 ? ret : -99999999;
}
int main() {
  cin >> S;
  int ans = -999999999;
  for (int a = (0); a <= (((int)S.size()) - 3); a++)
    for (int b = (a + 1); b <= (((int)S.size()) - 2); b++) {
      int x = get(0, a);
      int y = get(a + 1, b);
      int z = get(b + 1, ((int)S.size()) - 1);
      ans = max(ans, x + y + z);
    }
  if (ans >= 0)
    cout << ans;
  else
    cout << "-1";
}
