#include <stdio.h> int main() { int n,m; scanf("%d",&n); for(int t =3;t<n;t++) { m = t; while(m ) { if(m%10==3) { printf("%d ",t); break; } m=m/10; } } return 0; }