#include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
// NOTE: gP(n) is incorrect for even values of n
#define N 1000000
unsigned int mark[N / 64];
#define gP(n) (mark[n>>6]&(1<<((n>>1)&31)))
#define rP(n) (mark[n>>6]&=~(1<<((n>>1)&31)))
int cnt[N + 1];
void sieve() {
memset( mark, -1, sizeof( mark ) );
unsigned int i;
unsigned int sqrtN = ( unsigned int )sqrt( ( double )N ) + 1;
for( i = 3; i < sqrtN; i += 2 ) if( gP( i ) ) {
unsigned int i2 = i + i;
for( unsigned int j = i * i; j < N; j += i2 ) rP( j );
}
cnt[1] = 1;
cnt[2] = 1;
for( i = 3; i < N; i += 2)
if (gP(i)) cnt[i] = 1;
for(int i=1; i <= N; ++i) cnt[i] += cnt[i-1];
}
int main() {
ios :: sync_with_stdio(false); cin.tie(NULL);
sieve();
int ntest; cin >> ntest;
for(int test = 1; test <= ntest; ++test) {
int n; cin >> n;
cout << "Case #" << test << ": " << cnt[n] << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0cmluZz4KI2luY2x1ZGUgPGNtYXRoPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKLy8gTk9URTogZ1AobikgaXMgaW5jb3JyZWN0IGZvciBldmVuIHZhbHVlcyBvZiBuCiNkZWZpbmUgTiAxMDAwMDAwCnVuc2lnbmVkIGludCBtYXJrW04gLyA2NF07CiNkZWZpbmUgZ1AobikgKG1hcmtbbj4+Nl0mKDE8PCgobj4+MSkmMzEpKSkKI2RlZmluZSByUChuKSAobWFya1tuPj42XSY9figxPDwoKG4+PjEpJjMxKSkpCgppbnQgY250W04gKyAxXTsKCnZvaWQgc2lldmUoKSB7CiAgICBtZW1zZXQoIG1hcmssIC0xLCBzaXplb2YoIG1hcmsgKSApOwogICAgdW5zaWduZWQgaW50IGk7CiAgICB1bnNpZ25lZCBpbnQgc3FydE4gPSAoIHVuc2lnbmVkIGludCApc3FydCggKCBkb3VibGUgKU4gK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