Implement the Cubically Cube Cubically is a fairly new esoteric language capable of creating short, golf-like answers for a very specific subset of problems. It is unique in that it stores memory in the form of a 3x3 Rubik's cube, making calculations far less trivial than in most languages. In Cubically, the programmer must rotate the internal cube in order to manipulate the values stored on the faces, then use those values in their calculations. Calculations are performed on a single 32-bit integer stored on an imaginary face known as the "notepad". Additionally, Cubically can request user input and store it in an input buffer consisting of only a single integer value.

The Cube

The faces of the cube are Up, Down, Left, Right, Front, and Back:

   UUU
   UUU
   UUU
LLLFFFRRRBBB
LLLFFFRRRBBB
LLLFFFRRRBBB
   DDD
   DDD
   DDD


When the program starts, the cube is initialized such that each square on that face is equal to that face's 0-based index:

   000
   000
   000
111222333444
111222333444
111222333444
   555
   555
   555


Whenever a face is rotated, it is always rotated clockwise:

Cubically&gt; F1

   000
   000
   111
115222033444
115222033444
115222033444
   333
   555
   555


The value of a face is defined as being the sum of every square on that face. For example, in the above cube, the value of face 0 is 3.

Syntax

Commands are executed by first loading a command into memory, then passing arguments to it to execute the command. For example, the command F1 will load the command F into memory, then call it with the argument 1. Additionally, F13 will load the command F into memory, then call it with the argument 1, then call it with the argument 3. Any non-digit character is treated as a command, and any digit is treated as an argument.

Your task

Your task is to implement Cubically's internal memory cube in a language of your choice. Your code should be able to execute a very small subset of the language.

Commands


R - Rotate the right face of the cube clockwise the specified number of times.
L - Rotate the left face of the cube clockwise the specified number of times.
U - Rotate the top face of the cube clockwise the specified number of times.
D - Rotate the bottom face of the cube clockwise the specified number of times.
F - Rotate the front face of the cube clockwise the specified number of times.
B - Rotate the back face of the cube clockwise the specified number of times.
% - Outputs the value on the given face. The value of a face is defined as the sum of all squares on that face.


Rules


You may use any language created before or after the date this challenge was posted to write a program or function capable of solving this challenge.
Input will be passed in either through STDIN, as a string, or as a character array (you choose, please specify).
Output must be passed either to STDOUT or as the output of the function, and it must be either an integer, a string containing only digits, or an array of digits. If your language requires you to output a trailing newline, you may do so.
The input will always be in the following format: ([UDLRFB]\d*)*%[0-5]. There will be no whitespace characters in the input.
The input for % will always use a 0-based index.


This is code-golf, so shortest answer in bytes wins.

Test Cases

%0 -&gt; 0
%1 -&gt; 9
%2 -&gt; 18
%3 -&gt; 27
%4 -&gt; 36
%5 -&gt; 45
R1%2 -&gt; 27
RD3F2%5 -&gt; 32
L1R23F1B5U9D2%3 -&gt; 17


For more test cases, check out the TIO interpreter. If TIO isn't working, you may use the Lua interpreter instead.
Python 2, 476 bytes

import re
c=[[i]*9for i in range(6)]
r=lambda f:[f[a+b]for a in(0,1,2)for b in(6,3,0)]
U=lambda c:[r(c[0])]+[c[j+1][:3]+c[j or 4][3:]for j in(1,2,3,0)]+[c[5]]
y=lambda c:[r(c[0])]+c[2:5]+[c[1],r(r(r(c[5])))]
z=lambda c:[c[2],r(r(r(c[1]))),c[5],r(c[3]),c[0][::-1],c[4][::-1]]
s=input()
exec(&quot;c=&quot;+&quot;(c);c=&quot;.join(&quot;&quot;.join(&quot;zzzUz U zzUzz yyyzUzzzy zUzzz yzUzzzyyy&quot;.split()[ord(t)%11%7]*sum(map(int,n))for t,n in re.findall(&quot;([BUDLFR])(\d*)&quot;,s[:-2])))+&quot;(c)&quot;)
print sum(c[int(s[-1])])

Try it online!
A port from my Simulate A Rubik's Cube answer. The revisit prompted me to golf that by 47 bytes.