#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int prime[1000005],cnt,H;
bool vis[1000005],semi[1000005];
inline void euler(){
for(int i=5;i<=1000005;i+=4){
if(!vis[i]){
prime[++cnt]=i;
}
for(int j=1;j<=cnt&&i*prime[j]<=1000005;j++){
if(!vis[i])semi[i*prime[j]]=1;//注意①
vis[i*prime[j]]=1;
if(i%prime[j]==0)break;
}
}
}
int main(){
euler();
while(1){
scanf("%d",&H);
if(H==0)return 0;
int ans=0;
for(int i=5;i<=H;i+=4){
if(semi[i])ans++;
}
printf("%d %d
",H,ans);
}
}
注意②:1不是H素数!!!!!!
注意③:原来CE是因选错语言......(光速逃