#include <bits/stdc++.h>
using namespace std;
#define int              long long int
#define double           long double
#define print(a)         for(auto x : a) cout << x << " "; cout << endl


const int M = 1000000007;
const int INF = 2e9+1;
const int LINF = 2000000000000000001;

inline int power(int a, int b, int mod=M) {
    int x = 1;
    a %= mod;
    while (b) {
        if (b & 1) x = (x * a) % mod; 
        a = (a * a) % mod;
        b >>= 1;
    }
    return x;
}


//_ ***************************** START Below *******************************

const int N = 1e7+1;

vector<bool> isPrime;
vector<int> primes;

void seive(){
    isPrime.assign(N+1, 1);
    isPrime[0] = isPrime[1] = 0;

    for(int i=2; i*i<=N; i++){
        if(isPrime[i] == 0) continue;
        for(int j=i*i; j<=N; j+=i){
            isPrime[j] = 0;
        }
    }

    unordered_set<int> st;
    for(int x=1; x<=10000; x++){
        for(int y=1; y<=100; y++){
            int p = x*x + y*y*y*y;
            if(p<=N && isPrime[p]){
                if(st.count(p) == 0){
                    primes.push_back(p);
                }
                st.insert(p);
            }
        }
    }

    sort(begin(primes), end(primes));
}


int consistency(int n){

    auto ans = upper_bound(begin(primes), end(primes), n) - begin(primes);

    return ans;

}















int practice(int n){


    return 0;
}





void solve() {
    static int _ = (seive(), 0);


    int n;
    cin>> n;
    
    
    cout << consistency(n) << endl;


}





int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int t = 1;
    cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}