#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 2e18;
const int N = 6;
string s[N];
void Up(int c) {
  char temp = s[0][c];
  for (int i = 0; i + 1 < N; ++i) s[i][c] = s[i + 1][c];
  s[N - 1][c] = temp;
}
void Dn(int c) {
  char temp = s[N - 1][c];
  for (int i = N - 1; i > 0; --i) s[i][c] = s[i - 1][c];
  s[0][c] = temp;
}
void Rt(int r) {
  char temp = s[r][N - 1];
  for (int i = N - 1; i > 0; --i) s[r][i] = s[r][i - 1];
  s[r][0] = temp;
}
void Lf(int r) {
  char temp = s[r][0];
  for (int i = 0; i + 1 < N; ++i) s[r][i] = s[r][i + 1];
  s[r][N - 1] = temp;
}
const string alpha = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vector<string> path;
pair<int, int> goal(char c) {
  int val = (c < 'A' ? c - '0' : 10 + c - 'A');
  return pair<int, int>(val / N, val % N);
}
pair<int, int> locate(char c) {
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < N; ++j) {
      if (c == s[i][j]) return {i, j};
    }
  }
  return {-1, -1};
}
void operation(char c, int x) {
  string str = "";
  str += c;
  str += to_string(x + 1);
  path.push_back(str);
  if (c == 'U')
    Up(x);
  else if (c == 'D')
    Dn(x);
  else if (c == 'R')
    Rt(x);
  else
    Lf(x);
}
void swap(pair<int, int> p, pair<int, int> q) {
  assert(p.first == q.first and (q.second - p.second + N) % N == 1);
  operation('D', p.second);
  operation('L', p.first);
  operation('L', p.first);
  operation('U', p.second);
  operation('L', p.first);
  operation('D', p.second);
  operation('L', p.first);
  operation('U', p.second);
  operation('L', p.first);
  operation('D', p.second);
  operation('L', p.first);
  operation('U', p.second);
  operation('L', p.first);
}
void move(char c) {
  pair<int, int> fr = locate(c), to = goal(c);
  if (fr == to) return;
  if (fr.first == to.first) {
    operation('D', fr.second);
    operation('L', fr.first + 1);
    operation('U', fr.second);
    return move(c);
  }
  int rts = (to.second - 1 - fr.second + N) % N;
  for (int i = 0; i < rts; ++i) {
    operation('R', fr.first);
  }
  int dns = (fr.first - to.first);
  for (int i = 0; i < dns; ++i) {
    operation('D', to.second);
  }
  operation('R', fr.first);
  for (int i = 0; i < dns; ++i) {
    operation('U', to.second);
  }
}
void epilogue() {
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j + 1 < N; ++j) {
      if (s[N - 1][j] > s[N - 1][j + 1]) {
        swap({N - 1, j}, {N - 1, j + 1});
      }
    }
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  for (int i = 0; i < N; ++i) cin >> s[i];
  for (int i = 0; i < N * (N - 1); ++i) move(alpha[i]);
  epilogue();
  cout << (int)path.size() << "\n";
  for (auto &qq : path) cout << qq << "\n";
  return 0;
}
