The Fair Nut found a string $s$. The string consists of lowercase Latin letters. The Nut is a curious guy, so he wants to find the number of strictly increasing sequences $p_1, p_2, \ldots, p_k$, such that:   For each $i$ ($1 \leq i \leq k$), $s_{p_i} =$ 'a'.  For each $i$ ($1 \leq i < k$), there is such $j$ that $p_i < j < p_{i + 1}$ and $s_j =$ 'b'. 

The Nut is upset because he doesn't know how to find the number. Help him.

This number should be calculated modulo $10^9 + 7$.


-----Input-----

The first line contains the string $s$ ($1 \leq |s| \leq 10^5$) consisting of lowercase Latin letters.


-----Output-----

In a single line print the answer to the problem — the number of such sequences $p_1, p_2, \ldots, p_k$ modulo $10^9 + 7$.


-----Examples-----
Input
abbaa

Output
5
Input
baaaa

Output
4
Input
agaa

Output
3


-----Note-----

In the first example, there are $5$ possible sequences. $[1]$, $[4]$, $[5]$, $[1, 4]$, $[1, 5]$.

In the second example, there are $4$ possible sequences. $[2]$, $[3]$, $[4]$, $[5]$.

In the third example, there are $3$ possible sequences. $[1]$, $[3]$, $[4]$.

Difficulty: MEDIUM
Tags: Dynamic programming

Combinatorics

Implementation
Skill types: Dynamic programming

Starter code:

Solutions:
import math

def seq_count(str_):
	prev = None
	base_a = 0
	a_count = 0
	seq_count = 0
	for i in range(len(str_) - 1, -1, -1):
		if arr[i] == 'a':
			seq_count += 1
			seq_count += base_a
			a_count += 1
		elif arr[i] == 'b' and prev != 'b':
			base_a = seq_count
			a_count = 0
		prev = arr[i]
	return seq_count % (10 ** 9 + 7)
arr = input()
print(seq_count(arr))


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *

def main():
	mod = 1000000007
	s = []
	for i in input().rstrip():
		if i == 'a' or i == 'b':
			s.append(i)
	a = []
	n = len(s)
	i = 0
	while i < n:
		if s[i] == 'a':
			l = 1
			j = i + 1
			while j < n:
				if s[j] == 'b':
					break
				j += 1
			a.append(j - i)
			i = j
		i += 1
	p = 1
	for i in a:
		p = p * (i + 1) % mod
	print((p - 1) % mod)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


s = input()
ans = 0
sum1 = 0
sum2 = 0
MOD = 10 ** 9 + 7
dp = [0] * (len(s) + 1)
currsum1 = 0
currsum2 = 0
for i in range(len(s)):
	if s[i] == 'a':
		currsum1 = (currsum1 + currsum2 + 1) % MOD
		dp[i] = currsum2 + 1
	if s[i] == 'b':
		currsum2 = (currsum2 + currsum1) % MOD
		currsum1 = 0
print(sum(dp) % MOD)


s = input()
a = 1
res = 1
for i in s:
	if i == 'b':
		res *= a
		a = 1
	elif i == 'a':
		a += 1
res *= a
print((res - 1) % 1000000007)


s = input()
news = ''
for c in s:
	if c in ['a', 'b']:
		news += c
news += '#a'
i = 0
while news[i] != 'a':
	i += 1
tot = 1
(a, b) = ('a', 'b')
while i < len(news) - 2:
	count = 0
	while a == news[i]:
		count += 1
		i += 1
	if a == 'a':
		tot *= count + 1
		tot %= 10 ** 9 + 7
	(a, b) = (b, a)
print(tot - 1)


from math import factorial
s = input()
s = ''.join([c for c in s if c == 'a' or c == 'b']).split('b')
MOD = 10 ** 9 + 7
res = 1
for g in s:
	res += len(g) * res % MOD
	res %= MOD
print((res - 1 + MOD) % MOD)


s = [x.count('a') for x in input().split('b') if x.count('a') > 0]
if len(s) == 0:
	print(0)
else:
	dp = [0] * len(s)
	for i in reversed(range(len(s))):
		if i == len(s) - 1:
			dp[i] = s[i]
		else:
			dp[i] = s[i] + s[i] * dp[i + 1] + dp[i + 1]
	print(dp[0] % 1000000007)


(ans, v) = (1, 1)
for c in input():
	v = v + 1 if c == 'a' else v
	if c == 'b':
		ans = ans * v % 1000000007
		v = 1
print((ans * v - 1) % 1000000007)


s = input()
(size, mod, res, i) = (len(s), 1000000007, 1, 0)
while i < size:
	(j, aux) = (i, 1)
	while j < size:
		if s[j] == 'a':
			aux += 1
			j += 1
		elif s[j] == 'b':
			break
		else:
			j += 1
	(i, res) = (j, res * aux % mod)
	i += 1
print(res - 1)


s = input()
arr = []
t = 0
r = 0
M = 1000000007
for c in s:
	if c == 'b':
		t = r
	if c == 'a':
		r = (r + t + 1) % M
print(r)


s = input()
temp = 0
sum = 1
mod = 10 ** 9 + 7
for i in range(len(s)):
	if s[i] == 'a':
		temp += 1
	elif s[i] == 'b' and s[i - 1] != 'b':
		sum *= (temp + 1) % mod
		temp = 0
print((sum * (temp + 1) - 1) % mod)


s = input()
a = []
b = []
for i in range(len(s)):
	if s[i] == 'a':
		a.append(i)
	if s[i] == 'b':
		b.append(i)
dp = [0 for i in range(len(a))]
if len(a) >= 1:
	dp[0] = 1
else:
	print(0)
	exit()
i = a[0] + 1
flag = 0
t = 1
pre = [1]
while i < len(s):
	if s[i] == 'b':
		flag = 1
	if s[i] == 'a':
		if flag == 1:
			dp[t] = pre[-1] + 1
			dp[t] %= 10 ** 9 + 7
		else:
			dp[t] = dp[t - 1]
		t += 1
		flag = 0
		pre.append(pre[-1] + dp[t - 1])
		pre[-1] %= 10 ** 9 + 7
	i += 1
print(sum(dp) % (10 ** 9 + 7))


s = input()
m = 10 ** 9 + 7
x = [1]
for c in s:
	if c == 'b' and x[-1] != 1:
		x.append(1)
	if c == 'a':
		x[-1] += 1
a = 1
for v in x:
	a *= v
	a %= m
print(a - 1)


string = input()
clean = list()
cnt = 1
for c in string:
	if c == 'a' or c == 'b':
		if len(clean) == 0:
			clean.append(c)
		elif c == 'b':
			if clean[-1] != 'b':
				clean.append(c)
		else:
			clean.append(c)
splt = ''.join(clean).split('b')
for i in range(len(splt)):
	cnt *= len(splt[i]) + 1
print((cnt - 1) % 1000000007)


import re
s = input()
ans = 1
s = re.sub('[^a-b]', '', s)
s = re.sub('b+', 'b', s)
s = re.sub('^b', '', s)
s = re.sub('b$', '', s)
s = s.split('b')
for i in range(len(s)):
	ans = (ans * len(s[i]) + ans) % (10 ** 9 + 7)
print(ans - 1)


s = input()
n = len(s)
MOD = 10 ** 9 + 7
bckt = []
ct = 0
for i in range(n):
	if s[i] == 'a':
		ct += 1
	elif s[i] == 'b' and ct:
		bckt.append(ct)
		ct = 0
if ct:
	bckt.append(ct)
prod = 1
for i in bckt:
	prod = prod * (i + 1) % MOD
prod = (prod - 1) % MOD
print(prod)


n2 = input()
n = ''
for i in n2:
	if i == 'a' or i == 'b':
		n += i
while n.startswith('b'):
	n = n[1:]
while n.endswith('b'):
	n = n[:-1]
s = 1
numbers_of_a = 0
while n:
	k = n.find('b')
	if k != -1:
		s *= k + 1
		n = n[k + 1:]
	else:
		s *= len(n) + 1
		break
print((s - 1) % 1000000007)


s = input()
p = 10 ** 9 + 7
a = []
for ch in s:
	if ch == 'a':
		if len(a) == 0 or a[-1][1] == True:
			a += [(1, False)]
		else:
			a[-1] = (a[-1][0] + 1, False)
	if ch == 'b' and len(a) > 0:
		a[-1] = (a[-1][0], True)
n = len(a)
dp = {}
dp[n] = 1
for i in range(n - 1, -1, -1):
	dp[i] = dp[i + 1] * (1 + a[i][0]) % p
print((dp[0] - 1) % p)


s = list(input())

def poss(arr):
	n = len(arr)
	ans = 1
	for i in range(0, n):
		ans = ans * (arr[i] + 1)
	return ans - 1
cs = [0]
for i in s:
	if i == 'a':
		cs[-1] += 1
	elif i == 'b' and cs[-1] != 0:
		cs.append(0)
print(poss(cs) % (10 ** 9 + 7))


s1 = input()
s = ''
for i in s1:
	if i in 'ab':
		s += i
n = len(s)
ans = 1
i = 0
while i < n:
	x = 0
	while i < n and s[i] == 'a':
		i += 1
		x += 1
	ans *= x + 1
	i += 1
MOD = 10 ** 9 + 7
print((ans - 1) % MOD)


s = input()
a = []
b = 0
for i in range(0, len(s)):
	if s[i] == 'a' or s[i] == 'b':
		a.append(s[i])
		if s[i] == 'b':
			b += 1
if len(a) == 0 or b == len(a):
	print(0)
else:
	blocks = []
	i = 0
	while i < len(a):
		if a[i] == 'a':
			m = 1
			i += 1
			while i < len(a):
				if a[i] == 'a':
					m += 1
					i += 1
				else:
					break
			blocks.append(m)
		else:
			i += 1
	ans = 1
	for i in range(0, len(blocks)):
		ans = ans * (blocks[i] + 1)
	print((ans - 1) % (10 ** 9 + 7))


import os, sys, bisect
from collections import defaultdict, Counter, deque
from functools import lru_cache
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')
input = lambda : sys.stdin.readline().strip()
imap = lambda : map(int, input().split())
ilist = lambda : list(imap())
mod = int(1000000000.0 + 7)
s = input().strip()
a = []
for i in s:
	if i in ['a', 'b']:
		a.append(i)
n = len(a)
tota = []
cnt = 0
for i in range(n):
	if a[i] == 'a':
		cnt += 1
	else:
		if cnt:
			tota.append(cnt)
		cnt = 0
if cnt:
	tota.append(cnt)
res = 1
for i in tota:
	res += res * i % mod
	res %= mod
print(res - 1)


s = input()
ln = len(s)
cnt = [0 for i in range(ln)]
(ans, mod, prev_b) = (0, 10 ** 9 + 7, -1)
for i in range(ln):
	if s[i] == 'a':
		ans += 1
		if prev_b > -1:
			ans += cnt[prev_b]
		ans %= mod
	if s[i] == 'b':
		cnt[i] = ans % mod
		prev_b = i
print(ans % mod)


