import java.util.*;
public class Main // WarAndPeas
{
final long MOD = 1000000007;
long modPow(long a, long b)
{
a %= MOD;
long ans = 1;
while (b > 0)
{
if (b % 2 != 0)
ans = ans * a % MOD;
a = a * a % MOD;
b /= 2;
}
return ans;
}
long add(long a, long b)
{
return (a + b) % MOD;
}
long sub(long a, long b)
{
return (a - b % MOD + MOD) % MOD;
}
long mul(long a, long b)
{
return a * b % MOD;
}
long div(long a, long b)
{
return mul(a, modPow(b, MOD - 2));
}
int N;
int M;
int S;
long[][] pasc;
int c2(int x)
{
return x * (x-1) / 2;
}
public int expectedPeas
(String state
) {
N = state.length();
M = c2(N);
for (int i = 1; i < N; i++)
if (state.charAt(i) == state.charAt(0))
++S;
pasc = new long[N][N];
for (int i = 0; i < N; i++)
for (int j = 0; j < N; j++)
if (j == 0) pasc[i][j] = 1;
else if (j > i) pasc[i][j] = 0;
else pasc[i][j] = add(pasc[i-1][j-1], pasc[i-1][j]);
long[] B = new long[N];
for (int i = 0; i < N-1; i++)
{
int good = i;
int bad = N - i - 1;
long a = div(good * bad, 2 * M);
long b = div(c2(good) + c2(bad) + good, M);
long c = sub(1, a + b);
if (i != 0)
B[i] = mul(B[i-1], a);
if (S == i-1) B[i] = add(B[i], a);
if (S == i) B[i] = add(B[i], b);
if (S == i+1) B[i] = add(B[i], c);
B[i] = div(B[i], c);
}
for (int i = N-2; i >= 0; i--)
B[i] = add(B[i], B[i+1]);
long ans = 0;
for (int i = 0; i < N; i++)
ans = add(ans, mul(B[i], pasc[N-1][i]));
ans = div(ans, pasc[N-1][S]);
++ans;
ans = div(ans, modPow(2, N));
return (int) ans;
}
public static void main
(String[] args
) {
System.
out.
println(new Main
().
expectedPeas(new Scanner
(System.
in).
next())); }
}
aW1wb3J0IGphdmEudXRpbC4qOwoKcHVibGljIGNsYXNzIE1haW4gLy8gV2FyQW5kUGVhcwp7CiAgICBmaW5hbCBsb25nIE1PRCA9IDEwMDAwMDAwMDc7CgogICAgbG9uZyBtb2RQb3cobG9uZyBhLCBsb25nIGIpCiAgICB7CiAgICAgICAgYSAlPSBNT0Q7CiAgICAgICAgbG9uZyBhbnMgPSAxOwogICAgICAgIHdoaWxlIChiID4gMCkKICAgICAgICB7CiAgICAgICAgICAgIGlmIChiICUgMiAhPSAwKQogICAgICAgICAgICAgICAgYW5zID0gYW5zICogYSAlIE1PRDsKICAgICAgICAgICAgYSA9IGEgKiBhICUgTU9EOwogICAgICAgICAgICBiIC89IDI7CiAgICAgICAgfQogICAgICAgIHJldHVybiBhbnM7CiAgICB9CgogICAgbG9uZyBhZGQobG9uZyBhLCBsb25nIGIpCiAgICB7CiAgICAgICAgcmV0dXJuIChhICsgYikgJSBNT0Q7CiAgICB9CiAgICBsb25nIHN1Yihsb25nIGEsIGxvbmcgYikKICAgIHsKICAgICAgICByZXR1cm4gKGEgLSBiICUgTU9EICsgTU9EKSAlIE1PRDsKICAgIH0KICAgIGxvbmcgbXVsKGxvbmcgYSwgbG9uZyBiKQogICAgewogICAgICAgIHJldHVybiBhICogYiAlIE1PRDsKICAgIH0KICAgIGxvbmcgZGl2KGxvbmcgYSwgbG9uZyBiKQogICAgewogICAgICAgIHJldHVybiBtdWwoYSwgbW9kUG93KGIsIE1PRCAtIDIpKTsKICAgIH0KCiAgICBpbnQgTjsKICAgIGludCBNOwogICAgaW50IFM7CiAgICBsb25nW11bXSBwYXNjOwoKICAgIGludCBjMihpbnQgeCkKICAgIHsKICAgICAgICByZXR1cm4geCAqICh4LTEpIC8gMjsKICAgIH0KCiAgICBwdWJsaWMgaW50IGV4cGVjdGVkUGVhcyhTdHJpbmcgc3RhdGUpCiAgICB7CiAgICAgICAgTiA9IHN0YXRlLmxlbmd0aCgpOwogICAgICAgIE0gPSBjMihOKTsKICAgICAgICBmb3IgKGludCBpID0gMTsgaSA8IE47IGkrKykKICAgICAgICAgICAgaWYgKHN0YXRlLmNoYXJBdChpKSA9PSBzdGF0ZS5jaGFyQXQoMCkpCiAgICAgICAgICAgICAgICArK1M7CgogICAgICAgIHBhc2MgPSBuZXcgbG9uZ1tOXVtOXTsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IE47IGkrKykKICAgICAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBOOyBqKyspCiAgICAgICAgICAgICAgICBpZiAoaiA9PSAwKSBwYXNjW2ldW2pdID0gMTsKICAgICAgICAgICAgICAgIGVsc2UgaWYgKGogPiBpKSBwYXNjW2ldW2pdID0gMDsKICAgICAgICAgICAgICAgIGVsc2UgcGFzY1tpXVtqXSA9IGFkZChwYXNjW2ktMV1bai0xXSwgcGFzY1tpLTFdW2pdKTsKICAgICAgICAgICAgICAgIAogICAgICAgIGxvbmdbXSBCID0gbmV3IGxvbmdbTl07CiAgICAgICAgZm9yIChpbnQgaSA9IDA7IGkgPCBOLTE7IGkrKykKICAgICAgICB7CiAgICAgICAgICAgIGludCBnb29kID0gaTsKICAgICAgICAgICAgaW50IGJhZCA9IE4gLSBpIC0gMTsKICAgICAgICAgICAgbG9uZyBhID0gZGl2KGdvb2QgKiBiYWQsIDIgKiBNKTsKICAgICAgICAgICAgbG9uZyBiID0gZGl2KGMyKGdvb2QpICsgYzIoYmFkKSArIGdvb2QsIE0pOwogICAgICAgICAgICBsb25nIGMgPSBzdWIoMSwgYSArIGIpOwogICAgICAgICAgICBpZiAoaSAhPSAwKQogICAgICAgICAgICAgICAgQltpXSA9IG11bChCW2ktMV0sIGEpOwogICAgICAgICAgICBpZiAoUyA9PSBpLTEpICAgQltpXSA9IGFkZChCW2ldLCBhKTsKICAgICAgICAgICAgaWYgKFMgPT0gaSkgICAgIEJbaV0gPSBhZGQoQltpXSwgYik7CiAgICAgICAgICAgIGlmIChTID09IGkrMSkgICBCW2ldID0gYWRkKEJbaV0sIGMpOwogICAgICAgICAgICBCW2ldID0gZGl2KEJbaV0sIGMpOwogICAgICAgIH0KICAgICAgICBmb3IgKGludCBpID0gTi0yOyBpID49IDA7IGktLSkKICAgICAgICAgICAgQltpXSA9IGFkZChCW2ldLCBCW2krMV0pOwogICAgICAgIGxvbmcgYW5zID0gMDsKICAgICAgICBmb3IgKGludCBpID0gMDsgaSA8IE47IGkrKykKICAgICAgICAgICAgYW5zID0gYWRkKGFucywgbXVsKEJbaV0sIHBhc2NbTi0xXVtpXSkpOwogICAgICAgIGFucyA9IGRpdihhbnMsIHBhc2NbTi0xXVtTXSk7CiAgICAgICAgKythbnM7CiAgICAgICAgYW5zID0gZGl2KGFucywgbW9kUG93KDIsIE4pKTsKICAgICAgICByZXR1cm4gKGludCkgYW5zOwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpCiAgICB7CiAgICAgICAgU3lzdGVtLm91dC5wcmludGxuKG5ldyBNYWluKCkuZXhwZWN0ZWRQZWFzKG5ldyBTY2FubmVyKFN5c3RlbS5pbikubmV4dCgpKSk7CiAgICB9Cn0=