#include<stdio.h>

int main(){
int n;
while(1){
scanf("%d",&n);if(n==0)break;

int a=0,b=0,c=0;
for(int i=1;i<=n;i++)
{if(i%10)a++;
else if(i%5)b++;
else if(i%2)c++;
}
int s=0;
if(b<c)c=b;
s=a+c;
printf("%d\n",s);
}
return 0;
}