import sys
input = sys.stdin.readline
read = lambda : map(int, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def upper_bound(a, x, lo=0, hi=None):
	if hi == None:
		hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
from bisect import bisect_left

def solve():
	s = input().rstrip()
	count = 0
	ans = 0
	for i in range(len(s)):
		if s[i] == 'b':
			count = ans
		elif s[i] == 'a':
			ans = (ans + count + 1) % MOD
	print(ans)
for _ in range(1):
	solve()


from sys import stdin
import math

def clean_it(string):
	mystack = []
	for i in range(len(string)):
		if string[i] == 'a' or string[i] == 'b':
			if len(mystack) == 0:
				if string[i] == 'a':
					mystack.append(string[i])
			elif mystack[-1] == 'a':
				mystack.append(string[i])
			elif mystack[-1] == 'b':
				if string[i] == 'a':
					mystack.append(string[i])
	return mystack
mod = 10 ** 9 + 7
string = list(stdin.readline().strip())
string = ''.join(clean_it(string))
string = list(string.split('b'))
product = 1
for i in string:
	product *= len(i) + 1
	product %= mod
print(product - 1)


hell = 1000000007
s = list(input())
n = len(s)
count = 1
x = 0
for i in range(n):
	if s[i] == 'a':
		x += 1
	if s[i] == 'b':
		count = count * (x + 1) % hell
		x = 0
print((count * (x + 1) % hell - 1 + hell) % hell)


mod = 1000000007

def md(x):
	return (x % mod + mod) % mod
s = input()
r = 1
a = 1
for i in s:
	if i == 'a':
		a += 1
	elif i == 'b':
		r = md(r * a)
		a = 1
r = md(r * a)
print(md(r - 1))


s = input()
s += 'b'
ss = []
last = 0
for i in s:
	if i == 'a':
		last += 1
	elif i == 'b' and last != 0:
		ss.append(last)
		last = 0
M = 1000000007
ans = 1
for i in ss:
	ans *= i + 1
	ans %= M
print(ans - 1)


inp = __import__('sys').stdin.readline
a = [i.count('a') for i in inp().split('b') if i.count('a')]
if not a:
	print(0)
	exit()
(b, m) = (a[0], 10 ** 9 + 7)
for i in a[1:]:
	b = ((i + 1) * (b + 1) - 1) % m
print(b)


import sys
string = list(input())
string.append('b')
lis = []
a = 0
for i in string:
	if i == 'a':
		a += 1
	elif i == 'b':
		lis.append(a)
		a = 0
total = lis[0]
for k in lis[1:]:
	total = total * (k + 1) + k
	total %= 1000000007
print(total)


r = t = 0
for c in input():
	if c == 'b':
		t = r
	if c < 'b':
		r = (r + t + 1) % (10 ** 9 + 7)
print(r)


M = 1000000007
S = input()
flag = False
count = 0
List = []
for i in range(len(S)):
	if S[i] == 'b' and flag and count:
		List.append(count)
		count = 0
	elif S[i] == 'a':
		count += 1
		flag = True
if flag:
	List.append(count)
if not List:
	print(0)
	exit()
N = len(List)
dp = [0] * N
dp[0] = List[0]
for i in range(1, N):
	dp[i] = dp[i - 1] + List[i] + dp[i - 1] * List[i]
	dp[i] %= M
print(dp[-1])


s = str(input())
s += 'b'
a = []
MOD = int(pow(10, 9)) + 7
count = 0
for i in s:
	if i == 'b':
		a.append(count + 1)
		count = 0
	elif i == 'a':
		count += 1
total = 1
for i in a:
	total = total * i % MOD
print(total - 1)


n = input()
k = []
i = 0
a = len(n)
x = 0
p = 1
q = 0
while i < a:
	if n[i] == 'a':
		q += 1
		x += 1
	if n[i] == 'b':
		p = 0
		k += [x]
		x = 0
	i += 1
k += [x]
if p == 1:
	print(q)
else:
	z = 1
	for i in k:
		z *= i + 1
	z -= 1
	print(z % (10 ** 9 + 7))


s = input()
A = []
a = 0
b = 0
for i in range(len(s)):
	if s[i] == 'a':
		a += 1
		b = 0
	if s[i] == 'b':
		b += 1
		if a > 0:
			A.append(a)
			a = 0
if a > 0:
	A.append(a)
if len(A) > 0:
	dp = [0] * (len(A) + 1)
	dp[0] = A[0]
	for i in range(1, len(A)):
		dp[i] = dp[i - 1] + A[i] * (1 + dp[i - 1])
	print(dp[len(A) - 1] % 1000000007)
else:
	print(0)


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
s = input().strip()
x = []
for i in range(len(s)):
	if s[i] == 'a' or s[i] == 'b':
		x.append(s[i])
x.append('b')
c = 0
ans = 1
for i in range(len(x)):
	if x[i] == 'a':
		c += 1
	else:
		ans *= c + 1
		c = 0
ans -= 1
ans %= 10 ** 9 + 7
print(ans)


(ans, cur) = (0, 0)
for c in input():
	if c == 'a':
		ans += cur + 1
	if c == 'b':
		cur = ans
	ans %= 1000000007
print(ans)


s = input()
t = ''
N = len(s)
pre = '.'
MOD = 10 ** 9 + 7
for i in range(N):
	if s[i] == 'a':
		t += 'a'
		pre = 'a'
	elif s[i] == 'b' and pre != 'b':
		t += 'b'
		pre = 'b'
q = t.split('b')
num = 1
for i in q:
	num *= len(i) + 1
	num %= MOD
num -= 1
if num < 0:
	num += MOD
print(num)


mod = 1000000007
s = str(input())
ans = 1
count1 = 0
arr = []
i = 0
while i < len(s):
	if s[i] == 'b':
		i += 1
		break
	elif s[i] == 'a':
		i += 1
		count1 += 1
	else:
		i += 1
count2 = 0
while i < len(s):
	if s[i] == 'b':
		if count2 > 0:
			arr.append(count1)
			count1 = count2
			count2 = 0
	elif s[i] == 'a':
		count2 += 1
	i += 1
if count1 > 0:
	arr.append(count1)
if count2 > 0:
	arr.append(count2)
for i in range(len(arr)):
	ans = ans % mod * ((arr[i] % mod + 1 % mod) % mod) % mod
ans = ((ans % mod - 1 % mod) % mod + mod) % mod
print(ans)


mod = 10 ** 9 + 7
s = list(input())
sa = []
i = 0
cnt = 0
for i in s:
	if i == 'a' or i == 'b':
		sa.append(i)
s = ''.join(sa)
i = 0
l = []
while i < len(s):
	j = i
	while s[j] == 'a':
		cnt += 1
		j += 1
		if j == len(s):
			break
	if j == len(s):
		l.append(cnt)
	if j == len(s):
		break
	if s[j] != 'a':
		i = j + 1
		if s[j] == 'b':
			l.append(cnt)
			cnt = 0
	else:
		i = j
ans = 1
for i in l:
	ans = ans % mod * (i + 1) % mod
	ans = ans % mod
print(ans % mod - 1)


s = input()
mod = 10 ** 9 + 7
n = len(s)
dp = [[]] * (n + 1)
dp[0] = [0, -1]
for i in range(n):
	j = i + 1
	dp[j] = dp[i].copy()
	if s[i] == 'b':
		dp[j][1] = j
	elif s[i] == 'a':
		dp[j][0] = (dp[i][0] + 1 + (dp[dp[i][1]][0] if dp[i][1] != -1 else 0)) % mod
print(dp[n][0] % mod)


from functools import reduce
from itertools import groupby
lim = 10 ** 9 + 7
gs = [len(list(g)) + 1 for (k, g) in groupby(filter(lambda o: o in ['a', 'b'], list(input()))) if k == 'a']
print((reduce(lambda x, y: x * y % lim, gs, 1) - 1) % lim)


s = input()
n = len(s)
mod = 10 ** 9 + 7
num = 0
ar = [0] * (n + 1)
for i in range(n):
	if s[i] == 'a':
		ar[i + 1] = ar[i] + num + 1
		ar[i + 1] %= mod
	else:
		ar[i + 1] = ar[i]
		if s[i] == 'b':
			num = ar[i]
print(ar[-1])


s = input()
(lastb_ans, ans, is_b) = (0, 0, 0)
for ch in s:
	if ch == 'a':
		ans = lastb_ans + ans + 1
		is_b = 0
	elif ch == 'b':
		lastb_ans = ans
		is_b = 1
	ans %= 1000000007
print(ans)


s = input()
ans = 0
c = 0
for i in range(0, len(s)):
	if s[i] == 'a':
		ans += 1
		ans += c
		ans %= 10 ** 9 + 7
	if s[i] == 'b':
		c = ans
print(ans)


MOD = 10 ** 9 + 7
s = input()
temp = ''
for i in s:
	if i == 'a' or i == 'b':
		temp += i
d = temp.split('b')
ans = 1
for i in d:
	ans *= len(i) + 1
	ans %= MOD
print(ans - 1)


def main():
	s = input()
	a = 1
	out = 1
	for i in s:
		if i == 'b':
			out *= a
			a = 1
		if i == 'a':
			a = a + 1
	out *= a
	out = out - 1
	out %= 1000000000 + 7
	print(out)
main()


s = input()
withb = 0
withoutb = 0
ans = 0
for i in s:
	if i == 'a':
		ans += withb + 1
		ans %= 10 ** 9 + 7
		withoutb += withb + 1
		withoutb %= 10 ** 9 + 7
	elif i == 'b':
		withb += withoutb
		withb %= 10 ** 9 + 7
		withoutb = 0
print(ans % (10 ** 9 + 7))


s = input()
(lst, a) = ([], 0)
for (i, x) in enumerate(s):
	if x == 'b':
		if a > 0:
			lst.append(a)
			a = 0
	elif x == 'a':
		a += 1
if a > 0:
	lst.append(a)
res = 0
for (i, x) in enumerate(lst):
	if i == 0:
		res += x
	else:
		res += x * (res + 1)
		res = res % 1000000007
print(res)


m = 10 ** 9 + 7
s = input()
n = len(s)
a = 0
b = 0
k = 0
table = [0] * (n + 1)
dp = [0] * (n + 1)
ans = [0] * (n + 1)
for i in range(n):
	if s[i] == 'a':
		a = a + 1
		table[b] = table[b] + 1
		c = b
	elif s[i] == 'b':
		b = b + 1
	else:
		k = k + 1
if k == n:
	print(0)
else:
	dp[c] = table[c]
	ans[c] = table[c]
	prev = c
	for i in range(c - 1, -1, -1):
		if table[i] != 0:
			dp[i] = (ans[prev] % m * (table[i] % m) + table[i] % m) % m
			ans[i] = (dp[i] % m + ans[prev] % m) % m
			prev = i
	if prev == c:
		print(dp[prev])
	else:
		res = 0
		for i in range(n + 1):
			res = (res + dp[i] % m) % m
		print(res)


s = input()
mod = 10 ** 9 + 7
w = []
z = 1
for i in s:
	if i in ['a', 'b']:
		if i == 'b' and z != 0:
			w.append(z)
			z = 1
		else:
			z += 1
w.append(z)
r = 1
for i in w:
	r = r * i % mod
print(r - 1)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Prime_factors(n):
	i = 2
	factors = set()
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.add(i)
	if n > 1:
		factors.add(n)
	print(factors)
	if len(factors) == 2:
		return True
	else:
		return False

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def Sieve(n):
	prime = [True for i in range(n + 1)]
	lst = []
	p = 2
	while p * p <= n:
		if prime[p]:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p = p + 1
	for i in range(2, n + 1):
		if prime[i]:
			lst.append(i)
	return lst

def minimum_integer_not_in_list(a):
	b = max(a)
	if b < 1:
		return 1
	A = set(a)
	B = set(range(1, b + 1))
	D = B - A
	if len(D) == 0:
		return b + 1
	else:
		return min(D)

def solution():
	s = Lstr()
	ans = [0, 0]
	for i in range(len(s)):
		if s[i] == 'b':
			ans[1] = ans[0]
		elif s[i] == 'a':
			ans[0] = (sum(ans) + 1) % Mod()
	print(ans[0] % Mod())
solution()


import sys, os, io
from sys import stdin
from math import log, gcd, ceil
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_left, bisect_right
import math
alphabets = list('abcdefghijklmnopqrstuvwxyz')
from types import GeneratorType

def bootstrap(f, stack=[]):

	def wrappedfunc(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		else:
			to = f(*args, **kwargs)
			while True:
				if type(to) is GeneratorType:
					stack.append(to)
					to = next(to)
				else:
					stack.pop()
					if not stack:
						break
					to = stack[-1].send(to)
			return to
	return wrappedfunc

def ncr(n, r, p):
	num = den = 1
	for i in range(r):
		num = num * (n - i) % p
		den = den * (i + 1) % p
	return num * pow(den, p - 2, p) % p

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			l.append(int(i))
			n = n / i
	if n > 2:
		l.append(n)
	c = dict(Counter(l))
	return list(set(l))

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def sieveForSmallestPrimeFactor():
	MAXN = 100001
	spf = [0 for i in range(MAXN)]
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, math.ceil(math.sqrt(MAXN))):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
	return spf

def getPrimeFactorizationLOGN(x):
	spf = sieveForSmallestPrimeFactor()
	ret = list()
	while x != 1:
		ret.append(spf[x])
		x = x // spf[x]
	return ret

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def si():
	return input()

def divideCeil(n, x):
	if n % x == 0:
		return n // x
	return n // x + 1

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def solve():
	s = list(si())
	st = []
	for i in range(len(s)):
		if s[i] in ['a', 'b']:
			if st == []:
				st.append(s[i])
			elif s[i] == 'b':
				while st != [] and st[-1] == 'b':
					st.pop(-1)
				st.append('b')
			else:
				st.append('a')
	if st == []:
		print(0)
		return
	if st[-1] == 'b':
		st.pop(-1)
	if st == []:
		print(0)
		return
	if st[0] == 'b':
		st.pop(0)
	if st == []:
		print(0)
		return
	mod = int(1000000000.0) + 7
	ans = 1
	c = 0
	for i in range(len(st)):
		if st[i] == 'a':
			c += 1
		else:
			ans *= c + 1
			ans %= mod
			c = 0
	ans *= c + 1
	ans %= mod
	print(ans - 1)
t = 1
for _ in range(t):
	solve()


s = input()
lengths = []
cnt = 0
eps = 1e-08
for c in s:
	if c == 'b':
		if cnt > 0:
			lengths.append(cnt)
		cnt = 0
	elif c == 'a':
		cnt += 1
if cnt > 0:
	lengths.append(cnt)
	cnt = 0
ans = 1
for l in lengths:
	ans *= l + 1
	ans %= 1000000000.0 + 7
ans -= 1
print(int(ans % (1000000000.0 + 7) + eps))


import sys
input = sys.stdin.readline
import math
import copy
import collections
from collections import deque
import heapq
import itertools
from collections import defaultdict
from collections import Counter
s = input().rstrip()
n = len(s)
mod = 10 ** 9 + 7
dp = [0 for i in range(n)]
for i in range(n):
	if s[i] == 'a':
		dp[i] = 1
sm = 0
prev = 0
for i in range(n):
	if s[i] == 'a':
		dp[i] += sm
	elif s[i] == 'b':
		sm += prev
		sm %= mod
		prev = 0
	else:
		pass
	dp[i] %= mod
	prev += dp[i]
	prev %= mod
ans = 0
for i in range(n):
	ans += dp[i]
	ans %= mod
print(ans)


s = input()
a_count = [0] * (len(s) + 1)
prev = curr = None
ab_seen = False
x = 0
mod = 10 ** 9 + 7
while x < len(s) and s[x] != 'a':
	x += 1
if x < len(s):
	curr = 1
	prev = 0
else:
	curr = 0
x += 1
new_curr = None
while x < len(s):
	while x < len(s) and s[x] != 'a':
		if s[x] == 'b':
			ab_seen = True
		x += 1
	if x == len(s):
		break
	if ab_seen:
		new_curr = curr * 2 + 1
	else:
		new_curr = 2 * curr - prev
	new_curr = new_curr % mod
	ab_seen = False
	prev = curr
	curr = new_curr
	x += 1
print(curr % mod)


s = input()
n = len(s)
b = []
a = [0] * n
MOD = 10 ** 9 + 7
if s[0] == 'a':
	a[0] = 1
if s[0] == 'b':
	b.append(0)
for i in range(1, n):
	a[i] = a[i - 1]
	if s[i] == 'a':
		a[i] += 1
		if len(b) > 0:
			p = b[-1]
			if p > 0:
				a[i] += a[p - 1]
	elif s[i] == 'b':
		b.append(i)
	a[i] %= MOD
print(a[n - 1] % MOD)


s = input()
mod = 10 ** 9 + 7
L = []
c = 0
f = 0
for i in s:
	if i == 'a':
		f = 0
		c += 1
	elif i == 'b' and f == 0:
		L.append(c)
		c = 0
		f = 1
if c > 0 and f == 0:
	L.append(c)
res = 1
for i in range(len(L)):
	res *= (L[i] + 1) % mod
print((res - 1) % mod)


s = input()
n = len(s)
a = 0
b = 0
ans = 0
mod = 10 ** 9 + 7
for i in range(n):
	if s[i] == 'a':
		ans = (ans + 1) % mod
		ans = (ans + a) % mod
		b = (b + 1 + a) % mod
	elif s[i] == 'b':
		a = (a + b) % mod
		b = 0
print(ans)


import sys
s = sys.stdin.readline().strip()
l = len(s)
result = 1
a = 0
for i in range(0, l):
	if s[i] == 'a':
		a = a + 1
	elif s[i] == 'b':
		result = result * (a + 1) % (10 ** 9 + 7)
		a = 0
result = result * (a + 1) % (10 ** 9 + 7)
print(result - 1)


def prog():
	s = input()
	ab = []
	mod = 10 ** 9 + 7
	ans = 1
	cnt = 1
	for i in s:
		if i == 'a':
			cnt += 1
		elif i == 'b':
			ans = ans * cnt % mod
			cnt = 1
	ans = ans * cnt % mod
	ans -= 1
	while ans < 0:
		ans += mod
	return ans % mod
print(prog())


s = input()
constant = 10 ** 9 + 7

def possible_ways(s):
	last_a_count = 1
	count = 0
	has_a = has_b = False
	for c in s:
		if c == 'a':
			has_a = True
			if has_b:
				last_a_count = count + 1
			count += last_a_count
			last_a_count %= constant
			count %= constant
			has_b = False
		elif c == 'b' and has_a:
			has_b = True
	return count
print(possible_ways(s))


from itertools import groupby
from functools import reduce
s = input().strip()
s = ''.join((c for c in s if c in {'a', 'b'}))
runs = []
for (key, grp) in groupby(s):
	if key == 'a':
		runs.append(len(tuple(grp)))
adj = [l + 1 for l in runs]
result = (reduce(lambda x, y: x * y % (10 ** 9 + 7), adj, 1) - 1) % (10 ** 9 + 7)
print(result)


from functools import reduce
from itertools import groupby
s = input()
div = 10 ** 9 + 7
s = [len(list(g)) for (k, g) in groupby(filter(lambda k: k in 'ab', s)) if k == 'a']
a = reduce(lambda w1, w2: w1 * (w2 % div) % div, (q + 1 for q in s), 1) - 1
print(a)


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, OrderedDict
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()

def solve(st):
	bcnt = st.count('b')
	if bcnt == 0:
		return st.count('a')
	block = []
	cnt = 0
	for i in range(len(st)):
		if st[i] == 'a':
			cnt += 1
		elif st[i] == 'b':
			if i != 0 and cnt > 0:
				block.append(cnt)
				cnt = 0
	if st[-1] != 'b':
		block.append(cnt)
	ans = 1
	for bl in block:
		ans *= (bl + 1) % MOD
	return (ans - 1) % MOD
MOD = 10 ** 9 + 7
s = stringIn()
ans = solve(s)
print(ans)


old_palavra = input()
a_palavra = []
for letra in old_palavra:
	if letra == 'a':
		a_palavra.append(letra)
	if letra == 'b' and len(a_palavra) > 0 and (a_palavra[-1] == 'a'):
		a_palavra.append(letra)
matrix_palavra = [[]]
arrayinterno = 0
for i in a_palavra:
	if i == 'a':
		matrix_palavra[arrayinterno].append(i)
	else:
		matrix_palavra.append([])
		arrayinterno += 1
tamanhos_de_arrays = []
for i in matrix_palavra:
	tamanhos_de_arrays.append(len(i) + 1)
resultado = tamanhos_de_arrays[0]
for i in range(1, len(tamanhos_de_arrays)):
	resultado *= tamanhos_de_arrays[i]
print((resultado - 1) % 1000000007)


m = 10 ** 9 + 7
a = b = 1
for i in input():
	if i == 'b':
		a = a * b % m
		b = 1
	elif i == 'a':
		b += 1
a = a * b % m
print(a - 1)


MOD = 10 ** 9 + 7
S = input().strip()
N = len(S)
groups = [0]
size = 1
for ch in S:
	if ch == 'a':
		groups[size - 1] += 1
	elif ch == 'b':
		groups.append(0)
		size += 1
ans = 1
for ind in range(size - 1, -1, -1):
	ans = ans * (groups[ind] + 1) % MOD
print(ans - 1)


s = input()
n = len(s)
lb = 0
rb = 0
for i in range(0, n):
	if s[i] == 'b':
		lb = lb + rb
		rb = 0
	if s[i] == 'a':
		rb = rb + lb + 1
print((lb + rb) % 1000000007)


n = list(input())
ans = 1
a = []
for i in range(len(n)):
	if n[i] == 'a' or n[i] == 'b':
		a.append(n[i])
count = 0
for j in range(len(a)):
	if a[j] == 'a':
		count += 1
	elif a[j] == 'b':
		ans *= count + 1
		ans = ans % (10 ** 9 + 7)
		count = 0
ans *= count + 1
print((ans - 1) % (10 ** 9 + 7))


(st, count, ans) = (input(), 0, 1)
for char in st:
	if char == 'a':
		count += 1
	elif char == 'b' and count > 0:
		ans *= count + 1
		count = 0
ans = ans * (count + 1) - 1 if count > 0 else ans - 1
print(ans % (10 ** 9 + 7))


s = input()
total = 1
a_count = 0
for c in s:
	if c == 'a':
		a_count += 1
	elif c == 'b' and a_count > 0:
		total *= a_count + 1
		total %= 10 ** 9 + 7
		a_count = 0
if a_count > 0:
	total *= a_count + 1
	total %= 10 ** 9 + 7
total -= 1
total %= 10 ** 9 + 7
print(total)


m = 10 ** 9 + 7
s = input()
r = x = 1
for c in s:
	if c == 'b':
		r = r * x % m
		x = 1
	elif c == 'a':
		x += 1
r = r * x % m
print(r - 1)


S = input()
mod = 10 ** 9 + 7
ANS = 0
YET = 0
OK = 0
for s in S:
	if s == 'a':
		YET += (OK + 1) % mod
		ANS = (ANS + OK + 1) % mod
	elif s == 'b':
		OK = (OK + YET) % mod
		YET = 0
print(ANS)


r = t = 0
s = input()
p = list(s)
for k in s:
	if k == 'b':
		t = r
	if k == 'a':
		r = (r + t + 1) % (10 ** 9 + 7)
print(r)


s = input()
cnt = 1
ans = 1
a = []
for i in range(len(s)):
	if s[i] == 'a':
		cnt += 1
	elif s[i] == 'b':
		ans = cnt * ans
		cnt = 1
print((ans * cnt - 1) % (10 ** 9 + 7))


s = input()
l = [0]
n = len(s)
cur = -1
for i in range(n):
	if s[i] == 'a':
		if cur == -1:
			l[-1] += 1
		else:
			l.append(1)
			cur = -1
	if s[i] == 'b':
		cur = i
m = 1000000007
ans = 1
for i in l:
	ans = ans * (i + 1)
print((ans - 1) % m)


s = input()
ans = 1
count = 0
M = 1000000000.0 + 7
w = ''
for x in s:
	if x == 'a' or x == 'b':
		w = w + x
for x in w:
	if x == 'a':
		count = count + 1
	else:
		ans = ans * (count + 1) % M
		count = 0
ans = ans * (count + 1) % M
print(int(ans - 1))


q = input().split('b')
z = 1
v = 0
for i in range(len(q)):
	if 'a' not in q[i]:
		pass
	else:
		z = z * (q[i].count('a') + 1)
print((z - 1) % (10 ** 9 + 7))


s = input()
n = len(s)
dp = [0] * (n + 1)
last = -1
dp[0] = 0
nax = 10 ** 9 + 7
for i in range(1, n + 1):
	if s[i - 1] == 'b':
		last = i - 1
		dp[i] = dp[i - 1]
	elif s[i - 1] == 'a':
		if last != -1:
			dp[i] = (dp[last] % nax + dp[i - 1] % nax + 1) % nax
		else:
			dp[i] = (dp[i - 1] % nax + 1 % nax) % nax
	else:
		dp[i] = dp[i - 1]
print(dp[n])


import sys
st = sys.stdin.readline().rstrip()
s = 0
li = 0
p = 0
for i in range(0, len(st)):
	if st[i] == 'a':
		s += 1 + p
	elif st[i] == 'b':
		p = s % (10 ** 9 + 7)
print(s % (10 ** 9 + 7))


s = input()
n = len(s)
a = []
curr = 0
for i in range(n):
	if s[i] == 'a':
		curr += 1
	elif s[i] == 'b':
		a.append(curr)
		curr = 0
if curr > 0:
	a.append(curr)
prod = 1
for i in range(len(a)):
	prod *= a[i] + 1
	prod = prod % 1000000007
print(prod - 1)


s = input()
n = len(s)
d = 0
ans = 1
for i in range(n):
	if s[i] == 'a':
		d += 1
	if s[i] == 'b':
		ans *= (d + 1) % 1000000007
		d = 0
ans *= (d + 1) % 1000000007
print((ans - 1) % 1000000007)


s = input()
mod = 1000000000.0 + 7
ans = 1
cnt = 0
for i in range(len(s)):
	if s[i] != 'b':
		if s[i] == 'a':
			cnt += 1
	else:
		if cnt > 0:
			ans = ans * (cnt + 1) % mod
		cnt = 0
if cnt > 0:
	ans = ans * (cnt + 1) % mod
print(int(ans) - 1)


s = input()
k = 1
otvet = 1
for i in s:
	if i == 'a':
		k += 1
	elif i == 'b':
		otvet *= k
		k = 1
print((otvet * k - 1) % (10 ** 9 + 7))


import sys

def main():
	s = sys.stdin.readline()
	count = 0
	mod = 10 ** 9 + 7
	(i, n) = (0, len(s))
	while i < n and s[i] != 'a':
		i += 1
	ans = 1
	while i < n:
		if s[i] == 'a':
			count += 1
		elif s[i] == 'b':
			ans = ans * (1 + count) % mod
			count = 0
		i += 1
	ans = ans * (1 + count) % mod
	print(ans - 1, sep=' ', end='\n', file=sys.stdout, flush=False)
main()


from functools import reduce
s = [len(z) + 1 for z in ''.join((y for y in [x for x in input() if x == 'a' or x == 'b'])).split('b') if len(z) > 0]
print((reduce(lambda x, y: x * y % int(1000000000.0 + 7), s) - 1) % int(1000000000.0 + 7) if len(s) > 0 else 0)


s = input()
m = 10 ** 9 + 7
l = list()
count = 0
for c in s:
	if c == 'a':
		count += 1
	if c == 'b' and count > 0:
		l.append(count)
		count = 0
if count > 0:
	l.append(count)
ans = 1
for i in l:
	ans = ans * (i + 1) % m
print(ans - 1)


import math
s = input()
n = len(s)
mod = 1000000007
ans = 1
cnt = 0
f = 0
for i in range(n):
	if s[i] == 'a':
		cnt = cnt + 1
	if s[i] == 'b':
		ans = ans * (cnt + 1) % mod
		cnt = 0
if cnt:
	ans = ans * (cnt + 1) % mod
print((ans + mod - 1) % mod)


def main():
	mod = 1000000007
	s = input()
	l = len(s)
	a = []
	a.append('*')
	for i in range(l):
		if s[i] == 'a':
			a.append(s[i])
		elif s[i] == 'b' and a[-1] != 'b':
			a.append(s[i])
	last = 0
	p = len(a)
	dp = []
	dp.append(0)
	for i in range(p):
		if a[i] == 'a':
			dp.append(dp[i] + last + 1)
		else:
			dp.append(dp[i])
			last = dp[i]
		dp[i + 1] %= mod
	print(dp[-1])
main()


MODER = 10 ** 9 + 7
s = input()
l = len(s)
tokens = []
cur_token = None
for i in range(l):
	if s[i] == 'a':
		if not cur_token:
			cur_token = [i]
		else:
			cur_token.append(i)
	elif s[i] == 'b':
		if cur_token:
			tokens.append(len(cur_token))
			cur_token = None
if cur_token:
	tokens.append(len(cur_token))
r = 0
for e in tokens:
	r = r * (e + 1) + e
	r %= MODER
print(r)


string = input()
sequence = [1]
for letter in string:
	if letter == 'a':
		sequence[-1] += 1
	elif letter == 'b':
		sequence.append(1)
ans = 1
for elem in sequence:
	ans *= elem
ans -= 1
print(ans % (10 ** 9 + 7))


def p(arr, n):
	ans = 1
	for i in range(0, n):
		ans = ans * (arr[i] + 1)
	return ans - 1
s = input()
a = []
k = 0
for i in s:
	if i == 'a':
		k += 1
	elif i == 'b':
		if k != 0:
			a.append(k)
		k = 0
if k != 0:
	a.append(k)
print(p(a, len(a)) % 1000000007)


string = input()
counter = 0
countera = 0
counterb = 0
for i in string:
	if i == 'a':
		counter += countera + 1
		counter %= 1000000000.0 + 7
	elif i == 'b':
		countera = counter
print(int(counter % (1000000000.0 + 7)))


def decompose(string):
	ans = []
	current_a_count = 0
	for c in string:
		if c == 'a':
			current_a_count += 1
		elif c == 'b':
			if current_a_count > 0:
				ans.append(current_a_count)
			current_a_count = 0
	if current_a_count > 0:
		ans.append(current_a_count)
	return ans

def solve(string):
	problem = decompose(string)
	if len(problem) == 0:
		return 0
	solutions = 0
	for i in problem:
		solutions += i + solutions * i
	return solutions % (10 ** 9 + 7)
string = input()
print(solve(string))


a = b = 0
for c in input():
	if c == 'b':
		b = a
	if c < 'b':
		a = (a + b + 1) % (10 ** 9 + 7)
print(a)


import sys
import os
from io import BytesIO, IOBase

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return defaultdict(int)

def ddl():
	return defaultdict(list)

def ddd():
	return defaultdict(defaultdict(int))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from collections import defaultdict
mod = 10 ** 9 + 7
for _ in range(1):
	s = input()
	s += 'b'
	f = 0
	cnt = 0
	res = 1
	for i in range(len(s)):
		if s[i] == 'a':
			cnt += 1
		if s[i] == 'b':
			res *= 1 + cnt
			res %= mod
			cnt = 0
	print(res - 1)


ch = input().split('b')
mod = 1000000007
m = len(ch) - 1
s = 0
t = 0
while m >= 0:
	if ch[m] != '':
		k = ch[m].count('a')
		if k != 0:
			t = k * (1 + s) % mod
			s = (s + t) % mod
	m -= 1
print(s)


s = input()
x = ''
for i in s:
	if i == 'a' or i == 'b':
		x += i
if len(x) <= 1:
	print(len(x))
else:
	i = 0
	j = 1
	c = 1
	ans = 1
	while i < len(x) and j < len(x):
		if x[i] == x[j]:
			j += 1
			c += 1
		else:
			if x[i] == 'a':
				ans *= c + 1
				ans = ans % 1000000007
			c = 1
			i = j
			j += 1
	if x[i] == 'a':
		ans *= c + 1
	ans = ans % 1000000007
	print(ans - 1)


mod = 1000000007

def md(x):
	return (x % mod + mod) % mod
s = input()
res = 1
cnt = 1
for c in s:
	if c == 'a':
		cnt += 1
	elif c == 'b':
		res = md(res * cnt)
		cnt = 1
res = md(res * cnt)
print(md(res - 1))


s = str(input())
amount = 1
a_c = 1
last = True
for i in s:
	if i == 'a' and last:
		last = False
		a_c = 2
	elif i == 'a':
		a_c += 1
	elif i == 'b':
		last = True
		amount *= a_c
		a_c = 1
if not last:
	amount *= a_c
print((amount - 1) % (10 ** 9 + 7))


s = input()
ans = 1
c = 0
p = 1000000007
for i in s:
	if i == 'a':
		c += 1
	elif i == 'b':
		ans = ans * (c + 1) % p
		c = 0
ans = ans * (c + 1)
ans -= 1
print(ans % p)


s = input()
arr = [0, 0]
M = 1000000007
for ch in s:
	if ch == 'b':
		arr[1] = arr[0]
	elif ch == 'a':
		arr[0] = arr[0] + arr[1] + 1
		if arr[0] >= M:
			arr[0] -= M
print(arr[0])


a = input()
now = 0
total = 1
for r in a:
	if r == 'a':
		now += 1
	elif r == 'b':
		if now > 0:
			total *= now + 1
			now = 0
total *= now + 1
print((total - 1) % 1000000007)


M = 10 ** 9 + 7
s = input()
l = []
i = 0
while i < len(s):
	if s[i] == 'a':
		break
	i += 1
j = len(s) - 1
while j > -1:
	if s[j] == 'a':
		break
	j -= 1
while i <= j:
	if s[i] == 'a':
		l.append(s[i])
	if l[-1] != 'b' and s[i] == 'b':
		l.append('b')
	i += 1
la = []
ca = 0
for i in l:
	if i == 'a':
		ca += 1
	else:
		la.append(ca)
		ca = 0
la.append(ca)
ans = 1
for i in la:
	ans = ans * (1 + i) % M
print(ans - 1)


inp_s = input()
mod = 10 ** 9 + 7
i = 0
l = len(inp_s)
r = 0
while i < l:
	a = 0
	while i < l and inp_s[i] != 'b':
		if inp_s[i] == 'a':
			a += 1
		i += 1
	r = (r + r * a + a) % mod
	i += 1
print(r)


s = input()
partitions = []
a = 0
for c in s:
	if c == 'a':
		a += 1
	if c == 'b' and a > 0:
		partitions.append(a)
		a = 0
if a > 0:
	partitions.append(a)
combinations = 1
for a in partitions:
	combinations = combinations * (a + 1) % 1000000007
combinations = (combinations - 1) % 1000000007
print(combinations)


s = input()
m = 10 ** 9 + 7
a = []
j = 0
for i in range(len(s)):
	if s[i] == 'b':
		a.append(j)
		j = 0
	elif s[i] == 'a':
		j += 1
if j != 0:
	a.append(j)
if len(a) == 0:
	print(0)
	return
ans = a[0]
for i in range(1, len(a)):
	ans = (ans + ans * a[i] + a[i]) % m
print(ans)


b = s = 0
p = 1
M = 10 ** 9 + 7
for x in list(input()):
	if x == 'b':
		b = 1
	elif x == 'a':
		if b == 1:
			p = s + 1
		s += p
		s = s % M
		b = 0
print(s)


mod = 10 ** 9 + 7
s = input()

def getMod(x):
	return (x % mod + mod) % mod
r = 1
count = 1
for i in range(len(s)):
	if s[i] == 'a':
		count += 1
	elif s[i] == 'b':
		r = getMod(r * count)
		count = 1
r = getMod(getMod(r * count) - 1)
print(r)


a = input()
n = len(a)
mod = int(1000000000.0 + 7)
s = 0
ans = 0
bfound = True
for i in range(n - 1, -1, -1):
	if a[i] == 'b':
		bfound = True
	elif a[i] == 'a':
		if bfound:
			bfound = False
			ans += s + 1
			last = s + 1
			s += s + 1
		else:
			s += last
			ans += last
	s %= mod
	ans %= mod
print(ans)


import sys
s = input()
t = ''
for i in s:
	if i == 'a' or i == 'b':
		t += i
posj = []
for i in range(len(t)):
	if t[i] == 'b':
		posj.append(i)
if len(posj) == 0:
	print(len(t))
	sys.exit()
mids = [posj[0] + 1]
mod = 10 ** 9 + 7
sub1 = 0
for i in range(len(posj) - 1):
	mid = posj[i + 1] - posj[i]
	mids.append(mid)
mids.append(len(t) - posj[-1])
tot = 1
for i in mids:
	tot *= i
	tot %= mod
tot -= 1
print(tot % mod)


MOD = 10 ** 9 + 7
l = input()
l = [i for i in l if i == 'a' or i == 'b']
grp = []
n = len(l)
c = 0
for i in range(n):
	if l[i] == 'a':
		c += 1
	else:
		grp.append(c)
		c = 0
if c > 0:
	grp.append(c)
ans = 1
for i in range(len(grp)):
	ans = ans * (grp[i] + 1) % MOD
ans = (ans - 1 + MOD) % MOD
print(ans)


s = input()
L = []
temp = 0
for i in range(0, len(s)):
	if s[i] == 'a':
		temp += 1
	elif s[i] == 'b':
		if temp > 0:
			L.append(temp)
			temp = 0
if temp > 0:
	L.append(temp)
ans = 1
for i in L:
	ans = ans * (i + 1) % 1000000007
print((ans - 1) % 1000000007)


import sys
readline = sys.stdin.readline
mod = 10 ** 9 + 7
L = []
for s in readline().strip():
	if s == 'a':
		L.append(1)
	elif s == 'b' and L and (L[-1] != 0):
		L.append(0)
N = len(L)
dp = [0] * (N + 1)
cnt = 0
for i in range(1, N + 1):
	s = L[i - 1]
	if s:
		dp[i] = (dp[i - 1] + dp[cnt] + 1) % mod
	else:
		dp[i] = dp[i - 1]
		cnt = i
print(0 if not dp else dp[-1] % mod)


check = input()
ans = 0
back = 0
for i in range(len(check) - 1, -1, -1):
	if check[i:i + 1] == 'a':
		ans += (1 + back) % (10 ** 9 + 7)
	elif check[i:i + 1] == 'b':
		back = ans
print(ans % (10 ** 9 + 7))


line = list(input()) + ['b']
a = []
count = 0
for i in line:
	if i == 'b' and count > 0:
		a.append(count)
		count = 0
	if i == 'a':
		count += 1
ans = 1
for i in a:
	ans *= i + 1
	ans %= 1000000007
print(ans - 1)


from sys import stdin, stdout
import cProfile, math
from collections import Counter
from bisect import bisect_left, bisect, bisect_right
import itertools
from copy import deepcopy
from fractions import Fraction
import sys, threading
sys.setrecursionlimit(10 ** 6)
threading.stack_size(2 ** 27)
printHeap = str()
memory_constrained = False
P = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10000000)

