program numbers;

function sort(s: string): string;
var
	i, j: longint;
	c: char;
begin
	for i := 1 to length(s) do
		for j := i + 1 to length(s) do begin	
			if s[i] > s[j] then begin
				c := s[i]; s[i] := s[j]; s[j] := c;
			end;
		end;
	sort := s;
end;

function eq(s1, s2: string): boolean;
begin
	eq := sort(s1) = sort(s2);
end;

var
	sample: string;
	an: longint;
	a: array [1..36] of string;
	froms: array [1..3] of char;

procedure bt(i: longint; s: string);
var
	c: char;
	j: longint;
begin
	if i = 7 then begin
		if eq(s, sample) then begin
			for j := 1 to an do
				if a[j] = s then 
					exit;
			inc(an);
			a[an] := s;
		end;
		exit;
	end;

	if i in [1, 5, 6] then begin
		for j := 1 to 3 do
			bt(i + 1, s + froms[j]);
	end else begin
		for c := '0' to '9' do
			bt(i + 1, s + c);
	end;
end;

var
	i: longint;

begin
	reset(input, 'numbers.in');
	rewrite(output, 'numbers.out');

	readln(sample);
	froms[1] := sample[1];
	froms[2] := sample[5];
	froms[3] := sample[6];

	an := 0;
	bt(1, '');

	writeln(an);
	for i := 1 to an do
		writeln(a[i]);

	close(input);
	close(output);
end.