{"raw_statement":[{"iden":"statement","content":"There are $n$ soldiers in the line, standing shoulder to shoulder from left to right. Each soldier's head is turned either to the left or to the right, that is, each of the soldiers is looking either strictly to the left or strictly to the right.\n\nYou need to give some of the soldiers an order to turn their heads in the opposite direction. That means, after executing this order, a soldier looking to the left should turn his head to the right, and a soldier looking to the right should turn his head to the left. After executing the order, there should exist a soldier such that all other soldiers look at him (it doesn't matter in which direction that soldier looks). Only the soldiers who were given the order turn their heads.\n\nFor example, if there are $5$ soldiers in the line, the first three soldiers are looking to the right, and the fifth soldier is looking to the left, then they all are looking at the fourth soldier.\n\nFind the minimum number of soldiers who should be given the order to turn their heads so that all the soldiers were looking in the direction of some single soldier.\n\nThe first line contains an integer $n$ ($2 <= n <= 2 thin 000$) — the number of soldiers in the line.\n\nThe second line contains a string $s$ of length $n$, consisting of the letters \"_L_\" and \"_R_\". If the $i$-th character of the string is \"_L_\", then the $i$-th soldier is looking to the left. If the $i$-th character of the string is \"_R_\", then the $i$-th soldier is looking to the right.\n\nPrint the minimum number of soldiers who should be given the order to turn their heads so that there exists a soldier such that all other soldiers look at him (it doesn't matter in which direction that soldier looks).\n\nIn the first example, you need to give the order, for example, to the first and sixth soldiers. After that, the line would look like \"_RRRRLL_\". So everyone except the fifth soldier would be looking at the fifth soldier.\n\nIn the second example, all the soldiers are looking to the left, so the second and third soldiers are looking at the first soldier, so you don't need to give any orders.\n\n"},{"iden":"input","content":"The first line contains an integer $n$ ($2 <= n <= 2 thin 000$) — the number of soldiers in the line.The second line contains a string $s$ of length $n$, consisting of the letters \"_L_\" and \"_R_\". If the $i$-th character of the string is \"_L_\", then the $i$-th soldier is looking to the left. If the $i$-th character of the string is \"_R_\", then the $i$-th soldier is looking to the right."},{"iden":"output","content":"Print the minimum number of soldiers who should be given the order to turn their heads so that there exists a soldier such that all other soldiers look at him (it doesn't matter in which direction that soldier looks)."},{"iden":"examples","content":"Input6\nLRRRLR\nOutput2\nInput3\nLLL\nOutput0\nInput10\nLLRRLRRRRL\nOutput3\n"},{"iden":"note","content":"In the first example, you need to give the order, for example, to the first and sixth soldiers. After that, the line would look like \"_RRRRLL_\". So everyone except the fifth soldier would be looking at the fifth soldier.In the second example, all the soldiers are looking to the left, so the second and third soldiers are looking at the first soldier, so you don't need to give any orders."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ with $ 2 \\leq n \\leq 2000 $.  \nLet $ s = s_1 s_2 \\dots s_n $ be a string over $ \\{L, R\\} $, where $ s_i = L $ means soldier $ i $ looks left, $ s_i = R $ means soldier $ i $ looks right.\n\n**Constraints**  \nFor each soldier $ i \\in \\{1, \\dots, n\\} $:  \n- If $ s_i = L $, the soldier looks toward soldier $ i-1 $ (if $ i > 1 $).  \n- If $ s_i = R $, the soldier looks toward soldier $ i+1 $ (if $ i < n $).\n\n**Objective**  \nFind the minimum number of soldiers to flip (i.e., change $ L \\leftrightarrow R $) such that there exists an index $ k \\in \\{1, \\dots, n\\} $ where:  \n- For all $ i < k $, soldier $ i $ looks right (i.e., $ s_i = R $),  \n- For all $ i > k $, soldier $ i $ looks left (i.e., $ s_i = L $).  \n\nThat is, find:  \n$$\n\\min_{k=1}^{n} \\left( \\sum_{i=1}^{k-1} \\mathbf{1}_{s_i \\neq R} + \\sum_{i=k+1}^{n} \\mathbf{1}_{s_i \\neq L} \\right)\n$$","simple_statement":"You have n soldiers in a line, each looking left (L) or right (R).  \nYou can flip any soldier’s direction (L→R or R→L).  \nGoal: Make all soldiers look toward at least one common soldier (the “center”).  \nFind the minimum number of flips needed.  \n\nA soldier looks at another if they are facing them directly:  \n- An L looks left → sees all soldiers to its left.  \n- An R looks right → sees all soldiers to its right.  \n\nSo, for a soldier at position i to be the center:  \n- All soldiers to the left of i must be R (looking right → at i).  \n- All soldiers to the right of i must be L (looking left → at i).  \n\nFind the center position i that requires the fewest flips to satisfy this.","has_page_source":false}