aaaaabb
 aabaaaa
 babbabaabbbbabwbvbhbbbaaabbabbbbbbbkabbbbabaaabbbbbbajabbaaabazbbbzbalbabbwbbaabbabacabdbabbbfaaabbb
 baaahbbbba
 ababavvvv
 abnxabbaab
 krflnzhter
 amaabbbbxaabbbabaabaabbaaabaaaaabibbabaabaaabaabcaaxabablbbbbmbbbaaaaaabbaabbbaaabaaaababaababbabbbb
 babbbaaaaaabbbaabaaaaaoaabababaababaaaaababaaaaaaabbbbbbaaapaabaaabaaababaaaabaaaabaaaaababaaaabaaab

5
 14
 42467327
 7
 7
 11
 0
 98718509
 813881762

import java.util.*;
import java.io.*;
public class Main
{
	static class FastReader 
	{ 
	    BufferedReader br; 
	    StringTokenizer st; 

	    public FastReader() 
	    { 
	        br = new BufferedReader(new
	                 InputStreamReader(System.in)); 
	    } 
	    String next() 
	    { 
	        while (st == null || !st.hasMoreElements()) 
	        { 
	            try
	            { 
	                st = new StringTokenizer(br.readLine()); 
	            } 
	            catch (IOException  e) 
	            { 
	                e.printStackTrace(); 
	            } 
	        } 
	        return st.nextToken(); 
	    }
	    int nextInt() 
	    { 
	        return Integer.parseInt(next()); 
	    } 
	    long nextLong()
	    {
	    	return Long.parseLong(next());
	    }
	}

	public static void main(String args[])
	{
		FastReader s=new FastReader();
		String t=s.next();
		int n=t.length();
		long ans=0l;
		ArrayList<Integer> al=new ArrayList<Integer>();
		ArrayList<Integer> bl=new ArrayList<Integer>();
		for(int i=0;i<n;i++)
		{
			if(t.charAt(i)=='a')
			{
				al.add(i);
				ans++;
			}
			else if(t.charAt(i)=='b')
				bl.add(i);
			
		}
		
		int a=al.size();
		int b=bl.size();
		int va=0;
		int vb=0;
		int M=1000000007;
		for(int i=0;i<a;i++)
		{
			int temp1=al.get(i);
			for(int j=i+1;j<a;j++)
			{
				int temp2=al.get(j);
				for(int k=0;k<b;k++)
				{
					int temp3=bl.get(k);
					if(temp1<temp3&&temp3<temp2)
					{
						ans=(ans+(long)(a-j))%M;
						while(i<j-1&&al.get(i)<al.get(j))
						{
							i++;
							ans=(ans+(long)(a-j))%M;
						}
						while(bl.size()>0&&bl.get(0)<temp2)
							bl.remove(0);
						
						b=bl.size();
						break;
					}
					
				}	
			}
		}
		System.out.println(ans);
	}
	
}