#include <bits/stdc++.h>
using namespace std;
bool is(int i){
	if(i%3==0||i%10==3)return true;
	while(i/=10)if(i%10==3)return true;
	return false;
}
int main(){
	int a=1,u;cin>>u;for(;a<=u;a++)if(is(a))cout<<" "<<a;cout<<endl;
}
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  string s;
  cin >> s;
  if(s[0] == '7' || s[1] == '7' || s[2] == '7')
    cout << "Yes";
  else cout << "No";
}