class Operation:

	def __init__(self, name, function, function_on_equal, neutral_value=0):
		self.name = name
		self.f = function
		self.f_on_equal = function_on_equal

def add_multiple(x, count):
	return x * count

def min_multiple(x, count):
	return x

def max_multiple(x, count):
	return x
sum_operation = Operation('sum', sum, add_multiple, 0)
min_operation = Operation('min', min, min_multiple, 1000000000.0)
max_operation = Operation('max', max, max_multiple, -1000000000.0)

class SegmentTree:

	def __init__(self, array, operations=[sum_operation, min_operation, max_operation]):
		self.array = array
		if type(operations) != list:
			raise TypeError('operations must be a list')
		self.operations = {}
		for op in operations:
			self.operations[op.name] = op
		self.root = SegmentTreeNode(0, len(array) - 1, self)

	def query(self, start, end, operation_name):
		if self.operations.get(operation_name) == None:
			raise Exception('This operation is not available')
		return self.root._query(start, end, self.operations[operation_name])

	def summary(self):
		return self.root.values

	def update(self, position, value):
		self.root._update(position, value)

	def update_range(self, start, end, value):
		self.root._update_range(start, end, value)

	def __repr__(self):
		return self.root.__repr__()

class SegmentTreeNode:

	def __init__(self, start, end, segment_tree):
		self.range = (start, end)
		self.parent_tree = segment_tree
		self.range_value = None
		self.values = {}
		self.left = None
		self.right = None
		if start == end:
			self._sync()
			return
		self.left = SegmentTreeNode(start, start + (end - start) // 2, segment_tree)
		self.right = SegmentTreeNode(start + (end - start) // 2 + 1, end, segment_tree)
		self._sync()

	def _query(self, start, end, operation):
		if end < self.range[0] or start > self.range[1]:
			return None
		if start <= self.range[0] and self.range[1] <= end:
			return self.values[operation.name]
		self._push()
		left_res = self.left._query(start, end, operation) if self.left else None
		right_res = self.right._query(start, end, operation) if self.right else None
		if left_res is None:
			return right_res
		if right_res is None:
			return left_res
		return operation.f([left_res, right_res])

	def _update(self, position, value):
		if position < self.range[0] or position > self.range[1]:
			return
		if position == self.range[0] and self.range[1] == position:
			self.parent_tree.array[position] = value
			self._sync()
			return
		self._push()
		self.left._update(position, value)
		self.right._update(position, value)
		self._sync()

	def _update_range(self, start, end, value):
		if end < self.range[0] or start > self.range[1]:
			return
		if start <= self.range[0] and self.range[1] <= end:
			self.range_value = value
			self._sync()
			return
		self._push()
		self.left._update_range(start, end, value)
		self.right._update_range(start, end, value)
		self._sync()

	def _sync(self):
		if self.range[0] == self.range[1]:
			for op in self.parent_tree.operations.values():
				current_value = self.parent_tree.array[self.range[0]]
				if self.range_value is not None:
					current_value = self.range_value
				self.values[op.name] = op.f([current_value])
		else:
			for op in self.parent_tree.operations.values():
				result = op.f([self.left.values[op.name], self.right.values[op.name]])
				if self.range_value is not None:
					bound_length = self.range[1] - self.range[0] + 1
					result = op.f_on_equal(self.range_value, bound_length)
				self.values[op.name] = result

	def _push(self):
		if self.range_value is None:
			return
		if self.left:
			self.left.range_value = self.range_value
			self.right.range_value = self.range_value
			self.left._sync()
			self.right._sync()
			self.range_value = None

	def __repr__(self):
		ans = '({}, {}): {}\n'.format(self.range[0], self.range[1], self.values)
		if self.left:
			ans += self.left.__repr__()
		if self.right:
			ans += self.right.__repr__()
		return ans

def display(string_to_print):
	stdout.write(str(string_to_print) + '\n')

def primeFactors(n):
	factors = dict()
	for i in range(2, math.ceil(math.sqrt(n)) + 1):
		while n % i == 0:
			if i in factors:
				factors[i] += 1
			else:
				factors[i] = 1
			n = n // i
	if n > 2:
		factors[n] = 1
	return factors

def isprime(n):
	if n < 4:
		return True
	if n % 2 == 0:
		return False
	if n % 3 == 0:
		return False
	i = 5
	w = 2
	while i * i <= n:
		if n % i == 0:
			return False
		i += w
		w = 6 - w
	return True

def test_print(*args):
	if testingMode:
		print(args)

def display_list(list1, sep=' '):
	stdout.write(sep.join(map(str, list1)) + '\n')

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))
memory = dict()

