#include<bits/stdc++.h>
using namespace std;
int main(){
int i=1,n;
cin>>n;
while(i<=n){
if(i%3==2&&i%5==3&&i%7==2){
cout<<i<<endl;
}
i++;
}
}
/**************************************************************
Problem: 1021
User: chenyaohuo
Language: C++
Result: Wrong Answer
****************************************************************/