#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  char c = getchar();
  bool f = 0;
  for (; c > '9' || c < '0'; f = c == '-', c = getchar())
    ;
  for (; c >= '0' && c <= '9'; x = (x << 1) + (x << 3) + c - '0', c = getchar())
    ;
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x >= 10) write(x / 10);
  putchar(x % 10 + 48);
}
long long num[3000010], lim = 1000000000000000000ll;
int main() {
  for (int i = 2; i <= 1000000; ++i)
    for (long long x = (long long)i * i * i;; x *= i) {
      long long y = sqrt(x);
      if (y * y != x) num[++*num] = x;
      if (x > lim / i) break;
    }
  sort(num + 1, num + *num + 1);
  *num = unique(num + 1, num + *num + 1) - num - 1;
  int Test = read();
  for (int tt = 1; tt <= Test; ++tt) {
    long long n = read();
    write(n - (upper_bound(num + 1, num + *num + 1, n) - num - 1) -
          (long long)sqrt(n));
    puts("");
  }
}