def clear_cache():
	global memory
	memory = dict()

def cached_fn(fn, *args):
	global memory
	if args in memory:
		return memory[args]
	else:
		result = fn(*args)
		memory[args] = result
		return result
TestCases = False
testingMode = False
optimiseForReccursion = False

def comp(li):
	return len(li)

def main():
	li = list(input())
	xs = []
	c = 0
	for i in li:
		if i == 'b':
			if c > 0:
				xs.append(c)
				c = 0
		if i == 'a':
			c += 1
	if c > 0:
		xs.append(c)
	res = 1
	for i in xs:
		res = res * (1 + i) % P
	print((res - 1) % P)
if TestCases:
	for _ in range(get_int()):
		cProfile.run('main()') if testingMode else main()
else:
	(cProfile.run('main()') if testingMode else main()) if not optimiseForReccursion else threading.Thread(target=main).start()


s = input()
sss = ''
for i in s:
	if i in ['a', 'b']:
		sss += i
from itertools import groupby
xxx = [''.join(g) for (_, g) in groupby(sss)]
xxx = [len(i) + 1 for i in xxx if 'a' in i]
ans = 1
if len(xxx) == 1:
	print((xxx[0] - 1) % 1000000007)
else:
	for i in xxx:
		ans *= i
	print((ans - 1) % 1000000007)


