#include<bits/stdc++.h>
using namespace std;
#define sz(s) long(s.size())
#define ll long long
#define F first
#define S second
#define pb push_back
#define all(v) v.begin(), v.end()
#define file(s) freopen(s".in", "r", stdin); freopen(s".out", "w", stdout)
const int N=1e6+2, mod=1e9+7;
char a[N];
vector<vector<int> > g(28);
int n;
signed main() {
	string s;
	cin>>s;
	n=sz(s);
	for(int i=1; i<=n; i++)a[i]=s[i-1];
	for(int i=1; i<=n; i++) {
		g[int(a[i]-'A')].pb(i);
	}
	ll cnt=0;
	for(int i=1; i<=n; i++) {
		for(int j=0; j<=27; j++) {
			if(g[j].empty() || g[j].back()<i)continue;
			if(sz(g[j])==1) {
				if(g[j][0]>=i)cnt=(cnt+(n-g[j][0]+1))%mod;
				continue;
			}
			int l=0, r=sz(g[j])-1;
			while(l<=r) {
				int mid=(l+r)>>1;
				if(g[j][mid]>=i)r=mid-1;
				else l=mid+1;
			}
			if(l==sz(g[j])-1) {
				cnt=(cnt+(n-g[j][l]+1))%mod;
				continue;
			}
			cnt=(cnt+(g[j][l+1]-g[j][l]))%mod;
		}
	}
	cout << cnt%mod << '\n';
}