#include <bits/stdc++.h>
using namespace std;
bool judge(int n)
{
if(n%4==0)
{
return false;
}
else {
do
{
if(n%10==4)
{
break;
}
n/=10;
}while(n);
if(n==0){
return true;
}
else{
return false;
}
}
}
int main() {
int n;cin>>n;
for(int i=1;i<=n;i++){
{
if(judge(i)==true){
cout<<i<<endl;
}
}
}
}
// 64 位输出请用 printf("%lld")

京公网安备 11010502036488号