include<stdio.h>

int main()
{int n,i,t;
scanf("%d",&n);
for(i=1;i<=n;i++)
{t=i;
if(t%3==2&&t%5==3&&t%7==2)
{printf("%d\n",i);}}}