#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <cassert>
 
using namespace std;
 
#define DEBUG(x) cout << #x << " = " << x << endl
 
enum COLOR { R, O, Y, G, B, W };
enum FACE { FRONT, BACK, UP, DOWN, LEFT, RIGHT };
 
struct Cube {
    vector<vector<int> > f;
    vector<COLOR> id;
 
    Cube() : f(vector<vector<int> >(6, vector<int>(4))), id(vector<COLOR>(4*6)) {
        int k = 0;
        for(int i = 0; i < 4; i++) { f[FRONT][i] = k; id[k] = Y; k++; }
        for(int i = 0; i < 4; i++) { f[BACK][i] = k; id[k] = W; k++; }
        for(int i = 0; i < 4; i++) { f[UP][i] = k; id[k] = R; k++; }
        for(int i = 0; i < 4; i++) { f[DOWN][i] = k; id[k] = O; k++; }
        for(int i = 0; i < 4; i++) { f[LEFT][i] = k; id[k] = G; k++; }
        for(int i = 0; i < 4; i++) { f[RIGHT][i] = k; id[k] = B; k++; }
    }
 
    // front -> right
    void roll_x() {
        roll(FRONT, RIGHT, BACK, LEFT);
 
        vector<int> tmp;
 
        tmp = f[UP];
        f[UP][0] = tmp[1];
        f[UP][1] = tmp[3];
        f[UP][2] = tmp[0];
        f[UP][3] = tmp[2];
 
        tmp = f[DOWN];
        f[DOWN][0] = tmp[2];
        f[DOWN][1] = tmp[0];
        f[DOWN][2] = tmp[3];
        f[DOWN][3] = tmp[1];
 
        tmp = f[BACK];
        for(int i = 0; i < 4; i++) {
            f[BACK][i] = tmp[3 - i];
        }
 
        tmp = f[LEFT];
        for(int i = 0; i < 4; i++) {
            f[LEFT][i] = tmp[3 - i];
        }
    }
 
    // front -> top
    void roll_y() {
        roll(FRONT, UP, BACK, DOWN);
 
        // rotate RIGHT & LEFT
        vector<int> tmp;
 
        tmp = f[RIGHT];
        f[RIGHT][0] = tmp[2];
        f[RIGHT][1] = tmp[0];
        f[RIGHT][2] = tmp[3];
        f[RIGHT][3] = tmp[1];
 
        tmp = f[LEFT];
        f[LEFT][0] = tmp[1];
        f[LEFT][1] = tmp[3];
        f[LEFT][2] = tmp[0];
        f[LEFT][3] = tmp[2];
 
        /*
        tmp = f[BACK];
        for(int i = 0; i < 4; i++) {
            f[BACK][i] = tmp[3 - i];
        }
 
        tmp = f[DOWN];
        for(int i = 0; i < 4; i++) {
            f[DOWN][i] = tmp[3 - i];
        }
        */
    }
 
    void rotate_front() {
        vector<vector<int> > tmp = f;
        f[FRONT][0] = tmp[FRONT][2];
        f[FRONT][1] = tmp[FRONT][0];
        f[FRONT][2] = tmp[FRONT][3];
        f[FRONT][3] = tmp[FRONT][1];
        f[UP][2] = tmp[LEFT][3];
        f[UP][3] = tmp[LEFT][1];
        f[LEFT][1] = tmp[DOWN][0];
        f[LEFT][3] = tmp[DOWN][1];
        f[DOWN][0] = tmp[RIGHT][2];
        f[DOWN][1] = tmp[RIGHT][0];
        f[RIGHT][0] = tmp[UP][2];
        f[RIGHT][2] = tmp[UP][3];
    }
 
    int fshow(FACE face, int index) {
        return f[face][index];
    }
 
    void tr2() {
        /*
        printf("  ....%3d%3d....\n", fshow(UP, 0), fshow(UP, 1));
        printf("  ....%3d%3d....\n", fshow(UP, 2), fshow(UP, 3));
        printf("%3d%3d%3d%3d%3d%3d%3d%3d\n", fshow(LEFT, 0), fshow(LEFT, 1), fshow(FRONT, 0), fshow(FRONT, 1), fshow(RIGHT, 0), fshow(RIGHT, 1), fshow(BACK, 3), fshow(BACK, 2));
        printf("%3d%3d%3d%3d%3d%3d%3d%3d\n", fshow(LEFT, 2), fshow(LEFT, 3), fshow(FRONT, 2), fshow(FRONT, 3), fshow(RIGHT, 2), fshow(RIGHT, 3), fshow(BACK, 1), fshow(BACK, 0));
        printf("  ....%3d%3d....\n", fshow(DOWN, 0), fshow(DOWN, 1));
        printf("  ....%3d%3d....\n", fshow(DOWN, 2), fshow(DOWN, 3));
        printf("\n");
        */
    }
 
