#include <iostream>
using namespace std;

using ll = long long;

int main() {
  ll K; cin >> K;

  ll res = 0;
  for (int a=1; a<=K; ++a) {
    for (int b=1; b<=K/a; ++b) {
      ll prod = a*b;
      res += K/(a*b);
    }
  }

  cout << res << endl;
}

#include <bits/stdc++.h>
using namespace std;

template <typename T, typename U> bool cmin(T &a, U b) { return a > b && (a = b, true); }
template <typename T, typename U> bool cmax(T &a, U b) { return a < b && (a = b, true); }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;
  int N = S.size();

  int mx = INT_MIN;
  for (int bit = 0; bit < 1 << N; bit++) {
    int tmp = 0;
    for (int i = 0; i < N; i++) {
      if (bit >> i & 1) tmp += S.at(i) - '0';
    }
    if (tmp % 3 == 0) cmax(mx, __builtin_popcount(bit));
  }
  cout << ((mx == 0) ? -1 : N - mx) << "\n";
}