/** Problem: numbers
  * Solution by: Semyon Dyatlov
  **/
#include <algorithm>
#include <stdio.h>
#include <string.h>

using namespace std;
const int ind[2][3] = {{0,4,5},{1,2,3}};

char z[36][7], s[7], p[36];
int n;

bool less(const int &a, const int &b)
{
  return strcmp(z[a],z[b])<1;
}

int main()
{
  freopen("numbers.in","rt",stdin);
  freopen("numbers.out","wt",stdout);

  scanf("%s",&s);

  n = 0;
  for (int i1=0;i1<3;i1++)
    for (int i2=0;i2<3;i2++)
      for (int j1=0;j1<3;j1++)
        for (int j2=0;j2<3;j2++)
          if (i1!=i2&&j1!=j2)
          {
            z[n][0] = s[ind[0][i1]];
            z[n][4] = s[ind[0][i2]];
            z[n][5] = s[ind[0][3-i1-i2]];
            z[n][1] = s[ind[1][j1]];
            z[n][2] = s[ind[1][j2]];
            z[n][3] = s[ind[1][3-j1-j2]];
            z[n][6] = 0;
            p[n++] = n;
          }
  stable_sort(p,p+n,less);

  int m = n;
  for (int i=1;i<n;i++)
    if (!strcmp(z[p[i]],z[p[i-1]]))
      --m;
  printf("%d\n",m);
  for (int i=0;i<n;i++)
    if (!i||strcmp(z[p[i]],z[p[i-1]]))
      printf("%s\n",z[p[i]]);

  return 0;
}