let line
let resarr = []
let reslut = []
while(line = readline()){
resarr=line.split(' ');
for(let item of resarr){
let res = 0
for(var i = 0;i<=parseInt(item);i++){
if((i%10 == 0) || (i%10 == 1) || (i%10 == 5) || (i%10 == 6)){
if(String(i*i).endsWith(String(i))){
res++
}
}
}
reslut.push(res)
}
}
console.log(reslut.join('\n'))