aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

import java.util.Scanner;
//import java.lang.Math;

public class lozi {


	public static int n;
	public static String s;
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);


		s = scan.next();
		n = s.length() ;

		System.out.print(asli(0));
	}
	//====================================================
	public static long asli (int start)
	{
		long tedad_a = 0, first_b = 0, tedad = 0;
		if(start >= n-1) {
			if (s.charAt(n - 1) == 'a')
				return 1;
			else
				return 0;
		}
		else {
			int counter = 0;
			for( int k = start; k < n; k++)
				if (s.charAt(k) == 'b')			counter ++;
			if(counter > 0) {
				for (int i = start ; i < n; i++)

					if (s.charAt(i) == 'b') {
						first_b = i;
						break;
					}

				for (int i = start; i < first_b; i++)
					if(s.charAt(i) == 'a')
					tedad_a++;
				return tedad_a + (tedad_a + 1) * asli((int)first_b + 1);
			}
			else
			{
				for (int j = start; j < n; j++)
					if(s.charAt(j) == 'a')
						tedad ++;
				return tedad;


			}
		}

	}

	}



