{"raw_statement":[{"iden":"statement","content":"We have a string of letters '_a_' and '_b_'. We want to perform some operations on it. On each step we choose one of substrings \"_ab_\" in the string and replace it with the string \"_bba_\". If we have no \"_ab_\" as a substring, our job is done. Print the minimum number of steps we should perform to make our job done modulo 109 + 7.\n\nThe string \"_ab_\" appears as a substring if there is a letter '_b_' right after the letter '_a_' somewhere in the string."},{"iden":"input","content":"The first line contains the initial string consisting of letters '_a_' and '_b_' only with length from 1 to 106."},{"iden":"output","content":"Print the minimum number of steps modulo 109 + 7."},{"iden":"examples","content":"Input\n\nab\n\nOutput\n\n1\n\nInput\n\naab\n\nOutput\n\n3"},{"iden":"note","content":"The first example: \"_ab_\"  →  \"_bba_\".\n\nThe second example: \"_aab_\"  →  \"_abba_\"  →  \"_bbaba_\"  →  \"_bbbbaa_\"."}],"translated_statement":[{"iden":"statement","content":"我们有一个由字母 '_a_' 和 '_b_' 组成的字符串。我们希望对它进行一些操作。在每一步中，我们选择字符串中的一个子串 \"_ab_\"，并将其替换为字符串 \"_bba_\"。当我们不再有任何 \"_ab_\" 子串时，任务完成。请输出使任务完成所需的最少操作步数，结果对 #cf_span[109 + 7] 取模。\n\n字符串 \"_ab_\" 作为子串出现，当且仅当字符串中某处存在字母 '_a_' 后紧跟字母 '_b_'。\n\n第一行包含一个仅由字母 '_a_' 和 '_b_' 组成的初始字符串，长度范围为 #cf_span[1] 到 #cf_span[106]。\n\n请输出最少操作步数，对 #cf_span[109 + 7] 取模。\n\n第一个例子：\"_ab_\" #cf_span[ → ] \"_bba_\"。\n\n第二个例子：\"_aab_\" #cf_span[ → ] \"_abba_\" #cf_span[ → ] \"_bbaba_\" #cf_span[ → ] \"_bbbbaa_\"。\n\n"},{"iden":"input","content":"第一行包含一个仅由字母 '_a_' 和 '_b_' 组成的初始字符串，长度范围为 #cf_span[1] 到 #cf_span[106]。"},{"iden":"output","content":"请输出最少操作步数，对 #cf_span[109 + 7] 取模。"},{"iden":"examples","content":"输入\nab\n输出\n1\n输入\naab\n输出\n3"},{"iden":"note","content":"第一个例子：\"_ab_\" #cf_span[ → ] \"_bba_\"。第二个例子：\"_aab_\" #cf_span[ → ] \"_abba_\" #cf_span[ → ] \"_bbaba_\" #cf_span[ → ] \"_bbbbaa_\"。"}],"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ s \\in \\{a, b\\}^* $ be the input string of length $ n $, where $ 1 \\leq n \\leq 10^6 $.  \n\n**Operation**  \nIn one step, replace any occurrence of the substring \"ab\" with \"bba\".  \n\n**Goal**  \nCompute the minimum number of such operations until no substring \"ab\" remains, modulo $ 10^9 + 7 $.  \n\n**Objective**  \nLet $ f(s) $ be the minimum number of operations to eliminate all \"ab\" substrings.  \nCompute $ f(s) \\mod (10^9 + 7) $.","simple_statement":null,"has_page_source":false}