def read(type=1):
	if type:
		file = open('input.dat', 'r')
		s = file.readline()
		file.close()
	else:
		s = input().strip()
	return s

def solve():
	MOD = 1000000007
	sol = 1
	c = []
	for i in range(len(s)):
		if s[i] == 'a':
			if len(c):
				c.append(c[-1] + 1)
			else:
				c.append(1)
		if s[i] == 'b':
			if len(c):
				if c[-1] != 0:
					sol *= c[-1] + 1
					sol %= MOD
					c.append(0)
	if len(c):
		if c[-1]:
			sol *= c[-1] + 1
			sol %= MOD
	sol -= 1
	sol %= MOD
	return sol
s = read(0)
sol = solve()
print(sol)


s = input()
l = []
c = 0
for i in s:
	if i == 'a':
		c += 1
	elif i == 'b':
		if c:
			l.append(c)
			c = 0
if c:
	l.append(c)
md = 10 ** 9 + 7
ans = 0
d = {}

def inverse(a, n):
	if a in d:
		return d[a]
	t = 0
	t1 = 1
	r = n
	r1 = a
	while r1 > 0:
		q = r // r1
		tmp = t - q * t1
		t = t1
		t1 = tmp
		tmp = r - q * r1
		r = r1
		r1 = tmp
	if t < 0:
		t += n
	t = (t + n) % n
	d[a] = t
	return t
mul = 1
for i in l:
	mul *= i + 1
	mul %= md
for i in range(len(l)):
	mul = mul * inverse(l[i] + 1, md) % md
	m = mul * l[i]
	m %= md
	ans += m
	ans %= md
print(ans)


MOD = 1000000007

def MD(x):
	return (x % MOD + MOD) % MOD
s = input()
res = 1
cnt = 1
for c in s:
	if c == 'a':
		cnt += 1
	elif c == 'b':
		res = MD(res * cnt)
		cnt = 1
