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

template <class A, class B> bool cmin(A& a, B b) { return a > b && (a = b, true); }
template <class A, class B> bool cmax(A& a, B b) { return a < b && (a = b, true); }

signed main() {
  cin.tie(nullptr)->sync_with_stdio(false);

  long N;
  cin >> N;
  vector<tuple<long, long, long>> V(N);
  for (long i = 0; i < N; i++) {
    long a, b, c;
    cin >> a >> b >> c;
    V.at(i) = {a, b, c};
  }

  long ans = LONG_MAX;
  for (const auto& [a, b, c] : V) {
    if (a >= c) continue;
    cmin(ans, b);
  }
  if (ans == LONG_MAX) ans = -1;
  cout << ans << '\n';
}
#include <bits/stdc++.h>
using namespace std;


using ll = long long;

void solve(long long N){
    set<ll> se;
    for(ll i = 2;i <= sqrt(N) + 10;i++){
        ll _i = i * i;
        for(;_i <= N;_i *= i){
            /*
            if(_i == 0){
                exit(0);
            }
            */
            //cout<<_i<<endl;
            se.insert(_i);
        }
    }
    cout<<N - se.size()<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}
