#include <stdio.h>
#define N 100
int fun(int *s, int n) {
int i, j, k, a, b, c;
j = 0;
for (i=100; i<n; i++) {
/********found********/
k = i;
a = k%10;
k /= 10;
b = k%10;
k /= 10;
/********found********/
c = k%10;
if (a==b && a==c)
s[j++] = i;
}
return j;
}
void main() {
int a[N], n, num = 0, i;
do {
scanf("%d", &n);
} while (n > 1000);
num = fun(a, n);
for (i=0; i<num; i++)
printf("%5d", a[i]);
}