import java.util.Scanner;
import java.util.Arrays;
import java.util.Set;
import java.util.HashSet;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;

public class numbers_pm {

    public static void main(String[] args) throws FileNotFoundException {
        Scanner scanner = new Scanner(new File("numbers.in"));
        PrintWriter writer = new PrintWriter(new File("numbers.out"));

        String s = scanner.nextLine();
        s = s.trim();
        char[] c = s.toCharArray();
        final int[] a = {0, 4, 5};
        final int[] b = {1, 2, 3};

        Set<String> ans = new HashSet<String>();

        for (int q1 : a) {
            for (int q2 : b) {
                for (int q3 : b) if (q3 != q2) {
                    for (int q4 : b) if (q4 != q3 && q4 != q2) {
                        for (int q5 : a) if (q5 != q1) {
                            for (int q6 : a) if (q6 != q1 && q6 != q5) {
                                ans.add("" + c[q1] + c[q2] + c[q3] + c[q4] + c[q5] + c[q6]);
                            }
                        }
                    }
                }
            }
        }

        writer.println(ans.size());
        for (String s1 : ans) {
            writer.println(s1);
        }
        writer.close();

    }
}
