import java.util.LinkedList;
import java.util.Scanner;
import java.util.Stack;
public class suanFa01 {
public static void main(String[] args) {
Stack<Integer> stack = new Stack<Integer>();
LinkedList list = new LinkedList();
Scanner console = new Scanner(System.in);
int M = console.nextInt();
int sum1 = 0;
int sum2 = 0;
Find(M,stack,sum1,list,sum2);
}
public static void Find(int M,Stack<Integer> stack,int sum1,LinkedList list,int sum2){
for(int i = 1; i <= M; i ++){
int temp = i;
while(i != 0){
int x = i % 2;
i /= 2;
stack.push(x);
}
while(stack.size() > 0){
int y = stack.pop();
sum1 += y;
}
i = temp;
while(i != 0){
int z = i % 10;
i /= 10;
sum2 += z;
}
if(sum1 == sum2){
list.add(temp);
}
i = temp;
sum1 = 0;
sum2 = 0;
}
System.out.println(list.size());
System.out.println(list);
}
}
100
3
[1, 20, 21]