res = MD(res * cnt)
print(MD(res - 1))


m = 10 ** 9 + 7
x = 1
y = 0
for c in input():
	z = (x + y) % m
	if c == 'a':
		y = z
	elif c == 'b':
		x = z
		y = 0
print((x + y + m - 1) % m)


mod = 1000000007

def treat(num):
	return (num % mod + mod) % mod
seq = input()
cont = 1
saida = 1
for i in seq:
	if i == 'a':
		cont += 1
	elif i == 'b':
		saida = treat(saida * cont)
		cont = 1
saida = treat(saida * cont)
print(treat(saida - 1))


import sys
s = input()
i = 0
n = len(s)
count = 0
p = 1
for i in range(len(s)):
	if s[i] == 'a':
		count += 1
	if s[i] == 'b':
		p = p * (count + 1) % 1000000007
		count = 0
p = p * (count + 1) % 1000000007
sys.stdout.write(str(p - 1) + '\n')


import sys, math
s = [x for x in input()]
string = []
last = ''
for i in range(len(s)):
	if s[i] == 'a' or s[i] == 'b':
		if last != s[i]:
			last = s[i]
			string.append([s[i], 0])
		string[-1][-1] += 1
res = [0]
summa = 0
for i in range(len(string)):
	if string[i][0] == 'a':
		res.append(string[i][1])
		res[-1] += string[i][1] * res[-2]
		res[-1] += res[-2]
		summa += res[-1]
if len(res) == 0:
	print(0)
else:
	print(res[-1] % (1000000000 + 7))


mod = 1000000007

def modulo(a):
	resp = a % mod
	if resp < 0:
		return resp + mod
	return resp
s = input()
resp = 1
c = 1
for l in s:
	if l == 'a':
		c += 1
	elif l == 'b':
		resp = modulo(resp * c)
		c = 1
resp = modulo(resp * c - 1)
print(resp)


import math
import sys

def main():
	s = input()
	a = s.split('b')
	cnt = []
	for i in a:
		sum_ = 0
		for j in i:
			sum_ += j == 'a'
		if sum_ > 0:
			cnt.append(sum_)
	if len(cnt) == 0:
		print(0)
	else:
		ans = 1
		mod = int(1000000000.0 + 7)
		for i in cnt:
			ans *= i + 1
			ans %= mod
		print(ans - 1)
main()


s = list(input())
a = [0]
ans = 1
for i in s:
	if i == 'a':
		a[-1] += 1
	elif i == 'b' and a[-1] != 0:
		a.append(0)
for i in a:
	ans *= i + 1
	ans %= 1000000007
print(ans - 1)


s = [c for c in input() if c in {'a', 'b'}]
(i, res, n) = (0, 1, len(s))
while i < n:
	j = 0
	while i < n and s[i] == 'a':
		j += 1
		i += 1
	res = res * (j + 1) % int(1000000000.0 + 7)
	while i < n and s[i] == 'b':
		i += 1
print((res - 1) % int(1000000000.0 + 7))


string = list(input())
arr = []
current = 0
for let in string:
	if let == 'a':
		current += 1
	if let == 'b':
		arr += [current]
		current = 0
arr += [current]
arr = [num + 1 for num in arr]

def prod(arr, mod):
	ans = 1
	for num in arr:
		ans = ans * num % mod
	return ans
print(prod(arr, 10 ** 9 + 7) - 1)


s = list(input())
ar = []
x = 0
for i in s:
	if i == 'b':
		if x > 0:
			ar += [x]
			x = 0
	if i == 'a':
		x += 1
if x > 0:
	ar += [x]
cur = 1
res = 0
for i in ar:
	cur *= i + 1
	cur %= 10 ** 9 + 7
print(cur - 1)


s = input()
n = len(s)
arr = []
start = 0
end = 0
for i in range(n):
	if s[i] != 'b':
		end = i
	else:
		if start <= end:
			arr.append(s[start:end + 1])
		start = i + 1
		end = i
if start <= end:
	arr.append(s[start:end + 1])
t = 0
counts = [x.count('a') for x in arr]
if len(arr) == 0:
	print(0)
else:
	m = len(arr)
	for i in range(m):
		t = ((t + counts[i]) % 1000000007 + t * counts[i] % 1000000007) % 1000000007
	print(t)


s = input()
ans = 1
preans = 0
for i in range(len(s)):
	if s[i] not in ['a', 'b']:
		continue
	if s[i] == 'a':
		preans += 1
	else:
		if preans > 0:
			ans = ans * (preans + 1) % (10 ** 9 + 7)
		preans = 0
if preans > 0:
	ans = ans * (preans + 1) % (10 ** 9 + 7)
print((ans - 1) % (10 ** 9 + 7))


import sys
input = sys.stdin.readline
rs = input()
s = ''
flag = False
for x in rs:
	if x == 'b':
		if not flag:
			flag = True
			s += x
	elif x == 'a':
		s += x
		flag = False
cnt = 0
ans = 1
mod = int(10 ** 9) + 7
for x in s:
	if x == 'a':
		cnt += 1
	elif x == 'b':
		ans = ans * (cnt + 1) % mod
		cnt = 0
if cnt > 0:
	ans = ans * (cnt + 1) % mod
ans = (ans - 1 + mod) % mod
print(ans)


s = input()
p = 0
a = []
for i in range(len(s)):
	if s[i] == 'a':
		p += 1
	if s[i] == 'b':
		a.append(p)
		p = 0
	if i == len(s) - 1 and s[i] != 'b':
		a.append(p)
	i += 1
z = 1
for i in range(len(a)):
	z *= a[i] + 1
print((z - 1) % (10 ** 9 + 7))


from sys import stdin, stdout
import math
s = input()
res = 0
idx = -1
for i in range(len(s)):
	if s[i] == 'a':
		res = 1
		idx = i
		break
if idx == -1:
	print(0)
	quit()
stack = [1]
cur = 0
for i in range(idx + 1, len(s)):
	if s[i] == 'b':
		cur = stack[-1]
	if s[i] == 'a':
		res += 1 + cur
		res = res % 1000000007
		stack.append(res)
print(res)


import heapq, math
from collections import defaultdict, deque
import sys, os.path
if os.path.exists('C:/Users/Dhanush/Desktop/cp/input.txt'):
	sys.stdout = open('C:/Users/Dhanush/Desktop/cp/output.txt', 'w')
	sys.stdin = open('C:/Users/Dhanush/Desktop/cp/input.txt', 'r')
input = sys.stdin.readline
mod = 10 ** 9 + 7
s = input().strip()
n = len(s)
ns = []
for i in range(n):
	if s[i] == 'a' or s[i] == 'b':
		ns.append(s[i])
s = ''.join(ns)
n = len(ns)
i = 0
l = []
while i < n:
	while i < n and s[i] == 'b':
		i += 1
	cnt = 0
	while i < n and s[i] == 'a':
		i += 1
		cnt += 1
	if cnt > 0:
		l.append(cnt)
if len(l) == 0:
	print(0)
else:
	ans = l[0] + 1
	for i in range(1, len(l)):
		ans = ans * (l[i] + 1) % mod
	print(ans - 1)


import sys
input = sys.stdin.readline
from collections import *
from bisect import *

class BIT:

	def __init__(self, n):
		self.n = n
		self.bit = [0] * (n + 1)

	def add(self, i, x):
		i += 1
		while i <= self.n:
			self.bit[i] += x
			self.bit[i] %= MOD
			i += i & -i

	def acc(self, i):
		i += 1
		s = 0
		while i > 0:
			s += self.bit[i]
			s %= MOD
			i -= i & -i
		return s
s = input()[:-1]
n = len(s)
b = []
for i in range(n):
	if s[i] == 'b':
		b.append(i)
bit = BIT(n)
MOD = 10 ** 9 + 7
for i in range(n):
	if s[i] == 'a':
		idx = bisect_left(b, i) - 1
		if idx == -1:
			bit.add(i, 1)
		else:
			bit.add(i, 1 + bit.acc(b[idx] - 1))
print(bit.acc(n - 1) % MOD)


mod = int(1000000000.0) + 7
s = input()
n = len(s)
ans = 1
kol = 0
tmp = 0
for c in s:
	if c == 'b':
		ans *= kol + 1
		ans = ans % mod
		kol = 0
	if c == 'a':
		kol += 1
		tmp += 1
print((ans * (kol + 1) - 1) % mod)


mod = 1000000007
entrada = input()
res = 1
cnt = 1
resultado = 0

def defMod(x):
	return (x % mod + mod) % mod
for i in entrada:
	if i == 'a':
		cnt += 1
	elif i == 'b':
		res = defMod(res * cnt)
		cnt = 1
res = defMod(res * cnt)
resultado = defMod(res - 1)
print(resultado)


s = input()
t = ''
for i in range(len(s)):
	if s[i] == 'a' or s[i] == 'b':
		t += s[i]
boo = False
t += 'b'
ans = 1
cur = 0
for i in range(len(t)):
	if boo:
		if t[i] == 'a':
			cur += 1
		else:
			ans *= cur
			ans %= 1000000007
			boo = False
	elif t[i] == 'a':
		cur = 2
		boo = True
print((ans - 1) % 1000000007)


s = str(input())
mod = 10 ** 9 + 7
cnt = 0
X = []
for c in s:
	if c == 'a':
		cnt += 1
	elif c == 'b':
		X.append(cnt)
		cnt = 0
else:
	X.append(cnt)
ans = 1
for x in X:
	ans *= x + 1
	ans %= mod
ans -= 1
print(ans % mod)


s = input()
MOD = int(1000000000.0 + 7)
cnt = 1
a = list()
for i in range(len(s)):
	if s[i] != 'a' and s[i] != 'b':
		continue
	if s[i] == 'a':
		cnt += 1
	else:
		a.append(cnt)
		cnt = 1
a.append(cnt)
ans = 1
for i in a:
	ans *= i
	ans %= MOD
ans -= 1
ans += MOD
ans %= MOD
print(ans)


import sys
s = [str(val) for val in input().split()][0]
singles = 0
for i in s:
	if i == 'a':
		singles += 1
count = 0
groups = []
for i in s:
	if i == 'a':
		count += 1
	if i == 'b' and count != 0:
		groups.append(count)
		count = 0
if count != 0:
	groups.append(count)
modval = int(1000000000.0 + 7)
tots = 1
for i in groups:
	tots = tots % modval * ((i + 1) % modval) % modval
print(tots - 1)


from functools import reduce
from operator import mul
MOD = 10 ** 9 + 7
A = input()
nums = []
current = 0
for x in A:
	if x == 'a':
		current += 1
	elif x == 'b' and current != 0:
		nums += [current + 1]
		current = 0
if current != 0:
	nums += [current + 1]
if len(nums) == 0:
	print(0)
else:
	print(reduce(lambda x, y: x * y % MOD, nums) - 1)


import sys
MOD = 1000000007

def solve(io):
	S = [c for c in io.read_line() if c == 'a' or c == 'b']
	clust = []
	consec = 0
	for c in S:
		if c == 'a':
			consec += 1
		else:
			clust.append(consec)
			consec = 0
	clust.append(consec)
	clust = [f for f in clust if f > 0]
	cnt = 0
	for f in clust:
		cnt = (cnt + cnt * f + f) % MOD
	io.println(cnt)

