#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

    int n;
    cin >> n;
    for (int i = 1; i <= n; i ++) {
        int t  = i;
        bool f = true;
        while (t) {
            int p = t % 10;
            if (p == 4) {
                f = false;
                break;
            }

            t /= 10;
        }
        if (!f) continue;
        else if (i % 4 == 0) continue;
        else cout << i << "\n";

    }

    return 0;
}