#include <bits/stdc++.h>
using namespace std;
vector<long long> v, vv;
void calc() {
  long long mx = 1e18;
  for (long long i = 2; i <= 1e6; i++) {
    for (long long u = i * i * i; u <= mx; u *= i) {
      v.push_back(u);
      if (u > mx / i) break;
    }
  }
  sort(v.begin(), v.end());
  v.erase(unique(v.begin(), v.end()), v.end());
  for (int i = 0; i < (int)v.size(); i++) {
    long long u = v[i];
    long long uu = sqrt(u);
    if (uu * uu == u) continue;
    vv.push_back(u);
  }
}
int main() {
  calc();
  int t;
  scanf("%d", &t);
  while (t--) {
    long long num, ans = 0;
    scanf("%lld", &num);
    ans += (long long)sqrt(num) - 1;
    long long all_a_to_b =
        (upper_bound(vv.begin(), vv.end(), num) - vv.begin());
    ans += all_a_to_b;
    ans = num - 1 - ans;
    printf("%lld\n", ans);
  }
}