class IO:
	in_stream = None
	out_stream = None
	raw = ''
	buf = []
	pos = 0

	def __init__(self, input_stream, output_stream):
		self.in_stream = input_stream
		self.out_stream = output_stream

	def read_to_buffer(self):
		self.raw = self.in_stream.readline().rstrip('\n')
		self.buf = self.raw.split()
		self.pos = 0

	def read_string(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		ans = self.buf[self.pos]
		self.pos += 1
		return ans

	def read_int(self):
		return int(self.read_string())

	def read_float(self):
		return float(self.read_string())

	def read_string_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_string())
		return arr

	def read_int_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_int())
		return arr

	def read_float_array(self, N, offset=0):
		arr = [None] * offset
		for _ in range(0, N):
			arr.append(self.read_float())
		return arr

	def read_line(self):
		while self.pos == len(self.buf):
			self.read_to_buffer()
		if self.pos > 0:
			raise ValueError('Cannot call read_line in the middle of a line.')
		self.pos = len(self.buf)
		return self.raw

	def print(self, s):
		self.out_stream.write(str(s))

	def println(self, s):
		self.print(s)
		self.print('\n')

	def println_array(self, arr, sep=' '):
		self.println(sep.join((str(x) for x in arr)))

	def flush_output(self):
		self.out_stream.flush()
pythonIO = IO(sys.stdin, sys.stdout)
solve(pythonIO)
pythonIO.flush_output()


palavra = input()
aux = 1
seq = []
palavra += 'b'
for i in range(len(palavra)):
	if palavra[i] == 'a':
		aux += 1
	if palavra[i] == 'b' and aux > 0:
		seq.append(aux)
		aux = 1
num_de_seq = 1
for i in seq:
	num_de_seq = num_de_seq * i
	num_de_seq = num_de_seq % 1000000007
print((num_de_seq - 1) % 1000000007)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
from collections import deque
s = input()
l = [0]
for i in range(len(s)):
	if s[i] == 'a':
		l[-1] += 1
	elif s[i] == 'b':
		if l[-1] != 0:
			l.append(0)
if l[-1] == 0:
	l.pop()
if len(l) == 0:
	print(0)
else:
	count = 1
	mod = pow(10, 9) + 7
	for i in l:
		count = count * ((1 + i) % mod) % mod
	count -= 1
	print(count % mod)


s = input()
k = 0
cl = []
res = 1
for x in s:
	if x == 'a':
		k += 1
	if x == 'b' and k != 0:
		res = (k + 1) * res
		k = 0
if k != 0:
	res = res * (k + 1)
print((res - 1) % (10 ** 9 + 7))


mod = 1000000007

def MD(x):
	return (x % mod + mod) % mod
s = input()
res = 1
cnt = 1
for e in s:
	if e == 'a':
		cnt += 1
	elif e == 'b':
		res = MD(res * cnt)
		cnt = 1
res = MD(res * cnt)
print(MD(res - 1))


mod = 10 ** 9 + 7
a = input()
c = 0
ans = 1
w = False
for i in range(len(a)):
	if a[i] == 'a':
		w = True
		c += 1
	elif a[i] == 'b' and w:
		ans = ans * (c + 1) % mod
		w = False
		c = 0
if c != 0:
	ans = ans * (c + 1) % mod
if ans == 0:
	print(1000000006)
else:
	print(ans - 1)


import re
s = input()
mod = 10 ** 9 + 7
s = re.sub('[^a-b]', '', s)
s = re.sub('b+', 'b', s)
s = re.sub('^b', '', s)
s = re.sub('b$', '', s)
s = s.split('b')
if s[0] != '':
	ans = 1
	for i in range(len(s)):
		ans = ans * (len(s[i]) + 1) % mod
	print(ans - 1)
else:
	print(0)


s = input()
MOD_N = 1 * 10 ** 9 + 7
result = 0

def add(a, b):
	global result
	global MOD_N
	result += result * a * 1 + a
	result %= MOD_N
c_pos = 0
while c_pos < len(s) and s[c_pos] != 'a':
	c_pos += 1
while c_pos < len(s):
	if s[c_pos] == 'b':
		break
	elif s[c_pos] == 'a':
		result += 1
	c_pos += 1
if c_pos == len(s):
	print('{}'.format(result))
	exit(0)
last = 'b'
last_b = 1
last_a = 0
s_a = []
s_b = []
c_pos += 1
while c_pos < len(s):
	c = s[c_pos]
	if c not in 'ab':
		c_pos += 1
		continue
	if c == last == 'a':
		last_a += 1
	elif c == last == 'b':
		last_b += 1
	elif c == 'a':
		last_a = 1
		last = 'a'
	else:
		add(last_a, last_b)
		last_a = 0
		last_b = 1
		last = 'b'
	c_pos += 1
add(last_a, last_b)
print('{}'.format(result))


s = input()
MOD = 10 ** 9 + 7
saa = 1
na = 0
ans = 0
for c in s:
	if c == 'a':
		ans += saa
		ans %= MOD
		na += 1
	if c == 'b':
		saa = saa + saa * na
		saa %= MOD
		na = 0
print(ans)


s = input()
last_b = 0
poss = 0
for c in s:
	if c == 'a':
		poss += last_b + 1
		poss %= 10 ** 9 + 7
	elif c == 'b':
		last_b = poss
print(poss)


s = input()
ans = 0
pb = []
f = 0
cb = 0
mod = 10 ** 9 + 7
cc = 1
for i in s:
	if i == 'a':
		cb += 1
		ans = (ans + cc) % mod
	if i == 'b':
		cc = (cc + cc * cb) % mod
		cb = 0
print(ans)


s = input()
prev = -1
a = 1
pa = 0
ans = 1
for i in range(len(s)):
	if s[i] == 'b':
		ans *= a
		a = 1
	elif s[i] == 'a':
		a += 1
if a != 0:
	ans *= a
print((ans - 1) % (10 ** 9 + 7))


s = input()
lis = []
for i in range(len(s)):
	if s[i] == 'a':
		lis.append(1)
	elif s[i] == 'b':
		lis.append(-1)
r = []
c = 0
for i in range(len(lis)):
	if lis[i] < 0:
		r.append(c + 1)
		c = 0
	else:
		c += 1
r.append(c + 1)
m = 7 + 10 ** 9
p = 1
for i in r:
	p = p * i % m
print(p - 1)


s = input()
r = a = 1
for i in s:
	if i == 'a':
		a += 1
	if i == 'b':
		r *= a
		a = 1
r *= a
print((r - 1) % 1000000007)


s1 = input()
s = ''
for el in s1:
	if el == 'b':
		if len(s) > 0 and s[-1] != 'b':
			s += el
	elif el == 'a':
		s += el
s += 'b'
arr = []
block = 0
for i in range(len(s)):
	if s[i] == 'a':
		block += 1
	if s[i] == 'b':
		if block > 0:
			arr.append(block)
			block = 0
ans = 1
for el in arr:
	ans *= el + 1
print((ans - 1) % (1000000000 + 7))


s = input()
s += 'b'
(res, cnt) = (1, 0)
MOD = int(1000000000.0 + 7)
for c in s:
	if c != 'a' and c != 'b':
		continue
	elif c == 'a':
		cnt = cnt + 1
	else:
		res = res * (cnt + 1) % MOD
		cnt = 0
print(res - 1)


s = input()
n = len(s)
m = 1
i = 0
while i < n:
	if s[i] == 'a':
		cnt = 1
		j = i + 1
		while j < n:
			if s[i] == s[j]:
				cnt += 1
			elif s[j] == 'b':
				break
			j += 1
		m = m * (cnt + 1) % 1000000007
		i = j
	else:
		i += 1
m = (m - 1) % 1000000007
print(m)


string = input()
combinations = []
count = 0
for char in string:
	if char == 'b':
		combinations.append(count)
		count = 0
	elif char == 'a':
		count += 1
combinations.append(count)
answer = 1
for counts in combinations:
	answer *= 1 + counts
answer -= 1
print(answer % (10 ** 9 + 7))


s = input()
ans = 0
t = 0
for x in s:
	if x == 'a':
		ans += t + 1
	if x == 'b':
		t = ans
print(ans % 1000000007)


import sys
(mod, MOD) = (1000000007, 998244353)
from math import ceil, floor, log, sqrt, factorial, pow, pi, gcd

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
string = 'z' + input()
if 'a' not in string:
	print(0)
	exit()
n = len(string)
curr = 0
mylist = []
for i in range(1, n):
	if string[i] == 'a':
		curr += 1
	elif string[i] == 'b':
		if curr > 0:
			mylist.append(curr)
			curr = 0
if curr > 0:
	mylist.append(curr)
	curr = 0
ans = 1
for i in mylist:
	ans = ans * (i + 1)
	ans %= mod
print(ans - 1)


mod = 10 ** 9 + 7
s = input()
occurs = [0]
for i in range(len(s)):
	if s[i] == 'a':
		occurs[-1] += 1
	elif s[i] == 'b' and occurs[-1] != 0:
		occurs.append(0)
res = 0
for n in occurs:
	res += (n + res * n) % mod
	res %= mod
print(res)


import sys
input = sys.stdin.readline
mod = 10 ** 9 + 7
s = [i for i in input().strip() if i == 'a' or i == 'b']
n = len(s)
dp = [0 for i in range(n)]
num_a = [0 for i in range(n)]
con_a = [0 for i in range(n)]
cnt = 0
if n == 0:
	print(0)
else:
	if s[0] == 'a':
		num_a[0] = 1
		cnt = 1
		dp[0] = 1
	for i in range(1, n):
		if s[i] == 'a':
			num_a[i] = num_a[i - 1] + 1
			con_a[i] = cnt
			cnt += 1
		else:
			num_a[i] = num_a[i - 1]
			con_a[i] = cnt
			cnt = 0
	val = 1
	has = False
	for i in range(1, n):
		if s[i] == 'a':
			dp[i] = (dp[i - 1] + val) % mod
		else:
			has = True
			dp[i] = dp[i - 1]
			val = val * (con_a[i] + 1) % mod
	print(dp[n - 1] % mod)


s = ''.join((c for c in input() if c in 'ab'))
(d, ans) = (s.split('b'), 1)
for i in d:
	ans = ans * (len(i) + 1) % (10 ** 9 + 7)
print((ans - 1) % (10 ** 9 + 7))


from sys import stdin, stdout
from math import *
from heapq import *
from collections import *

def main():
	s = stdin.readline().replace('\n', '')
	n = len(s)
	nb = 1
	res = 1
	mod = 10 ** 9 + 7
	for c in s:
		if c == 'a':
			res = (res + nb) % mod
		if c == 'b':
			nb = res
	stdout.write(str((res + mod - 1) % mod))
	return 0
main()


def _1084C():
	s = input()
	res = []
	count = 0
	for i in s:
		if i == 'b':
			res.append(count)
			count = 0
		elif i == 'a':
			count += 1
	res.append(count)
	ans = 1
	for i in res:
		if i:
			ans *= i + 1
	print((ans - 1) % 1000000007)
_1084C()


from sys import maxsize, stdout, stdin, stderr
mod = int(1000000000.0 + 7)
import sys

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
from collections import defaultdict, Counter, deque
import math
import heapq
from heapq import heappop, heappush
import bisect
from itertools import groupby

def gcd(a, b):
	while b:
		a %= b
		tmp = a
		a = b
		b = tmp
	return a

def lcm(a, b):
	return a // gcd(a, b) * b

def check_prime(n):
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def Bs(a, x):
	i = 0
	j = 0
	left = 1
	right = x
	flag = False
	while left < right:
		mi = (left + right) // 2
		if a[mi] <= x:
			left = mi + 1
			i += 1
		else:
			right = mi
			j += 1
	if left > 0 and a[left - 1] == x:
		return (i - 1, j)
	else:
		return (-1, -1)

def nCr(n, r):
	return fact(n) // (fact(r) * fact(n - r))

def fact(n):
	res = 1
	for i in range(2, n + 1):
		res = res * i
	return res

def primefactors(n):
	num = 0
	while n % 2 == 0:
		num += 1
		n = n / 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			num += 1
			n = n // i
	if n > 2:
		num += 1
	return num

def ask(a):
	print('? {}'.format(a), flush=True)
	n = I()
	return n

def dfs(i, p):
	(a, tmp) = (0, 0)
	for j in d[i]:
		if j != p:
			a += 1
			tmp += dfs(j, i)
	if a == 0:
		return 0
	return tmp / a + 1

def primeFactors(n):
	l = []
	while n % 2 == 0:
		l.append(2)
		n = n // 2
	if n > 2:
		l.append(n)
	return l
s = S()
d = Counter(s)
tmp = 1
dp = []
(cnt, tota, ans, a) = (0, 0, 0, 0)
for i in range(len(s)):
	if s[i] == 'a':
		a += 1
	elif s[i] == 'b':
		if a > 0:
			tmp = tmp * (a + 1) % mod
		a = 0
if a > 0:
	tmp = tmp * (a + 1) % mod
print(tmp - 1)


from sys import stdin
s = stdin.readline().strip()
acum = [0 for i in range(len(s) + 1)]
dp = [0 for i in range(len(s))]
last_b = 0
mod = 1000000007
for i in range(len(s)):
	if s[i] == 'a':
		dp[i] = (1 + acum[last_b]) % mod
	elif s[i] == 'b':
		last_b = i
	acum[i + 1] = (acum[i] + dp[i]) % mod
print(acum[-1])


MODULO = 1000000007
s = input()
t = ''
bEncouter = False
aCounter = 0
bCounter = 0
for c in s:
	if c == 'a':
		t += 'a'
		bEncouter = False
		aCounter += 1
	elif c == 'b':
		if not bEncouter:
			t += 'b'
			bEncouter = True
			bCounter += 1
if aCounter > 0 and bCounter > 0:
	if t[0] == 'b':
		t = t[1:]
	if t[-1] == 'b':
		t = t[:-1]
	aEnd = [0] * len(t)
	bEnd = [0] * len(t)
	sumUntilLastB = 0
	lastB = 0
	for c in range(len(t)):
		if t[c] == 'a':
			aEnd[c] = (sumUntilLastB + 1) % MODULO
		elif t[c] == 'b':
			sumUntilLastB = (sumUntilLastB + sum(aEnd[lastB:c])) % MODULO
			lastB = c
	print(sum(aEnd) % MODULO)
else:
	print(aCounter)


mod = 10 ** 9 + 7
s = list(input())
for i in range(len(s)):
	if s[i] is not 'a' and s[i] is not 'b':
		s[i] = ''
s = ''.join(s)
l = s.split('b')
(ans, k) = (1, 1)
for i in l:
	if i != '':
		k = len(i) + 1
		ans *= k
		ans %= mod
print(ans - 1)


from sys import stdin, stdout
import re
s = stdin.readline().strip()
arr = []
marker = 0
ns = re.sub('[^ab]', '', s)

def solve(s):
	ans = 1
	tctr = 0
	for i in s:
		if i == 'a':
			tctr += 1
		else:
			if tctr != 0:
				ans = ans * (tctr + 1) % (10 ** 9 + 7)
			tctr = 0
	if tctr != 0:
		ans = ans * (tctr + 1) % (10 ** 9 + 7)
	return ans - 1
finalans = solve(ns)
stdout.write(str(finalans))


import sys
from math import ceil, floor
RI = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
mod = 10 ** 9 + 7
st = ri()
a = []
cnt = 0
for i in st:
	if i == 'a':
		cnt += 1
	if i == 'b':
		if cnt != 0:
			a.append(cnt)
			cnt = 0
if cnt != 0:
	a.append(cnt)
if len(a) == 0:
	print(0)
	exit()
dp = [0] * len(a)
dp[0] = a[0]
ans = a[0]
summ = [0] * len(a)
summ[0] = a[0]
for i in range(1, len(a)):
	dp[i] = (dp[i - 1] * a[i] % mod + a[i]) % mod
	if i >= 2:
		dp[i] = (dp[i] + summ[i - 2] * a[i] % mod) % mod
	summ[i] = summ[i - 1] + dp[i]
	ans = (ans + dp[i]) % mod
print(ans)


mod = int(1000000000.0) + 7

def md(x):
	return (x % mod + mod) % mod
s = input()
x = 1
a = 1
for i in range(len(s)):
	if s[i] == 'a':
		a += 1
	elif s[i] == 'b':
		x = md(x * a)
		a = 1
x = md(x * a)
print(md(x - 1))


s = input() + 'b'
counter = 0
tot = 1
for item in s:
	if item == 'a':
		counter += 1
	elif item == 'b':
		if counter > 0:
			tot *= counter + 1
			counter = 0
print((tot - 1) % (10 ** 9 + 7))


from os import path
from io import BytesIO, IOBase
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, Counter, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('0')
file = 1

def ceil(a, b):
	return (a + b - 1) // b

def solve():
	N = 10001
	invfact = [0] * N
	fact = [1] * N
	for i in range(1, N):
		fact[i] = fact[i - 1] * i % mod
	invfact[-1] = pow(fact[-1], mod - 2, mod)
	for i in range(N - 2, -1, -1):
		invfact[i] = (i + 1) * invfact[i + 1] % mod

	def nCr(x, y):
		if y > x:
			return 0
		ans = invfact[x - y] * invfact[y] % mod
		ans *= fact[x]
		ans %= mod
		return ans
	ans = 0
	s = si()
	n = len(s)
	dp = [[0, 0] for i in range(n)]
	for i in range(n):
		if i > 0:
			dp[i][0] = dp[i - 1][0]
			dp[i][1] = dp[i - 1][1]
		if s[i] != 'a' and s[i] != 'b':
			continue
		if s[i] == 'a':
			dp[i][0] += dp[i][1]
			dp[i][0] %= mod
			dp[i][0] += 1
			dp[i][0] %= mod
			ans += dp[i][1]
			ans %= mod
			ans += 1
			ans %= mod
		if s[i] == 'b':
			dp[i][1] = dp[i][0]
	print(ans)
if file:
	if path.exists('tmp/input.txt'):
		sys.stdin = open('tmp/input.txt', 'r')
		sys.stdout = open('tmp/output.txt', 'w')
	else:
		input = sys.stdin.readline
solve()


s = input()
char = 'qwertyuiopsdfghjklzxcvnmñ'
for i in range(len(char)):
	s = s.replace(char[i], '')
count = 0
total = []
sol = 1
for i in range(len(s)):
	if s[i] == 'a':
		count += 1
	if s[i] == 'b' or i == len(s) - 1:
		total += [count]
		count = 0
for i in total:
	sol = sol * (i + 1)
print((sol - 1) % 1000000007)


import re
s = input()
s = re.sub('[^a-b]', '', s)
s = re.sub('b+', 'b', s)
next_b = [len(s) - 1 for _ in range(len(s))]
last_b_index = -1
i = len(s) - 1
while i >= 0:
	if last_b_index != -1:
		next_b[i] = last_b_index
	if s[i] == 'b':
		last_b_index = i
	i -= 1
dp = [-1 for _ in range(len(s) + 1)]
dp[len(s)] = 0
i = len(s) - 1
while i >= 0:
	dp[i] = dp[i + 1]
	if s[i] == 'a':
		dp[i] += 1 + dp[next_b[i] + 1]
		dp[i] %= 1000000007
	i -= 1
print(dp[0])


text = input()
(n, MOD) = (len(text), 10 ** 9 + 7)
(arr, cur) = ([], 0)
for l in text:
	if l == 'a':
		cur += 1
	elif l == 'b':
		if cur > 0:
			arr.append(cur)
		cur = 0
if cur > 0:
	arr.append(cur)
ans = 1
for v in arr:
	ans *= v + 1
	ans %= MOD
print(ans - 1)


(qc, c, res) = (1, 1, 0)
for x in input():
	if x == 'b':
		(qc, c) = (qc * c, 1)
	elif x == 'a':
		c += 1
		res = (res + qc) % (10 ** 9 + 7)
print(res)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
m = 10 ** 9 + 7
x = 1
y = 0
for c in input():
	z = (x + y) % m
	if c == 'a':
		y = z
	elif c == 'b':
		x = z
		y = 0
print((x + y + m - 1) % m)


inp = list(input())
lis = []
new_inp = []
for i in range(len(inp)):
	if inp[i] == 'a' or inp[i] == 'b':
		new_inp.append(inp[i])
i = 0
mul = []
while i < len(new_inp):
	if new_inp[i] == 'a':
		j = i
		while j < len(new_inp) and new_inp[j] == 'a':
			j += 1
		mul.append(j - i)
		i = j + 1
	else:
		i += 1
ans = 1
for k in mul:
	ans = ans * (k + 1)
ans -= 1
ans = ans % 1000000007
print(ans)


import sys
from os.path import isfile
(fin, fout) = (open('c.in'), open('c.out', 'w')) if isfile('c.in') else (sys.stdin, sys.stdout)

def ris():
	return map(int, fin.readline().split())

def ri():
	return int(fin.readline())
s = fin.readline().strip()
from collections import namedtuple
res = 0
cur = 0
old = 0
for c in s:
	if c != 'b' and c != 'a':
		continue
	if c == 'b':
		res += cur
		old = res
		cur = 0
	else:
		res += old
		cur += 1
res += cur
fout.write('%d\n' % (res % (10 ** 9 + 7)))
(fin.close(), fout.close())


import bisect
s = input()
s1 = ''
ans = 1
div = int(1000000000.0 + 7)
for l in s:
	if l == 'a' or l == 'b':
		s1 += l
li = s1.split('b')
for b in li:
	if len(b):
		ans *= len(b) + 1
		ans %= div
print(ans - 1)


u1 = list(input())
n = len(u1)
q = 10 ** 9 + 7
u2 = []
ok = False
for i in range(n):
	if u1[i] == 'a' or u1[i] == 'b':
		u2.append(u1[i])
		if u1[i] == 'a':
			ok = True
	else:
		n -= 1
if not ok:
	print(0)
	exit()
u = [u2[0]]
for i in range(1, n):
	if u2[i] == 'a' or u2[i - 1] == 'a':
		u.append(u2[i])
	else:
		n -= 1
if u[0] == 'b':
	u.pop(0)
	n -= 1
if u[-1] != 'b':
	u.append('b')
	n += 1
x = []
k = 0
for i in range(n):
	if u[i] == 'a':
		k += 1
	else:
		x.append(k + 1)
		k = 0
ans = 1
for i in range(len(x)):
	ans *= x[i]
	ans %= q
print(ans - 1)


s = input()
mo = int(1000000000.0 + 7)
import re
s = re.sub('b+', 'b', s)
if s[0] == 'b':
	s = s[1:]
if s[-1] == 'b':
	s = s[:-1]
m = list(filter(lambda x: x is 'b' or x is 'a', s))
s = ''.join(m).split('b')
m = [len(i) for i in s]
sol = [0] * (len(m) + 1)
for i in range(1, len(sol)):
	sol[i] = ((m[i - 1] % mo + sol[i - 1] * m[i - 1] % mo) % mo + sol[i - 1] % mo) % mo
print(sol[len(m)] % mo)


string = list(input())
n = len(string)
asubsets = []
a = 0
b = 1
for i in range(n):
	if string[i] == 'a':
		a = a + 1
	if string[i] == 'b':
		asubsets.append(a)
		a = 0
asubsets.append(a)
increase = [i + 1 for i in asubsets]
total = 1
for i in increase:
	total = total * i
finaltotal = (total - 1) % (pow(10, 9) + 7)
print(finaltotal)