    void tr() {
        printf("..%c%c....\n", colorCode(UP, 0), colorCode(UP, 1));
        printf("..%c%c....\n", colorCode(UP, 2), colorCode(UP, 3));
        printf("%c%c%c%c%c%c%c%c\n", colorCode(LEFT, 0), colorCode(LEFT, 1), colorCode(FRONT, 0), colorCode(FRONT, 1), colorCode(RIGHT, 0), colorCode(RIGHT, 1), colorCode(BACK, 3), colorCode(BACK, 2));
        printf("%c%c%c%c%c%c%c%c\n", colorCode(LEFT, 2), colorCode(LEFT, 3), colorCode(FRONT, 2), colorCode(FRONT, 3), colorCode(RIGHT, 2), colorCode(RIGHT, 3), colorCode(BACK, 1), colorCode(BACK, 0));
        printf("..%c%c....\n", colorCode(DOWN, 0), colorCode(DOWN, 1));
        printf("..%c%c....\n", colorCode(DOWN, 2), colorCode(DOWN, 3));
    }
 
private:
    void roll(FACE a, FACE b, FACE c, FACE d) {
        vector<int> tmp = f[b];
        f[b] = f[a]; f[a] = f[d];
        f[d] = f[c]; f[c] = tmp;
    }
 
    char colorCode(FACE face, int index) {
        COLOR color = id[f[face][index]];
        char c;
        switch(color) {
            case R: c = 'r'; break;
                case O: c = 'o'; break;
                case Y: c = 'y'; break;
                case G: c = 'g'; break;
                case B: c = 'b'; break;
                case W: c = 'w'; break;
                default: assert(false);
        }
        return c;
    }
};
 
void tr(Cube cube) {
    for(int i = 0; i < 4; i++) DEBUG(cube.f[FRONT][i]);
    for(int i = 0; i < 4; i++) DEBUG(cube.f[BACK][i]);
    for(int i = 0; i < 4; i++) DEBUG(cube.f[UP][i]);
    for(int i = 0; i < 4; i++) DEBUG(cube.f[DOWN][i]);
    for(int i = 0; i < 4; i++) DEBUG(cube.f[LEFT][i]);
    for(int i = 0; i < 4; i++) DEBUG(cube.f[RIGHT][i]);
}
 
int main() {
    Cube cube;
 
    cube.tr2();
 
    string s;
    cin >> s;
    int len = s.length();
    for(int i = 0; i < len; i++) {
        char c = s[i];
        switch(c) {
            case 'F':
                cube.rotate_front();
                break;
            case 'R':
                cube.roll_x();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                cube.rotate_front();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                break;
            case 'B':
                cube.roll_x();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                cube.rotate_front();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                break;
            case 'L':
                cube.roll_x();
                cube.tr2();
                cube.rotate_front();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                cube.roll_x();
                cube.tr2();
                break;
            case 'U':
                cube.roll_y();
                cube.tr2();
                cube.roll_y();
                cube.tr2();
                cube.roll_y();
                cube.tr2();
                cube.rotate_front();
                cube.tr2();
                cube.roll_y();
                cube.tr2();
                break;
            case 'D':
                cube.roll_y();
                cube.tr2();
                cube.rotate_front();
                cube.tr2();
                cube.roll_y();
                cube.tr2();
                cube.roll_y();
                cube.tr2();
                cube.roll_y();
                cube.tr2();
                break;
        }
    }
    cube.tr();
    /*
       cube.tr();
       cout << "----------" << endl;
       cube.rotate_front();
       cube.tr();
       cout << "----------" << endl;
       cube.roll_x();
       cube.tr();
       cout << "----------" << endl;
       cube.roll_x();
       cube.tr();
       cout << "----------" << endl;
       cube.roll_x();
       cube.tr();
       cout << "----------" << endl;
       cube.roll_x();
       cube.tr();
       cout << "----------" << endl;
       cube.roll_y();
       cube.tr();
       cout << "----------" << endl;
       cube.roll_y();
       cube.tr();
       cout << "----------" << endl;
       cube.roll_y();
       cube.tr();
       cout << "----------" << endl;
       cube.roll_y();
       cube.tr();
       */
}

Measured memory_bytes: 1212