BaoBao is trapped in a one-dimensional maze consisting of ngrids arranged in a row!The grids are numbered from 1 to nfrom left to right, and thei-thgrid is marked with a character si, where si is either 'L' or 'R'. Starting from the m-th grid, BaoBao will repeatedly take the following steps until he escapes the maze: 1.If BaoBao is in the1st grid or the n-th grid, then BaoBao is considered to arrive at the exit and thus can escape successfully. 2.Otherwise, let BaoBao be in the t-th grid. Ifst= 'L',BaoBao will move to the -th grid;Ifst= 'R',BaoBao will move to the -th grid; Before taking the above steps, BaoBao can change the characters in some grids to help himself escape. Concretely speaking, for the i-th grid, BaoBao can change si from 'L' to 'R', or from 'R' to 'L'. But changing characters in grids is a tiring job. Your task is to help BaoBao calculate the minimum number of grids he has to change to escape the maze.
BaoBao is trapped in a one-dimensional maze consisting of n grids arranged in a row! The grids are numbered from 1 to n from left to right, and the i-th grid is marked with a character si, where si is either 'L' or 'R'. Starting from the m-th grid, BaoBao will repeatedly take the following steps until he escapes the maze: 1.If BaoBao is in the 1st grid or the n-th grid, then BaoBao is considered to arrive at the exit and thus can escape successfully. 2.Otherwise, let BaoBao be in the t -th grid. If st = 'L', BaoBao will move to the (t - 1)-th grid; If st = 'R', BaoBao will move to the (t + 1)-th grid; Before taking the above steps, BaoBao can change the characters in some grids to help himself escape. Concretely speaking, for the i-th grid, BaoBao can change si from 'L' to 'R', or from 'R' to 'L'. But changing characters in grids is a tiring job. Your task is to help BaoBao calculate the minimum number of grids he has to change to escape the maze.