#include <bits/stdc++.h>
using namespace std;
int inf_int = 2e9;
long long inf_ll = 2e18;
const double pi = 3.1415926535898;
template <typename T>
void prin(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i];
    if (i < a.size() - 1)
      cout << " ";
    else
      cout << "\n";
  }
}
template <typename T>
void prin(set<T>& a) {
  for (auto it = a.begin(); it != a.end(); it++) {
    cout << *it << " ";
  }
}
template <typename T>
void prin_new_line(vector<T>& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i] << "\n";
  }
}
template <typename T, typename T1>
void prin_new_line(vector<pair<T, T1> >& a) {
  for (int i = 0; i < a.size(); i++) {
    cout << a[i].first << " " << a[i].second << "\n";
  }
}
int sum_vec(vector<int>& a) {
  int s = 0;
  for (int i = 0; i < a.size(); i++) {
    s += a[i];
  }
  return s;
}
template <typename T>
T max(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = max(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(vector<T>& a) {
  T ans = a[0];
  for (int i = 1; i < a.size(); i++) {
    ans = min(ans, a[i]);
  }
  return ans;
}
template <typename T>
T min(T a, T b, T c) {
  return min(a, min(b, c));
}
template <typename T>
T max(T a, T b, T c) {
  return max(a, max(b, c));
}
void solve() {
  string a;
  cin >> a;
  if (a.size() < 3) {
    cout << -1;
    return;
  }
  int n = a.size();
  long long ans = -1;
  for (int i = 0; i < n - 2; i++) {
    string a1 = a.substr(0, i + 1);
    if (0) cout << i << " " << a1 << endl;
    if (a1.size() > 1 && a1[0] == '0') continue;
    if (a1.size() > 7) continue;
    for (int e = i + 1; e < n - 1; e++) {
      string b1 = a.substr(i + 1, e - i);
      if (b1.size() > 1 && b1[0] == '0') continue;
      if (0) cout << "\t" << e << " " << b1;
      string c1 = a.substr(e + 1, n - e - 1);
      if (c1.size() > 1 && c1[0] == '0') continue;
      if (0) cout << " " << c1 << endl;
      if (b1.size() > 7) continue;
      if (c1.size() > 7) continue;
      long long A = 0;
      for (int f = 0; f < a1.size(); f++) {
        A = A * 10 + (a1[f] - '0');
      }
      long long B = 0;
      for (int f = 0; f < b1.size(); f++) {
        B = B * 10 + (b1[f] - '0');
      }
      long long C = 0;
      for (int f = 0; f < c1.size(); f++) {
        C = C * 10 + (c1[f] - '0');
      }
      if (A <= 1000000 && B <= 1000000 && C <= 1000000) {
        ans = max(ans, A + B + C);
      }
    }
  }
  cout << ans;
}
int main() {
  if (!0) {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
  }
  int t = 1;
  while (t--) solve();
  return 0;
}
