#include <stdio.h>
#include<ctype.h>
#include<string.h>
 void leftRot(char*str,int rot){
     char temp;
     int ind,len;
     len =strlen(str);
     for(int i=1;i<=(rot%len);i++){
     temp= str[0];
     len =strlen(str);
     for(ind=0;ind<len-1;i++){
         str[ind]=str[ind+1];
          str[ind]=temp;
     }
     }
 }
 void rightRot(char*str,int rot){
     char temp;
     int ind,len;
     len =strlen(str);
     for(int i=1;i<=(rot%len);i++){
     temp= str[len-1];
     for(ind=len-1;ind>=1;ind--){
         str[ind]=str[ind-1];
          str[ind]=temp;
     }
     }
 }
int main() {
 int main() {
    char str[20];
    char dir[20], newstr[20],copy[20];
    int ind,len,j=0,rot=0;
    scanf("%s", str);
    scanf(" %c", dir);
    len=strlen(dir);
for(ind=0;ind<len;ind++){
    int rot=0;
    if(dir[ind]>='0'&&dir[ind]<='9'){
        rot=(rot * 10)+(dir[ind]-48);
    }
    if(dir[ind] =='L'||dir[ind] =='l'){
        leftRot(str,rot);
        newstr[j++]=str[0];
        rot=0;
    }
    else if(dir[ind] =='R'||dir[ind] =='r'){
        rightRot(str,root);
        newstr[j++]=str[0];
        rot=0;
    }
}
newstr[j++]='\0';
    if(strstr(copy,newstr)){
    
    printf("yes");
    }
    else{
    return 0;
    }
}


}