#include using namespace std; typedef long long ll; typedef long double ld; #define REP(i, n) for (int i = 0; i < (n); ++i) #define REPR(i, n) for (int i = n - 1; i >= 0; --i) #define FOR(i, m, n) for (int i = m; i < n; ++i) #define FORR(i, m, n) for (int i = m; i >= n; --i) #define ALL(v) (v).begin(),(v).end() templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b0;k>>=1){ if(k&1){ res=(res*n)%m; } n=(n*n)%m; } return res; } int main(){ cin.tie(0); ios::sync_with_stdio(false); COMinit(); string s;cin >> s; ll n=s.size(); vector> c(26); REP(i,n){ c[s[i]-'a'].push_back(i); } ll ans=n*pow_mod(2,n-1,mod)%mod; REP(i,26){ int t=c[i].size(); vector a(t+1); REP(j,t){ a[j+1]=(a[j]+pow_mod(2,c[i][j],mod))%mod; } ll res=0; REP(j,t){ (res+=a[j]*pow_mod(2,n-1-c[i][j],mod)%mod)%=mod; } (ans+=mod-res)%=mod; } cout << ans << endl; }