#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>
#include <set>

using namespace std;

int main(){

    long long N;
    cin >> N;

    set<long long> numSet;
    for(long long i = 2; i <= 100000; i++){
        if(i * i > N){
            break;
        }

        if(numSet.find(i) == numSet.end()){
            long long temp = i * i;
            while(temp <= N){
                numSet.insert(temp);
                temp *= i;
            }
        }
    }

    long long ans = N - (int)numSet.size();
    cout << ans << endl;

    return 0;
}
#include <algorithm>
#include <array>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>


#define all(v) begin(v), end(v)
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)


using namespace std;


using ll = int_fast64_t;
using ld = long double;
template <class T> using pqg = priority_queue<T, vector<T>, greater<T>>;
template <class T> using pq  = priority_queue<T>;
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }


constexpr ll INF   = (1LL << 30);
constexpr ll INFLL = (1LL << 60);
constexpr ll MAX   = 500005;
constexpr ll MOD   = 1000000007;


int main(void)
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  rep2(i, 1, 1e6) {
    string s = to_string(i);
    s += s;

    ll t = stol(s);
    if (t > n) {
      cout << i-1 << endl;
      return (0);
    }
  }

  return (0);
}
