{"raw_statement":[{"iden":"statement","content":"There are N balloons linked together in a line. Each balloon is either red, green, or blue. Mr. Light wants to get exactly one balloon of each color (exactly one red balloon, one green balloon, and one blue balloon) - no more or less. Find the minimum number of cuts he has to make to achieve this.\n\nThis picture illustrates the first sample test case: \"RRGRGRRB\". Each letter represents one of the three colors. After making these cuts, Mr. Light will get the two balloons \"GR\" and the last balloon \"B\".\n\nNote that the three balloons Mr. Light will get don't have to be disconnected, and it is only allowed to cut the rope that links the balloons together.\n\nThe input contains a string S (3 ≤ |S| ≤ 2 × 105), representing the balloons in the line. Each letter is either 'R', 'G', or 'B' and represents the color of that balloon.\n\nIt is guaranteed that for each color, there exists at least one balloon with that color.\n\nPrint the minimum number of cuts on a single line.\n\n"},{"iden":"input","content":"The input contains a string S (3 ≤ |S| ≤ 2 × 105), representing the balloons in the line. Each letter is either 'R', 'G', or 'B' and represents the color of that balloon.It is guaranteed that for each color, there exists at least one balloon with that color."},{"iden":"output","content":"Print the minimum number of cuts on a single line."},{"iden":"examples","content":"InputRRGRGRRBOutput3InputRGRGBBOutput2"}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ S = s_1 s_2 \\dots s_n $ be a string of length $ n $, where $ s_i \\in \\{R, G, B\\} $, and $ 3 \\leq n \\leq 2 \\times 10^5 $.  \nLet $ C = \\{R, G, B\\} $ denote the set of colors.  \n\n**Constraints**  \nFor each color $ c \\in C $, there exists at least one index $ i $ such that $ s_i = c $.  \n\n**Objective**  \nFind the minimum number of cuts required to extract exactly one balloon of each color (one $ R $, one $ G $, one $ B $), where a cut separates adjacent balloons. The selected balloons must form a contiguous substring (i.e., no gaps), and the number of cuts equals the number of adjacent pairs broken to isolate this substring.  \n\nEquivalently, find the minimum length of a contiguous substring of $ S $ that contains at least one occurrence of each color $ R, G, B $. Then, the minimum number of cuts is:  \n$$\n\\text{min\\_length} - 1\n$$","simple_statement":"You are given a string of 'R', 'G', 'B' representing balloons in a line. You need to cut the line to get exactly one balloon of each color (one R, one G, one B). You can only cut between balloons. Find the minimum number of cuts needed.","has_page_source":false}