{"raw_statement":[{"iden":"statement","content":"Mikhail walks on a 2D plane. He can go either up or right. You are given a sequence of Mikhail's moves. He thinks that this sequence is too long and he wants to make it as short as possible.\n\nIn the given sequence moving up is described by character _U_ and moving right is described by character _R_. Mikhail can replace any pair of consecutive moves _RU_ or _UR_ with a diagonal move (described as character _D_). After that, he can go on and do some other replacements, until there is no pair of consecutive moves _RU_ or _UR_ left.\n\nYour problem is to print the minimum possible length of the sequence of moves after the replacements."},{"iden":"input","content":"The first line of the input contains one integer _n_ (1 ≤ _n_ ≤ 100) — the length of the sequence. The second line contains the sequence consisting of _n_ characters _U_ and _R_."},{"iden":"output","content":"Print the minimum possible length of the sequence of moves after all replacements are done."},{"iden":"examples","content":"Input\n\n5\nRUURU\n\nOutput\n\n3\n\nInput\n\n17\nUUURRRRRUUURURUUU\n\nOutput\n\n13"},{"iden":"note","content":"In the first test the shortened sequence of moves may be _DUD_ (its length is 3).\n\nIn the second test the shortened sequence of moves can be _UUDRRRDUDDUUU_ (its length is 13)."}],"translated_statement":[{"iden":"statement","content":"Mikhail 在二维平面上行走。他只能向上或向右移动。给定一个 Mikhail 的移动序列，他认为这个序列太长了，希望将其尽可能缩短。\n\n在给定序列中，向上移动用字符 _U_ 表示，向右移动用字符 _R_ 表示。Mikhail 可以将任意一对连续的移动 _RU_ 或 _UR_ 替换为一个对角线移动（用字符 _D_ 表示）。之后，他可以继续进行其他替换，直到不再存在任何连续的 _RU_ 或 _UR_ 对为止。\n\n你的任务是输出经过所有替换后，移动序列的最小可能长度。\n\n输入的第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100]) —— 序列的长度。第二行包含由 #cf_span[n] 个字符 _U_ 和 _R_ 组成的序列。\n\n请输出经过所有替换后，移动序列的最小可能长度。\n\n在第一个测试用例中，缩短后的移动序列可能是 _DUD_（其长度为 #cf_span[3]）。\n\n在第二个测试用例中，缩短后的移动序列可以是 _UUDRRRDUDDUUU_（其长度为 #cf_span[13]）。"},{"iden":"input","content":"输入的第一行包含一个整数 #cf_span[n] (#cf_span[1 ≤ n ≤ 100]) —— 序列的长度。第二行包含由 #cf_span[n] 个字符 _U_ 和 _R_ 组成的序列。"},{"iden":"output","content":"请输出经过所有替换后，移动序列的最小可能长度。"},{"iden":"examples","content":"输入5RUURU输出3输入17UUURRRRRUUURURUUU输出13"},{"iden":"note","content":"在第一个测试用例中，缩短后的移动序列可能是 _DUD_（其长度为 #cf_span[3]）。在第二个测试用例中，缩短后的移动序列可以是 _UUDRRRDUDDUUU_（其长度为 #cf_span[13]）。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ n \\in \\mathbb{Z} $ be the length of the sequence.  \nLet $ S = s_1 s_2 \\dots s_n $ be a string over the alphabet $ \\{U, R\\} $, representing Mikhail's moves.\n\n**Constraints**  \n$ 1 \\leq n \\leq 100 $\n\n**Objective**  \nMinimize the length of $ S $ by repeatedly replacing any occurrence of consecutive substrings \"RU\" or \"UR\" with \"D\", until no such pair remains.  \n\nThe minimum possible length is:  \n$$\n\\min \\{ |S'| \\mid S \\xrightarrow{*} S', \\text{ where } S' \\text{ contains no substring } \"RU\" \\text{ or } \"UR\" \\}\n$$\n\nEquivalently, the problem reduces to counting the number of **non-adjacent** $ U $ and $ R $ characters after greedily merging all possible adjacent $ U $-$ R $ pairs into $ D $, where each such merge reduces the length by 1.  \n\nLet $ c_U $ be the number of $ U $'s, and $ c_R $ the number of $ R $'s in $ S $.  \nEach replacement of \"UR\" or \"RU\" consumes one $ U $ and one $ R $, producing one $ D $.  \nThe maximum number of such replacements is $ \\min(c_U, c_R) $.  \n\nThus, the minimal length is:  \n$$\nn - \\min(c_U, c_R)\n$$","simple_statement":null,"has_page_source":false}