aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

import java.util.*;

public class A671{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
	String s=sc.next();
	char[] c=s.toCharArray();
	long ans=0;
	long sum=0;
	long mod=1000000007;
	int n=s.length();
	long a=0;long b=0;
	for(int i=0;i<n;i++){
	    if(c[i]=='a'){
	        a++;
	    }
	    else if(c[i]=='b'){
	       b++; 
	    }
	    
	}
	if(b==0){
	    sum=a*1;
	}
	
	for(int i=1;i<=b;i++){
	    
	    sum+=a*1-i+1;
	    
	}

	System.out.println(sum);
 
 
        
	}
}
 