#include <bits/stdc++.h>
using namespace std;

bool nabeatsu(int n){
    if(n % 3 == 0) return true;
    int temp = n;
    while(temp > 0){
        if(temp % 10 == 3) return true;
        temp /= 10;
    }
    return false;
}
int main(){
    int n; cin >> n;
    for(int i = 1; i <= n; i++){
        if(nabeatsu(i)){
            cout << ' ' << i;
        }
    }
    cout << endl;
}


#include <iostream>
#include <vector>

using namespace std;

int powerOf2(int n)	{
	int res = 0;
	while (n % 2 == 0)	{
		res++;
		n /= 2;
	}
	return res;
}

int main()	{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)	{
		cin >> a[i];
	}
	int pow2 = 1e9;
	for (int i = 0; i < n; i++)	{
		pow2 = min(pow2, powerOf2(a[i]));
	}	
	cout << pow2 << endl;
	return 0;
}
