#include <stdio.h>

int main() {
    int n,cnt=1;
    int check,i;
    scanf("%d",&n);
    if (n==1) {
        printf("666");
        return 0;
    }

    for(i=667;;i++) {
        check=0;
        int name=i;
        
        while(name) {
            if(name%1000==666) {
                check=1;
            }
            name/=10;
        }
        if(check) {
            cnt++;
            if(cnt==n) {
                break;
            }
        }
    }
    printf("%d",i);
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: