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 10^9 + 7.

The string "ab" appears as a substring if there is a letter 'b' right after the letter 'a' somewhere in the string.


-----Input-----

The first line contains the initial string consisting of letters 'a' and 'b' only with length from 1 to 10^6.


-----Output-----

Print the minimum number of steps modulo 10^9 + 7.


-----Examples-----
Input
ab

Output
1

Input
aab

Output
3



-----Note-----

The first example: "ab"  →  "bba".

The second example: "aab"  →  "abba"  →  "bbaba"  →  "bbbbaa".

Difficulty: MEDIUM

Solutions:
s = input()
mod = 10 ** 9 + 7
b = 0
res = 0
for c in s[::-1]:
	if c == 'b':
		b += 1
	else:
		res += b
		b *= 2
		res %= mod
		b %= mod
print(res)


MOD = 1000000000.0 + 7
s = input()
ans = 0
b = 0
for c in s[::-1]:
	if c == 'a':
		ans = (ans + b) % MOD
		b = 2 * b % MOD
	else:
		b = (b + 1) % MOD
print(int(ans))


def main():
	s = input()
	r = 0
	c = 0
	m = 10 ** 9 + 7
	for i in range(len(s) - 1, -1, -1):
		if s[i] == 'b':
			c = c % m + 1
		else:
			r = (r % m + c % m) % m
			c = c * 2 % m
	print(r)
main()


mod = 1000000007
qtdb = 0
jogadas = 0
s = input()
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'b':
		qtdb = (qtdb + 1) % mod
	else:
		jogadas = (jogadas + qtdb) % mod
		qtdb = 2 * qtdb % mod
print(jogadas)


S = input()[::-1]
S1 = []
num = 0
for s in S:
	if s == 'b':
		num += 1
	else:
		S1.append(num)
S1 = S1[::-1]
r = 0
num = 1
for s in S1:
	r = (r + s * num) % 1000000007
	num = num * 2 % 1000000007
print(r)


MOD = 1000000007
liste = []

def comp():
	ans = 1
	liste.append(ans)
	for i in range(1, 1000001):
		ans = ans * 2 % MOD
		liste.append(ans)
s = input()
acount = 0
cur = 0
total = 0
comp()
for c in s:
	if c == 'a':
		cur = cur + 1
		total = total + 1
	else:
		total = (total + liste[cur]) % MOD
print(total - len(s))


ans = 0
a_counter = 1
user_input = tuple(input())
for char in user_input:
	if char == 'b':
		ans += a_counter - 1
		ans %= 1000000007
	else:
		a_counter = a_counter * 2
		a_counter %= 1000000007
print(ans)


(l, r, p, m) = (0, 0, 1, 10 ** 9 + 7)
for i in input():
	if i == 'a':
		l += 1
		p = p * 2 % m
	else:
		r = (r + p - 1) % m
print(r)


mod = 10 ** 9 + 7

def main():
	s = input()
	n = len(s)
	p = [0] * n
	for i in range(n):
		if i == 0:
			p[i] = 1
		else:
			p[i] = p[i - 1] * 2
			p[i] %= mod
	ans = 0
	cnt = 0
	for c in s:
		if c == 'a':
			cnt += 1
		else:
			ans += p[cnt] - 1
			ans %= mod
	print(ans)
main()


import sys
read = lambda : sys.stdin.readline().rstrip()
readi = lambda : int(sys.stdin.readline())
writeln = lambda x: sys.stdout.write(str(x) + '\n')
write = lambda x: sys.stdout.write(x)
mod = 10 ** 9 + 7
S = read()
ls = len(S)
b = 0
ans = 0
for i in range(ls):
	if S[ls - 1 - i] == 'b':
		b += 1
	else:
		ans = (ans + b) % mod
		b = b * 2 % mod
writeln(ans)


s = input()
a = 1
ans = 0
mod = 1000000007
for i in s:
	if i == 'a':
		a *= 2
		if a >= mod:
			a %= mod
	else:
		ans += a - 1
		if ans >= mod:
			ans %= mod
print(ans)


m = 1000 * 1000 * 1000 + 7
s = input()
pow = 1
ans = 0
m = 1000 * 1000 * 1000 + 7
cnt = 0
for i in s:
	if i == 'a':
		cnt = cnt + 1
		pow = 2 * pow % m
	else:
		ans = (ans + pow - 1) % m
print(ans)


palavra_inicial = list(input())
num_min = 0
aux = 0
while palavra_inicial:
	if palavra_inicial.pop() != 'a':
		aux += 1
	else:
		num_min += aux
		aux = aux * 2 % 1000000007
print(num_min % 1000000007)


input = input()
len = len(input)
first_pos_a = last_pos_b = 0
mod_num = 10 ** 9 + 7
for i in range(len):
	if input[i] == 'a':
		first_pos_a = i
		break
for i in range(len - 1, 0 - 1, -1):
	if input[i] == 'b':
		last_pos_b = i
		break
if first_pos_a > last_pos_b:
	print(0)
	exit()
count_b = sum = 0
pow_2_a = 1
for i in range(first_pos_a, last_pos_b + 1):
	if input[i] == 'a':
		if count_b > 0:
			sum = (sum + count_b % mod_num * ((pow_2_a - 1) % mod_num) % mod_num) % mod_num
			count_b = 0
		pow_2_a = pow_2_a * 2 % mod_num
	elif input[i] == 'b':
		count_b += 1
		if i == last_pos_b:
			sum = (sum + count_b % mod_num * ((pow_2_a - 1) % mod_num) % mod_num) % mod_num
print(sum)


s = list(input())
p = [1]
for i in range(1000000):
	p.append(p[i] * 2 % 1000000007)
ctr = 0
ans = 0
l = len(s)
for i in range(l):
	if s[i] == 'a':
		ctr += 1
		continue
	ans = (p[ctr] - 1 + ans) % 1000000007
print(ans)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
mod = 10 ** 9 + 7

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

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def main():
	s = S()
	r = 0
	b = 0
	for c in s[::-1]:
		if c == 'a':
			r += b
			r %= mod
			b *= 2
			b %= mod
		else:
			b += 1
	return r
print(main())


(c, v, M) = (0, 0, 10 ** 9 + 7)
for ch in input()[::-1]:
	if ch == 'a':
		v = (v + c) % M
		c = 2 * c % M
	else:
		c += 1
print(v)


m = 10 ** 9 + 7

def binary(v, x=2, p=m):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while v:
		if v & 1 == 1:
			res = res * x % p
		v = v // 2
		x = x * x % p
	return res
s = input()
n = len(s)
b_count = 0
a_count = 0
answer = 0
i = 0
while i < n:
	(x, y) = (0, 0)
	if s[i] == 'a':
		x = 1
		i += 1
		while i < n:
			if s[i] == s[i - 1]:
				x += 1
				i += 1
			else:
				break
		if i != n:
			y = 1
			i += 1
			while i < n:
				if s[i] == s[i - 1] == 'b':
					y += 1
					i += 1
				else:
					break
		a_count += x
		b_count += y
		answer += binary(a_count) * y % m
	else:
		i += 1
answer -= b_count
print(answer % m)


s = input()
if 'b' not in s:
	print(0)
else:
	while s[-1] == 'a':
		s = s[:-1]
	MOD = 10 ** 9 + 7
	preb = 0
	cost = 0
	for i in range(len(s) - 1, -1, -1):
		if s[i] == 'b':
			preb += 1
		else:
			cost += preb
			cost %= MOD
			preb *= 2
			preb %= MOD
	print(cost)


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


import math as mt
import sys, string, bisect
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())
d = defaultdict(int)
s = input().strip()
c = 0
p = s.count('a')
ans = 0
for i in range(len(s)):
	if s[i] == 'a':
		c += 1
	else:
		ans += pow(2, c, 10 ** 9 + 7) - 1
		ans %= 10 ** 9 + 7
print(ans)


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


MOD = 1000000007
inp = input()
cnt = 0
ans = 0
for c in inp[::-1]:
	if c == 'b':
		cnt += 1
	else:
		ans += cnt
		ans %= MOD
		cnt *= 2
		cnt %= MOD
print(ans)


s = list(input())
s = s[::-1]
c = 0
res = 0
for i in range(0, len(s)):
	if s[i] == 'b':
		c += 1
	else:
		res += c
		res %= 10 ** 9 + 7
		c *= 2
		c %= 10 ** 9 + 7
print(res % (10 ** 9 + 7))


x = input()
str0 = x
x = x[::-1]
mod = 10 ** 9 + 7
ans = 0
sum0 = 0
for i in x:
	if i == 'b':
		ans += 1
	if i == 'a':
		sum0 += ans
		sum0 = sum0 % mod
		ans *= 2
		ans = ans % mod
print(sum0)


x = input()

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
MOD = 10 ** 9 + 7
count = 0
ans = 0
for ch in x:
	if ch == 'a':
		count += 1
	else:
		ans = (ans + power(2, count, MOD) - 1) % MOD
print(ans)


s = input()
cnt = 0
m = 10 ** 9 + 7
t = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'a':
		cnt = (cnt + t) % m
		t = t * 2 % m
	else:
		t += 1
print(cnt)


l = input()
(flaga, flagb) = (0, 0)
(countbn, countan) = (0, 0)
count = 0
MOD = 10 ** 9 + 7
i = len(l)
vec = []
while i > 0:
	i = i - 1
	if l[i] == 'b':
		countbn += 1
	else:
		count += countbn
		countbn *= 2
		count %= MOD
		countbn %= MOD
print(count % MOD)


entrada = input()
mod = 1000000007
result = 0
bs = 0
for i in range(len(entrada) - 1, -1, -1):
	if entrada[i] == 'b':
		bs = (bs + 1) % mod
	else:
		result = (result + bs) % mod
		bs = bs * 2 % mod
print(result)


s = input()
l = list()
cur = 0
for i in range(len(s)):
	if s[i] == 'a':
		cur += 1
	else:
		l.append(cur)
mo = 10 ** 9 + 7
cur = 0
exp = 1
res = 0
for i in range(len(l)):
	while l[i] > cur:
		cur += 1
		exp = exp * 2 % mo
	res = (res + exp - 1) % mo
print(res)


M = 10 ** 9 + 7
s = input()
count = 0
res = 0
powers = [1]
length = [1]

def pow(n):
	if n < length[0]:
		return powers[n]
	else:
		for i in range(length[0], n + 1):
			powers.append(powers[-1] * 2 % M)
		length[0] = n + 1
		return powers[n]
for c in s:
	if c == 'a':
		count += 1
	else:
		res += pow(count) - 1
print(res % M)


S = input()
num = 1
r = 0
for s in S:
	if s == 'a':
		num = num * 2 % 1000000007
	else:
		r = (r + num - 1) % 1000000007
print(r)


def main():
	s = input()
	r = b = 0
	for c in s[::-1]:
		if c == 'a':
			r += b
			b = b * 2 % 1000000007
		else:
			b += 1
	print(r % 1000000007)
main()


M = 1000000007
s = input()
(ans, cntstep) = (0, 1)
for c in s:
	if c == 'a':
		cntstep *= 2
		cntstep %= M
	else:
		ans += cntstep - 1
print(ans % M)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout
from heapq import heappush, heappop, heapify, _heapify_max, _heappop_max, nsmallest, nlargest
INF = 99999999999999999999999999999999

def outIn(x):
	print(x, flush=True)
	return input()

def main():
	mod = 1000000007
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	tc = 1
	for _ in range(tc):
		s = rs()
		nb = 0
		op = 0
		for i in range(len(s) - 1, -1, -1):
			if s[i] == 'b':
				nb = nb + 1
			else:
				op = (op + nb) % mod
				nb = nb * 2 % mod
		wi(op % mod)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			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, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			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()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

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

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
fin = sys.stdin
s = fin.readline()
s = s[:-1]
nra = 0
r = 0
pw = []
elpw = 1
for i in range(0, len(s)):
	pw.append(elpw)
	elpw = elpw * 2 % 1000000007
for ch in s:
	if ch == 'a':
		nra += 1
	else:
		r += pw[nra] - 1
		if r >= 1000000007:
			r -= 1000000007
print(r)


mod = 1000000007
powAr = [1, 2]
s = input()

def getSub(s, i):
	result = ''
	countA = 0
	countB = 0
	while i < len(s):
		if s[i] != 'a':
			break
		countA += 1
		i += 1
	if countA == 0:
		return [0, 0]
	while i < len(s):
		if s[i] != 'b':
			break
		countB += 1
		i += 1
	if countB == 0:
		return [0, 0]
	return [countA, countB]

def computePow2():
	for i in range(2, 1000000):
		powAr.append(powAr[-1] * 2 % mod)

def pow2(x):
	return powAr[x]

def do(s):
	count = 0
	i = 0
	carry = 0
	while i < len(s):
		no = getSub(s, i)
		if no[0] + no[1] == 0:
			i += 1
			continue
		noA = no[0] + carry
		noB = no[1]
		i += no[0] + no[1]
		carry = noA
		count += noB * (pow2(noA) - 1)
		count %= mod
	return count % mod
computePow2()
print(do(s))


s = input()
ca = 0
ans = 0
arr = [0, 1]

def f(i):
	while len(arr) < i + 1:
		arr.append((2 * arr[-1] + 1) % (10 ** 9 + 7))
	return arr[i]
for l in s:
	if l == 'a':
		ca += 1
	else:
		ans += f(ca)
		ans = ans % (10 ** 9 + 7)
print(ans)


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


s = input()
c = 0
m = 10 ** 9 + 7
ka = 0
for i in s:
	if i == 'b':
		ka = (ka + c) % m
	else:
		c = (c * 2 + 1) % m
print(ka)


inp = input()
cnt_b = 0
ans = 0
mod = 1000000000 + 7
for i in inp[::-1]:
	if i == 'b':
		cnt_b += 1
	else:
		ans = (ans + cnt_b) % mod
		cnt_b = cnt_b * 2 % mod
print(ans)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

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

def si():
	return input()

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

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, 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 // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

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 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

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
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()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect

def solve():
	s = string()
	l = len(s)
	i = 0
	j = l - 1
	ans = 0
	while j >= 0:
		if s[j] == 'b':
			i += 1
			i % MOD
		else:
			ans += i
			i *= 2
			i %= MOD
			ans %= MOD
		j -= 1
	print(ans)
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')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for i in range(1):
	solve()


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


MOD = 1000000007
s = input()
c = b = 0
for i in reversed(s):
	if i == 'a':
		c = (c + b) % MOD
		b = 2 * b % MOD
	else:
		b = (1 + b) % MOD
print(c)


MOD = 10 ** 9 + 7
s = input()
(bcount, count) = (0, 0)
for c in reversed(s):
	if c == 'b':
		bcount += 1
	else:
		count += bcount
		bcount *= 2
	if bcount >= MOD:
		bcount -= MOD
print(count % MOD)


import sys, os
from io import BytesIO, IOBase
from math import floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque
from heapq import merge, heapify, heappop, heappush, nsmallest
from bisect import bisect_left as bl, bisect_right as br, bisect
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')
(stdin, stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = pow(10, 9) + 7
mod2 = 998244353

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

def iinp():
	return int(inp())

def out(var, end='\n'):
	stdout.write(str(var) + '\n')

def outa(*var, end='\n'):
	stdout.write(' '.join(map(str, var)) + end)

def lmp():
	return list(mp())

def mp():
	return map(int, inp().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(m, val) for j in range(n)]

def ceil(a, b):
	return (a + b - 1) // b
S1 = 'abcdefghijklmnopqrstuvwxyz'
S2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

def isprime(x):
	if x <= 1:
		return False
	if x in (2, 3):
		return True
	if x % 2 == 0:
		return False
	for i in range(3, int(sqrt(x)) + 1, 2):
		if x % i == 0:
			return False
	return True
s = inp()
ans = 0
c = 0
m = 0
for l in s:
	if l == 'b':
		c = (c + m) % mod
	else:
		m = ((m << 1) + 1) % mod
print(c)


s = input()
qb = 0
j = 0
mod = int(1000000000.0) + 7
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'b':
		qb = (qb + 1) % mod
	else:
		j = (j + qb) % mod
		qb = 2 * qb % mod
print(j)


import sys
mod = 10 ** 9 + 7

def solve():
	s = input()[::-1]
	ans = 0
	b_cnt = 0
	for ch in s:
		if ch == 'b':
			b_cnt = (b_cnt + 1) % mod
		else:
			ans = (ans + b_cnt) % mod
			b_cnt = b_cnt * 2 % mod
	print(ans)
solve()


s = input()
MOD = 1000000007
ans = 0
k = 1
for ch in s:
	if ch == 'a':
		k = k * 2 % MOD
	else:
		ans = (ans + k - 1 + MOD) % MOD
print(ans)


res = 0
cur = 0
MOD = 1000000007
for c in input()[::-1]:
	if c == 'b':
		cur += 1
	else:
		res = (res + cur) % MOD
		cur = (cur << 1) % MOD
print(res)


str = input()
cnt = 0
ans = 0
MOD = 10 ** 9 + 7
for i in range(len(str)):
	if str[~i] == 'a':
		cnt = (cnt + ans) % MOD
		ans = ans * 2 % MOD
	else:
		ans += 1
print(cnt)


s = list(input())
n = len(s)
cb = 0
ca = 1
ans = 0
m = 10 ** 9 + 7
for i in range(0, n):
	if s[i] == 'a':
		ca = ca * 2 % m
		cb = 0
	if s[i] == 'b' and (i == len(s) - 1 or s[i + 1] == 'a'):
		cb += 1
		ans = (ans + cb * (ca - 1)) % m
	elif s[i] == 'b' and i != len(s) - 1:
		cb += 1
print(ans)


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


MOD = 10 ** 9 + 7

def addmod(a, b):
	a += b
	if a >= MOD:
		a -= MOD
	return a
s = input()
(bcount, count) = (0, 0)
for c in reversed(s):
	if c == 'b':
		bcount = addmod(bcount, 1)
	else:
		count = addmod(count, bcount)
		bcount = addmod(bcount, bcount)
print(count)


s = input()
suma = 0
cnt = 0
for i in s[::-1]:
	if i == 'b':
		cnt += 1
	if i == 'a':
		suma += cnt
		cnt = cnt * 2 % 1000000007
print(suma % 1000000007)


def mess():
	String = input()
	count_it = 0
	Counter = 0
	for i in String:
		if i == 'a':
			count_it = count_it * 2 % Modulo
			count_it += 1
		elif i == 'b':
			Counter += count_it
	return Counter
Modulo = 1000000007
print(mess() % Modulo)


def boka():
	s = input()
	a = 1
	ans = 0
	mod = 1000000007
	for i in s:
		if i == 'a':
			a *= 2
			if a >= mod:
				a %= mod
		else:
			ans += a - 1
			if ans >= mod:
				ans %= mod
	return ans
print(boka())


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


s = input()
val = 0
a_before = 0
val_a_before = 1
for i in range(len(s)):
	if s[i] == 'a':
		a_before += 1
		val_a_before *= 2
		val_a_before %= 10 ** 9 + 7
	if s[i] == 'b':
		val += val_a_before - 1
		val %= 10 ** 9 + 7
print(val)


IL = lambda : list(map(int, input().split()))
IS = lambda : input().split()
I = lambda : int(input())
S = lambda : input()
MOD = 1000000007
s = S()[::-1]
foundA = []
countB = 0
for c in s:
	if c == 'b':
		countB += 1
	else:
		foundA.append(countB)
		countB = countB * 2 % MOD
print(sum(foundA) % MOD)


string = list(input())
answer = 0
cont = 0
while string:
	if 'a' == string.pop():
		answer += cont
		cont = cont * 2 % 1000000007
	else:
		cont += 1
print(answer % 1000000007)


string = str(input())
index = 1
count = 0
count_a = 0
count_b = 0
flag = False
length = len(string)
for index in range(1, length):
	if string[index - 1] == 'a':
		count_a = ((count_a + 1) * 2 - 1) % 1000000007
	if string[index - 1] == 'a' and string[index] == 'b':
		count += count_a
		has_next = index + 1 < length
		flag = True if has_next and string[index] == 'b' else False
	elif flag and string[index] == 'b':
		count_b += 1
	elif flag and string[index] == 'a':
		count += count_a * count_b
		count_b = 0
if count_b > 0:
	count += count_a * count_b
print(count % 1000000007)


s = input()
l = len(s)
bCount = 0
prevCost = 0
totalCost = 0
for i in range(l)[::-1]:
	if s[i] == 'b':
		bCount += 1
	else:
		cost = bCount + 2 * prevCost
		prevCost = cost % 1000000007
		bCount = 0
		totalCost = (totalCost + cost) % 1000000007
print(totalCost)


import math as m
t = 1
mod = 10 ** 9 + 7
while t:
	t -= 1
	s = input()
	(ans, cost) = (0, 0)
	for i in range(len(s)):
		if s[i] == 'a':
			cost = (cost * 2 + 1) % mod
		else:
			ans += cost
	print(ans % mod)


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


MOD = int(1000000000.0) + 7

def solve():
	s = input()
	r = c = 0
	for i in range(len(s) - 1, -1, -1):
		if s[i] == 'b':
			c += 1
		else:
			r += c
			c = c * 2 % MOD
	return r % MOD
print(solve())


s = input().rstrip()
mod = 10 ** 9 + 7
a_count = 0
rs = 0
cur_mod = 2 ** a_count % mod
for c in s:
	if c == 'a':
		a_count += 1
		cur_mod = cur_mod * 2 % mod
	elif c == 'b':
		rs = (rs + cur_mod - 1) % mod
print(rs)


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


a = input()
mod = 1000000007
ans = 0
count_a = 0
for i in a:
	if i == 'a':
		count_a += 1
	else:
		ans += (pow(2, count_a, mod) - 1) % mod
print(ans % mod)


s = input()
count = 0
step = 0
MOD = 10 ** 9 + 7
for i in range(1, len(s) + 1):
	if s[-i] == 'b':
		count += 1
		count %= MOD
	else:
		step += count
		step %= MOD
		count *= 2
		count %= MOD
print(step)


s = input().strip()
MOD = 10 ** 9 + 7
total = 1
steps = 0
for c in s:
	if c == 'a':
		total = total * 2 % MOD
	else:
		steps += total - 1
print(steps % MOD)


s = input()
s = s[::-1]
a = 0
b = 0
M = 10 ** 9 + 7
for i in s:
	if i == 'b':
		b -= -1
	else:
		a += b
		b = b * 2 % M
print(a % M)


import sys
MOD = 1000000007

def solve():
	str = input()
	tp = 0
	N = 0
	for i in range(len(str)):
		if str[~i] == 'a':
			N = (N + tp) % MOD
			tp = tp * 2 % MOD
		else:
			tp += 1
	print(N)
solve()


MOD = 10 ** 9 + 7
s = input()
s = s[::-1]
ans = a = b = 0
for el in s:
	if el == 'b':
		b += 1
	else:
		ans += b
		ans %= MOD
		b *= 2
		b %= MOD
print(ans)


import sys
import math
import collections
inp = lambda : sys.stdin.readline()
m = 10 ** 9 + 7

def nCr(n, r):
	if n - r < 0:
		return 0
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
s = inp()
ct = 0
ans = 0
i = len(s) - 1
while i >= 0 and s[i] == 'a':
	i -= 1
while i >= 0:
	while i >= 0 and s[i] == 'b':
		i -= 1
		ct += 1
	if i < 0:
		break
	ans = (ans + ct) % m
	ct *= 2
	ct = ct % m
	i -= 1
print(ans % m)


N = 10 ** 9 + 7
s = input().strip()
n = 0
ret = 0
c2n = 2 ** n - 1
for c in s:
	if c == 'a':
		n += 1
		c2n = (2 * c2n + 1) % N
	else:
		ret += c2n
		ret %= N
print(ret)


s = input()[::-1]
ans = 0
r = 0
for i in s:
	if i == 'b':
		r += 1
	else:
		ans += r
		r *= 2
		r %= 1000000007
print(ans % 1000000007)


Mod = 1000000007
aval = 1
res = 0
a = input()
for ch in a:
	if ch == 'a':
		aval = aval * 2 % Mod
	else:
		res = (res + aval - 1) % Mod
print(res)


string = input()
mod = 1000000007
count = 0
b = 0
for i in string[::-1]:
	if i == 'a':
		count = (count + b) % mod
		b = 2 * b % mod
	else:
		b = (b + 1) % mod
print(count)


s = input()
cnt = 0
sm = 0
i = len(s) - 1
while i != -1 and s[i] == 'a':
	i -= 1
while i > -1:
	if s[i] == 'b':
		cnt += 1
	else:
		sm += cnt
		sm %= 1000000007
		cnt *= 2
		cnt %= 1000000007
	i -= 1
print(sm % (10 ** 9 + 7))


s = input()
l = [x for x in range(len(s)) if s[x] == 'a']
(i, step) = (0, 0)
while l:
	step = (len(s) + 2 * step - l.pop() - 1 - i) % (10 ** 9 + 7)
	i += 1
print(step)


import math as mt
import sys, string
from collections import Counter, defaultdict
input = sys.stdin.readline
MOD = 1000000007
PI = 3.141592653589793
I = lambda : int(input())
S = lambda : input()
M = lambda : map(int, input().split())
Ms = lambda : map(str, input().split())
ARR = lambda : list(map(int, input().split()))

def solve():
	s = S()
	(ans, count_b) = (0, 0)
	for i in range(len(s) - 1, -1, -1):
		if s[i] == 'b':
			count_b += 1
		else:
			ans += count_b
			ans %= MOD
			count_b *= 2
			count_b %= MOD
	print(ans)
tc = 1
for _ in range(tc):
	solve()


a = input()
res = 0
cur = 0
for i in reversed(a):
	if i == 'b':
		cur += 1
	else:
		res += cur
		res %= 1000000007
		cur = cur * 2 % 1000000007
print(res)


s = input()
m = 1000000007
p = 0
k = 1
for i in s:
	if i == 'a':
		k <<= 1
		k %= m
	else:
		p += k - 1
		p %= m
print(p)


M = 1000000000.0 + 7
s = input()
n = len(s)
ob = 0
ans = 0
for i in range(n - 1, -1, -1):
	if s[i] == 'b':
		ob += 1
	else:
		ans += ob
		ob = ob * 2
	ob = ob % M
	ans = ans % M
print(int(ans))


import math
s = input('')
count = 0
a = 1
for i in s:
	if i == 'a':
		a = a * 2
	else:
		count = (count + a - 1) % 1000000007
		a = a % 1000000007
print(count)


mod = 10 ** 9 + 7

def Solve(s):
	ans = b = 0
	for c in s[::-1]:
		if c == 'a':
			ans += b
			b = b * 2 % mod
		else:
			b += 1
	print(ans % mod)
Solve(input())


the_string = input()
ans = 0
a_met = 0
const = int(10 ** 9 + 7)
twos = [1]
for i in range(len(the_string) + 20):
	twos.append(twos[i] * 2 % const)
for letter in the_string:
	if letter == 'a':
		a_met += 1
	else:
		ans += twos[a_met] - 1
		ans = ans % const
print(ans)


mod = 1000000007
s = input()
b = 0
b2 = 0
resp = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'b':
		b += 1
		b2 += 1
	else:
		b2 = b2 * 2 % mod
b2 -= b
print(b2)


x = input()
str0 = x
x = x[::-1]
mod = 10 ** 9 + 7
ans = 0
sum0 = 0
for i in range(len(x)):
	if x[i] == 'b':
		ans += 1
	else:
		sum0 += ans
		sum0 = sum0 % mod
		ans *= 2
		ans = ans % mod
print(sum0)


from sys import stdin, stdout

def readint():
	return map(int, stdin.readline().split())
s = list(input())
l = len(s)
modv = 10 ** 9 + 7
acount = 0
bcount = 0
ans = 0
for i in range(l - 1, -1, -1):
	if s[i] == 'a':
		if bcount == 0:
			continue
		else:
			ans = (ans + bcount) % modv
			bcount = bcount * 2 % modv
	else:
		bcount += 1
print(ans)


letters = input()
mod = 10 ** 9 + 7
total_steps = 0
b_count = 0
for c in reversed(letters):
	if c == 'a':
		total_steps += b_count
		b_count = b_count * 2 % mod
	else:
		b_count += 1
print(total_steps % mod)


l = input()
mod = 10 ** 9 + 7
(res, cnt) = (0, 0)
for i in range(len(l) - 1, -1, -1):
	if l[i] == 'b':
		cnt = (cnt + 1) % mod
	else:
		res = (res + cnt) % mod
		cnt = 2 * cnt % mod
print(res)


s = input()
cnt = 0
cur = 1
ans = 0
for i in s:
	if i == 'a':
		cnt = cnt + 1
		cur = cur * 2 % (10 ** 9 + 7)
	else:
		ans = (ans + cur - 1) % 1000000007
print(ans)


s = input()[::-1]
MOD = 10 ** 9 + 7
(ans, bs) = (0, 0)
for c in s:
	if c == 'a':
		ans = (ans + bs) % MOD
		bs = bs * 2 % MOD
	elif c == 'b':
		bs += 1
print(ans)


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
import itertools

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 Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	n = Str()
	MOD = 1000000007
	ans = 0
	res = 0
	for i in n:
		if i == 'a':
			ans += 1
		else:
			res = (res + pow(2, ans, MOD) - 1) % MOD
	print(res)
solution()


strr = input()
numa = 0
ans = 0
modd = 1000000007
pow2 = [1]
for _ in range(1000009):
	neww = 2 * pow2[-1] % modd
	pow2.append(neww)
for i in strr:
	if i == 'a':
		numa += 1
	if i == 'b':
		ans = (ans + pow2[numa] - 1) % modd
print(ans)


s = input()
ans = 0
count = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'b':
		count += 1
	else:
		ans = (ans + count) % 1000000007
		count *= 2
		count %= 1000000007
print(ans)


def quantidadeJogadas(string, c):
	jogadas = 0
	quantidadeB = 0
	i = len(string) - 1
	while i >= 0:
		if string[i] == 'b':
			quantidadeB = (quantidadeB + 1) % c
		else:
			jogadas = (jogadas + quantidadeB) % c
			quantidadeB = 2 * quantidadeB % c
		i -= 1
	return jogadas
c = 1000000007
string = input()
print(quantidadeJogadas(string, c))


s = list(input())
answer = 0
popped = 0
while s:
	if s.pop() == 'b':
		popped += 1
		popped %= 1000000007
	else:
		answer += popped
		popped *= 2
		answer %= 1000000007
		popped %= 1000000007
print(answer)


import sys, itertools, math, collections, random

def ia():
	return [int(i) for i in sys.stdin.readline().strip().split(' ')]

def ii():
	return int(sys.stdin.readline().strip())

def istr():
	return sys.stdin.readline().strip()
s = istr()
m = 10 ** 9 + 7
ans = 0
(a, b) = (0, 0)
ab = False
for c in s:
	if not ab:
		if c == 'a':
			a += 1
		if c == 'b' and a >= 1:
			ab = True
			b = 1
	elif c == 'b':
		b += 1
	else:
		ab = False
		ans = (ans + (pow(2, a, m) - 1) * b) % m
		a = a + 1
		b = 0
if ab:
	ans += (pow(2, a, m) - 1) * b
print(ans % m)


s = input()
su = 0
inc = 0
for c in s:
	if c == 'a':
		inc = (2 * inc + 1) % 1000000007
	elif c == 'b':
		su = (su + inc) % 1000000007
print(su)


s = input()
MOD = int(1000000000.0 + 7)
(b, total) = (0, 0)
for i in range(len(s))[::-1]:
	if s[i] == 'b':
		b = (b + 1) % MOD
	else:
		total = (total + b) % MOD
		b = b * 2 % MOD
print(total)


from sys import stdin, stdout
s = stdin.readline().strip()
MOD = 10 ** 9 + 7
ans = 0
pw = [1]
for i in range(len(s)):
	pw.append(pw[-1] * 2 % MOD)
cnt = 0
for i in range(len(s)):
	if s[i] == 'a':
		cnt += 1
	else:
		ans = (ans + pw[cnt] - 1) % MOD
stdout.write(str(ans))


s = input()[::-1]
(res, cur) = (0, 0)
mod = 10 ** 9 + 7
for x in s:
	if x == 'b':
		cur = (cur + 1) % mod
	else:
		res = (res + cur) % mod
		cur = cur * 2 % mod
print(res)


(s, mod, ans, b) = (list(input()), 1000000007, 0, 0)
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'b':
		b += 1
	elif b:
		ans = (ans + b) % mod
		b = b * 2 % mod
print(ans)


string = input()
mod = 1000000007
(mult, countAtual) = (0, 0)
for i in range(len(string) - 1, -1, -1):
	if string[i] == 'b':
		countAtual += 1
	if string[i] == 'a':
		mult += countAtual
		mult %= mod
		countAtual = countAtual * 2
		countAtual %= mod
print(mult)


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
from collections import defaultdict, deque
import heapq
getcontext().prec = 25
MOD = pow(10, 9) + 7
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')
s = input()
c_a = 1
ans = 0
for i in range(len(s)):
	if s[i] == 'a':
		c_a *= 2
		c_a %= MOD
	else:
		ans += c_a - 1
		ans %= MOD
print(ans)


s = input()
b_s = result = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'a':
		result = (result + b_s) % (1000000000.0 + 7)
		b_s = b_s * 2 % (1000000000.0 + 7)
	else:
		b_s += 1
print(int(result % (1000000000.0 + 7)))


s = input()
ans = 0
j = 0
cnt1 = 0
cnt2 = 0
for i in range(0, len(s)):
	if i >= j:
		while i < len(s) and s[i] == 'a':
			cnt1 = cnt1 + 1
			i = i + 1
		while i < len(s) and s[i] == 'b':
			cnt2 = cnt2 + 1
			i = i + 1
		j = i
		if cnt1 > 0 and cnt2 > 0:
			ans = ans + cnt2
			bb = cnt2 * 2
			temp = cnt1 - 1
			ans = ans + bb * (pow(2, temp, 1000000007) - 1)
		cnt2 = 0
print(ans % 1000000007)


def solve(letters):
	modulo = 10 ** 9 + 7
	(steps, b_s) = (0, 0)
	for i in range(len(letters) - 1, -1, -1):
		if letters[i] == 'b':
			b_s = (b_s + 1) % modulo
		else:
			steps = (steps + b_s) % modulo
			b_s = 2 * b_s % modulo
	return steps
letters = input()
print(solve(letters))


string = input()
mod = 10 ** 9 + 7
numero_bs = 0
mudancas = 0
for i in range(len(string) - 1, -1, -1):
	if string[i] == 'b':
		numero_bs = (numero_bs + 1) % mod
	else:
		mudancas = (mudancas + numero_bs) % mod
		numero_bs = 2 * numero_bs % mod
print(mudancas % mod)


from itertools import groupby
MOD = 10 ** 9 + 7

def calc(string):
	ans = 0
	cnt_a = 0
	for (ch, group) in groupby(string):
		cnt = len(list(group))
		if ch == 'a':
			cnt_a += cnt
		else:
			ans = (ans + cnt * (pows[cnt_a] - 1)) % MOD
	return ans
string = input()
pows = [1]
for i in range(len(string)):
	pows.append(pows[-1] * 2 % MOD)
print(calc(string))


def min_steps(string):
	steps = 0
	b_count = 0
	for i in range(len(string) - 1, -1, -1):
		if string[i] == 'b':
			b_count = (b_count + 1) % (10 ** 9 + 7)
		else:
			steps = (steps + b_count) % (10 ** 9 + 7)
			b_count = 2 * b_count % (10 ** 9 + 7)
	return steps
x = input()
print(min_steps(x))


s = input()
l = 0
r = 0
p = 1
m = 1000000007
for i in range(len(s)):
	if s[i] == 'a':
		l += 1
		p = p * 2 % m
	else:
		r = (r + p - 1) % m
print(r % m)


import sys
s = sys.stdin.read()
n = 1000000007
aCount = 0
bCount = 0
count = 0
increment = 0
for c in s:
	if c == 'a':
		increment = (2 * increment + 1) % n
	if c == 'b':
		count = (count + increment) % n
print(count)


import math
import sys
mod = 1000000007

def main():
	n = input()
	tmp = 0
	ans = 0
	for i in range(len(n) - 1, -1, -1):
		if n[i] == 'a':
			ans += tmp
			ans %= mod
			tmp *= 2
			tmp %= mod
		else:
			tmp += 1
	print(ans)
main()


modulo = 1000000007
b = 0
saida = 0
entrada = input()
tamanho = len(entrada)
for i in range(tamanho - 1, -1, -1):
	if entrada[i] == 'b':
		b = (b + 1) % modulo
	else:
		saida = (saida + b) % modulo
		b = b * 2 % modulo
print(saida)


Mod = 1000000007
cur = 1
res = 0
a = input().strip()
for ch in a:
	if ch == 'a':
		cur *= 2
		cur %= Mod
	else:
		res += cur - 1
		res %= Mod
print(res)


s = list(input())
MOD = 10 ** 9 + 7
ans = 0
cnt = 1
for c in s:
	if c == 'a':
		cnt *= 2
		cnt %= MOD
	else:
		ans += cnt - 1
		ans %= MOD
print(ans)


a = input()
ans = 0
cnta = 0
mod = 10 ** 9 + 7
for i in a:
	if i == 'b':
		ans = (ans + cnta) % mod
	else:
		cnta = (cnta * 2 + 1) % mod
print(ans)


mod = 1000000007
(b, ans) = (0, 0)
for x in reversed(input()):
	if x == 'a':
		ans = (ans + b) % mod
		b = 2 * b % mod
	else:
		b = b + 1 % mod
print(ans)


import sys
import bisect
import math as mt
t = 1
mod = 10 ** 9 + 7
for _ in range(t):
	s = input()
	n = len(s)
	cnt = 0
	ans = 0
	(prev, nex) = (0, 0)
	mul = 1
	pref = [0] * (n + 1)
	pref[0] = 0
	mul = 1
	for i in range(n):
		pref[i + 1] = (mul + pref[i]) % mod
		mul = mul * 2 % mod
	mul = 1
	for i in range(len(s)):
		if s[i] == 'a':
			nex += 1
			cnt += 1
		else:
			ans = (ans % mod + pref[cnt]) % mod
			cnt = nex
	print(ans)


s = input()
mod = 1000000007
step = 0
p = 1
for x in s:
	if x == 'a':
		p = p * 2 % mod
	else:
		step = (step + p - 1) % mod
print(step)


import math
a = input()
mod = int(1000000000.0 + 7)
ans = int(0)
sum = 0

def pow(c):
	ans = 1
	c = int(c)
	base = 2
	while c:
		if c % 2 == 1:
			ans = ans * base % mod
		base = base * base % mod
		c = int(c / 2)
	return ans
for s in a:
	if s == 'b':
		if sum >= 1:
			temp = int(pow(sum))
			ans += temp - 1
			ans %= mod
	else:
		sum += 1
print(ans)


s = list(input())
nob = 0
nom = 0
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'b':
		nob += 1
	else:
		nom += nob
		nob = 2 * nob
		nob %= 10 ** 9 + 7
		nom %= 10 ** 9 + 7
print(nom % (10 ** 9 + 7))


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


def powers(a, m, X):
	p = [1]
	for i in range(m):
		p.append(p[-1] * a % X)
	return p

def solve(r, M):
	pows = powers(2, len(r), M)
	c = 0
	ans = 0
	for char in r:
		if char == 'a':
			c += 1
		elif char == 'b':
			ans = (ans + (pows[c] - 1)) % M
	return ans
s = input()
print(solve(s, 10 ** 9 + 7))


def main():
	s = input()
	tpw = [1 for i in range(len(s) + 1)]
	for i in range(1, len(s) + 1):
		tpw[i] = 2 * tpw[i - 1] % (10 ** 9 + 7)
	na = 0
	ans = 0
	for c in s:
		if c == 'a':
			na += 1
		else:
			ans = (ans + tpw[na] - 1) % (10 ** 9 + 7)
	print(ans)
main()


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


s = list(input())
n = len(s)
cb = 0
ans = 0
mod = 1000000007
for i in range(n - 1, -1, -1):
	if s[i] == 'b':
		cb += 1
		cb %= mod
	else:
		ans += cb
		cb *= 2
		ans %= mod
print(ans)


m = 1000000007
s = [1 if c == 'a' else 0 for c in input()]
s.append('@')
i = len(s) - 1
x = 0
y = 0
while i >= 0:
	y += s[i] == 0
	if s[i] == 1 and s[i + 1] == 0:
		x = (x + y) % m
		y = 2 * y % m
		s[i] = 0
	i -= 1
print(x)


import math as ma
from sys import exit
from decimal import Decimal as dec

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

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

def nu():
	return int(input())
s = input()
c = 0
counta = 1
countb = 0
c = 0
for i in range(0, len(s)):
	if s[i] == 'a':
		counta = counta * 2 % 1000000007
		continue
	if counta > 0:
		c = (c + counta - 1) % 1000000007
print(c)


(a, b, m) = (0, 0, 10 ** 9 + 7)
for i in input()[::-1]:
	if i == 'b':
		b += 1
	else:
		a += b
		b = (b << 1) % m
print(a % m)


import sys
input = sys.stdin.readline
extra = 0
need = 0
for ch in input().strip():
	if ch == 'a':
		need = (need * 2 + 1) % 1000000007
	else:
		extra = (extra + need) % 1000000007
print(extra)


MOD = 1000000007

def main():
	s = input()
	n = len(s)
	ans = 0
	a_ct = 0
	p = 1
	for c in s:
		if c == 'a':
			a_ct += 1
			p *= 2
			p %= MOD
		else:
			ans += p
			ans %= MOD
	ans -= n - a_ct
	if ans < 0:
		ans += MOD
	ans %= MOD
	print(ans)
main()


input = input()
len = len(input)
first_pos_a = 0
last_pos_b = 0
mod_num = 10 ** 9 + 7
i = 0
while i < len:
	if input[i] == 'a':
		first_pos_a = i
		break
	i += 1
i = 0
while i < len:
	if input[~i] == 'b':
		last_pos_b = len + ~i
		break
	i += 1
if first_pos_a > last_pos_b:
	print(0)
	exit()
count_b = 0
sum = 0
pow_2_a = 1
i = first_pos_a
while i <= last_pos_b:
	if input[i] == 'a':
		if count_b > 0:
			sum = (sum + count_b % mod_num * ((pow_2_a - 1) % mod_num) % mod_num) % mod_num
			count_b = 0
		pow_2_a = pow_2_a * 2 % mod_num
	elif input[i] == 'b':
		count_b += 1
		if i == last_pos_b:
			sum = (sum + count_b % mod_num * ((pow_2_a - 1) % mod_num) % mod_num) % mod_num
	i += 1
print(sum)


s = input()
mod = 10 ** 9 + 7
s = s[::-1]
ans = 0
bs = 0
for x in s[s.index('b'):]:
	if x == 'b':
		bs += 1
	else:
		ans += bs
		ans %= mod
		bs = 2 * bs % mod
print(ans)


MOD = 10 ** 9 + 7
s = input().rstrip()
n = len(s)
ways = [0] * (n + 1)
for i in range(1, n + 1):
	ways[i] = (ways[i - 1] + pow(2, i - 1, MOD)) % MOD
ret = 0
na = 0
for (i, ch) in enumerate(s):
	if ch == 'a':
		na += 1
	else:
		ret += ways[na]
		ret %= MOD
print(ret)


s = input()
ans = 0
cb = 0
i = len(s) - 1
while i >= 0:
	if s[i] == 'b':
		cb += 1
	else:
		ans += cb
		ans %= 10 ** 9 + 7
		cb *= 2
		cb %= 10 ** 9 + 7
	i -= 1
print(ans)


x = 10 ** 9 + 7
a = input()
b = 0
r = 0
for i in a[::-1]:
	if i == 'a':
		r += b
		b = b * 2 % x
	else:
		b += 1
r = r % x
print(r)


word = input()
mod = 1000000007
count = 0
res = 0
for i in range(len(word) - 1, -1, -1):
	if word[i] == 'b':
		count = (count + 1) % mod
	else:
		res = (res + count) % mod
		count = count * 2 % mod
print(res)


s = input()
steps = 0
qtdb = 0
mod = 1000000007
for e in range(len(s) - 1, -1, -1):
	if s[e] == 'a':
		steps = (steps + qtdb) % mod
		qtdb = 2 * qtdb % mod
	else:
		qtdb = (qtdb + 1) % mod
print(steps)


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
s = si()[::-1]
(c, b) = (0, 0)
for i in s:
	if i == 'b':
		b += 1
	else:
		c = (c + b) % mod
		b *= 2
		b %= mod
print(c)


import math
s = input()
counterb = 0
answ = 0
MOD = pow(10, 9) + 7
for i in range(len(s) - 1, -1, -1):
	if s[i] == 'b':
		counterb += 1
	else:
		answ += counterb
		counterb *= 2
		counterb %= MOD
		answ %= MOD
print(answ)


str = input()
bset = []
bno = 0
for c in str:
	if c == 'b':
		bno += 1
	else:
		bset += [bno]
		bno = 0
bset += [bno]
ans = 0
acc = 0
for n in reversed(bset[1:]):
	ans += acc + n
	acc *= 2
	acc += 2 * n
	acc %= 1000000007
	ans %= 1000000007
print(ans)


s = input()[::-1]
(a, b) = (0, 0)
mod = 10 ** 9 + 7
for i in s:
	if i == 'b':
		b += 1
	else:
		a += b
		a %= mod
		b <<= 1
		b %= mod
print(a)


a = list(input())
n = len(a)
acount = 1
ans = 0
hell = 10 ** 9 + 7
for i in range(n):
	if a[i] == 'a':
		acount = acount * 2 % hell
	if a[i] == 'b':
		ans += acount - 1
print(ans % hell)


mod = 10 ** 9 + 7
sequence = list(input())
steps = 0
answer = 0
while sequence:
	if 'a' == sequence.pop():
		answer += steps
		steps = steps * 2 % mod
	else:
		steps += 1
print(answer % mod)