Problem:
 Score : 200 points    Problem Statement You are given a string S of length N .
Among its subsequences, count the ones such that all characters are different, modulo 10^9+7 . Two subsequences are considered different if their characters come from different positions in the string, even if they are the same as strings.  Here, a subsequence of a string is a concatenation of one or more characters from the string without changing the order.      Constraints  1 \leq N \leq 100000  S consists of lowercase English letters.  |S|=N         Input Input is given from Standard Input in the following format:  N  S       Output Print the number of the subsequences such that all characters are different, modulo 10^9+7 .        Sample Input 1 4
abcd      Sample Output 1 15  Since all characters in S itself are different, all its subsequences satisfy the condition.       Sample Input 2 3
baa      Sample Output 2 5  The answer is five: b , two occurrences of a , two occurrences of ba . Note that we do not count baa , since it contains two a s.       Sample Input 3 5
abcab      Sample Output 3 17

Solution (Python):
import sys, math, re
from functools import lru_cache
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

def main():
    N = ii()
    S = input()
    d = {}
    for i in range(N):
        if not S[i] in d:
            d[S[i]] = 1
        d[S[i]] += 1

    ans = 1
    for v in d.values():
        ans *= v
        ans %= MOD

    ans -= 1
    print(ans%MOD)

if __name__ == "__main__":
    main()

Solution (Python):
mod = 10**9 + 7
n = int(input())
s = input()
dic = {}
for si in s:
  if si not in dic:
    dic[si] = 0
  dic[si] += 1
ans = 1
for k, v in dic.items():
  ans = ans * ((v+1) % mod) % mod
print((ans-1)%mod)

Solution (Python):
import sys
def input():
  return sys.stdin.readline().rstrip()

N=int(input())
S=input()

MOD=10**9+7
num=[0]*30

for c in S:
  num[ord(c)-ord("a")]+=1

ans=1
for i in range(26):
  ans*=num[i]+1
  ans%=MOD

print((ans+MOD-1)%MOD)

Solution (Python):
mod = 10**9+7

n = int(input())
S = input()

alp = [chr(i) for i in range(97, 97+26)]

cnt = []
for a in alp:
    cnt.append(S.count(a))

ans = 1
for c in cnt:
    if c:
        ans *= (c+1)

print((ans-1)%mod)

Solution (Python):
N = int(input())
S = str(input())
V = 'abcdefghijklmnopqrstuvwxyz'
Lavida = [1]*26
for i in range (0, N):
	Lavida[V.index(S[i])]+=1

count = 1
for i in range (0, 26):
	count*=Lavida[i]
	count=count%(10**9+7)

print((count-1)%(10**9+7))

Solution (Python):
from string import ascii_lowercase
from functools import reduce
from operator import mul
n = int(input())
S = input()
mod = 10**9 + 7
print(reduce(lambda x, y: x*y % mod, (S.count(c)+1 for c in ascii_lowercase))-1)

Solution (Python):
from string import ascii_lowercase
n = int(input())
S = input()
mod = 10**9 + 7
s = 1
for c in ascii_lowercase:
  s *= S.count(c)+1
  s %= mod
print(s-1)

Solution (Python):

from collections import Counter
def resolve():
    MOD = 10 ** 9 + 7
    N = int(input())
    S = input()

    CNT = Counter(S)
    ans = 1
    for v in CNT.values():
        ans *= v + 1
        ans %= MOD

    print(ans - 1)


if __name__ == "__main__":
    resolve()

Solution (Python):
from collections import Counter
MOD = 10**9 + 7
N = int(input())
S = input()
count_si = Counter(S)
ans = 1
for v in count_si.values():
    ans = (ans * (v+1)) % MOD

print((ans-1)%MOD)

Solution (Python):
n=int(input())
s=input()
m=10**9+7
dict={}
for i in s:
  if i not in dict:
    dict[i]=1
  else:
    dict[i]+=1
ans=1
for i in dict:
  ans*=dict[i]+1
print((ans-1)%m)

Solution (Python):

import collections
N = int(input())
S = input()
MOD = 10**9+7

cnt = collections.Counter(S)




ans = 1
for value in cnt.values():
    ans = (ans*(value+1))%MOD
print(ans - 1)

Solution (Python):
n = int(input())
a = list(input())
b = list(set(a))
ans = 1
for i in b:
    ans %= 10**9+7
    ans *= a.count(i)+1
print((ans-1)%(10**9+7))

Solution (Python):
N=int(input())
S=input()
cnt=[1]*26
for i in range(len(S)):
  cnt[ord(S[i])-ord('a')]+=1
ans=1
for i in range(26):
  ans*=cnt[i]
print((ans-1)%(10**9+7))

Solution (Python):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 1
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n = k()
s = X()

count = list(Counter(s).most_common())

for i in count:
    ans *= i[1]+1

ans -= 1
print(ans%mod)

Solution (Python):
from collections import Counter
MOD = 10**9 + 7
N = int(input())
S = input()
count_si = Counter(S)
ans = 1
for v in count_si.values():
    ans = (ans * (v+1)) % MOD

print((ans-1)%MOD)

Solution (Python):
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    s = S()
    ans = 1
    num = 10**9 + 7
    count = collections.Counter(s)

    for value in count.values():
        ans *= value+1
        ans %= num

    ans -= 1
    ans % num
    print(ans)
        
main()

Solution (Python):
from collections import Counter
N=int(input())
S = input()
ss = list(Counter(S).most_common())

ans = 1
MOD = 10**9 + 7
for i in range(len(ss)):
    ans *= ss[i][1] +1
    ans %= MOD
print(ans-1)

Solution (Python):
N = int(input())
S = input()
MOD = 10 ** 9 + 7
from collections import defaultdict
dic = defaultdict(int)

for s in S:
  dic[s] += 1
  
ans = 1
for value in dic.values():
  ans *= (value + 1)
  ans %= MOD
  
print((ans - 1) % MOD)

Solution (Python):
import collections
n=int(input())
s=list(input())
s=collections.Counter(s)
ans=1
for i in s:
  ans*=s[i]+1
  ans%=10**9+7
print(ans-1)

Solution (Python):
n = int(input()); s = input()
a = [0]*26; b = 1
for i in range(n): a[ord(s[i])-97] += 1
for i in range(26): b *= a[i]+1
print((b-1)%(10**9+7))

Solution (Python):
def main():
    from collections import Counter
    N = int(input())
    S_count = Counter(input())
    P = 10**9+7
    ans = 1
    for v in S_count.values():
        ans *= v+1
        ans %= P
    print(ans-1)



main()

Solution (Python):
from collections import Counter
input()
cnt=Counter(input())

ans=1
mod=10**9+7

for v in cnt.values():
    ans*=v+1
    ans%=mod

print((ans-1)%mod)

Solution (Python):
input()
S=input()
s=set(S)
a=1
for c in s:a=a*(S.count(c)+1)%(10**9+7)
print(a-1)

Solution (Python):
import operator
import functools
N = int(input())
S = input()
c = [1] * 26
for s in S:
    c[ord(s)-ord('a')] += 1
print((functools.reduce(operator.mul,c)-1) % (10**9+7))

Solution (Python):
from collections import Counter

n = int(input())
s = input()

cnt = Counter(s)

ans = 1

for v in cnt.values():
    ans *= v + 1
    ans %= (10 ** 9 + 7)

print(ans - 1)

Solution (Python):
from collections import Counter
N = int(input())
S = input()
S_c = Counter(S)
ans = 1
mod = 10 ** 9 + 7
for val in S_c.values():
    ans *= (val + 1)
    ans %= mod

print(ans - 1)

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 9)

def int1(x): return int(x) - 1
def II(): return int(input())
def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())
def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def MS(): return input().split()
def LS(): return list(input())
def LLS(rows_number): return [LS() for _ in range(rows_number)]
def printlist(lst, k=' '): print(k.join(list(map(str, lst))))
INF = float('inf')

from collections import deque, defaultdict





def solve():
    N = II()
    S = input()
    MOD = 1000000007

    d = defaultdict(lambda: 0)
    for s in S:
        d[s] += 1

    ans = 1
    for n in d.values():
        if n == 0: continue
        ans *= (n+1)
    print((ans-1) % MOD)
    
if __name__ == '__main__':
    solve()

Solution (Python):
from collections import Counter
N = int(input())
S = str(input())

c = Counter(S)
l = list(c.values())

ans = 1
for n in l:
  ans *= n+1
ans %= (10**9+7)
print(ans-1)

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from functools import reduce
from bisect import bisect_left, insort_left
from heapq import heapify, heappush, heappop

INPUT = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(INPUT())
MAP = lambda: map(int, INPUT().split())
S_MAP = lambda: map(str, INPUT().split())
LIST = lambda: list(map(int, INPUT().split()))
S_LIST = lambda: list(map(str, INPUT().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    N = INT()
    S = INPUT()

    ans = 1
    for n in set(S):
        ans *= S.count(n) + 1

    print((ans - 1) % mod)


if __name__ == '__main__':
    main()

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

ans = 1
for x in Counter(S).values():
    ans *= x + 1
    ans %= mod
print((ans - 1) % mod)

Solution (Python):
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

S_list = []
for s in S:
    S_list.append(s)

c = Counter(S)

ans = 1
for v in c.values():
    ans *= (v + 1)
ans = ans - 1
ans = ans % mod
print(ans)

Solution (Python):
from collections import Counter
n = int(input())
d = Counter(list(input()))
val = d.values()
ans = 1
for i in val:
    ans *= (i + 1)
    ans %= 10**9 + 7
print(ans - 1)

Solution (Python):
from collections import Counter
import sys
input = sys.stdin.readline



def main():
    n = int(input().strip())
    S = input().strip()
    cnts = Counter(S)

    x = 1
    for v in cnts.values():
        x *= (v + 1)
    ans = x - 1

    MOD = 10**9 + 7

    print(ans % MOD)
    return


if __name__ == "__main__":
    main()

Solution (Python):
n=int(input())
s=input()
d=dict(zip([chr(97+i) for i in range(26)],[1]*26))
mod=10**9+7
for i in s:
  d[i]+=1
ans=1
for i in d.values():
  ans*=i
  ans%=mod
print((ans-1)%mod)

Solution (Python):
import sys
import math
from collections import Counter

N = int(input())
S = input()

MOD = 1000000007













































ans = 1
counter = Counter()
counter[S[0]] += 1

for ch in S[1:]:
    if ch in counter:
        tmp = 1
        for k, cnt in counter.items():
            if k == ch:
                continue

            tmp = (tmp * (1 + cnt)) % MOD

        ans = (ans + tmp) % MOD
        counter[ch] += 1
    else:
        ans = (2 * ans) % MOD
        ans = (ans + 1) % MOD
        counter[ch] += 1

print(ans)

Solution (Python):
from collections import Counter


def main():
    MOD = 10**9 + 7
    N = int(input())
    counter = Counter(input())
    ans = 1
    for c in counter.values():
        ans *= c + 1
        ans %= MOD
    print(ans - 1)


if __name__ == '__main__':
    main()

Solution (Python):
N = int(input())
S = input()
al = [0 for _ in range(26)]
for i in range(N):
    al[ord(S[i])-97] += 1
count = 1
for j in range(26):
    count *= al[j]+1
    count %= 10**9+7
print((count-1)%(10**9+7))

Solution (Python):
CONST = 10**9+7
n = int(input())
s = input()

chars = {}
for c in s:
    if c in chars:
        chars[c] += 1
    else:
        chars[c] = 1

val = 1
for i in chars.values():
    val = (val * (i+1)) % CONST
print(val-1)

Solution (Python):
n = int(input())
s = input()
count = [0]*26
for i in s:
    count[ord(i)-ord("a")] += 1
mod = 10**9+7
ans = 1
for i in count:
    ans *= (i+1)
    ans %= mod
print(ans-1)

Solution (Python):
N = int(input())
S = list(input())
mod = 10**9+7
ans = 1
for i in 'abcdefghijklmnopqrstuvwxyz':
    ans *= S.count(i)+1
    ans %= mod
print((ans-1) % mod)

Solution (Python):
import sys
from collections import Counter

input = sys.stdin.readline
P = 10 ** 9 + 7


def main():
    N = int(input())
    S = input().rstrip()

    c = Counter(S)
    ans = 1
    for v in c.values():
        ans = (ans * (v + 1)) % P

    ans = (ans - 1) % P
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter
N = int(input())
S = list(input())
mod = pow(10, 9)+7
X = Counter(S)
ans = 1
for i in X.values():
    ans = (ans*(i+1)) % mod
print(ans-1)

Solution (Python):
from collections import Counter
N = int(input())
C = Counter(input())

mod = 10 ** 9 + 7
ans = 1
for v in C.values():
    ans *= (v + 1)  
    ans %= mod

ans -= 1
print(ans % mod)

Solution (Python):
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
s = input()
c = Counter(s)

res = 1
for v in c.values():
    
    res *= v+1
    res %= mod
print(res-1)

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
S = list(input())
mod = 10**9+7
from collections import Counter
c = Counter(S)
lis = []
ans = 1
for _, cnt in c.most_common():
    ans *= (cnt+1)
    ans %= mod
print((ans-1)%mod)

Solution (Python):
N = int(input())
S = input()
from collections import Counter
ctr = Counter(S)
MOD = 10**9+7

ans = 1
for v in ctr.values():
    ans *= (v+1)
    ans %= MOD
ans -= 1
ans %= MOD
print(ans)

Solution (Python):
MOD = 10 ** 9 + 7
cnt = [1 for _ in range(26)]
n = int(input())
string = input()
for s in string:
    cnt[ord(s) - 97] += 1
ans = 1
for num in cnt:
    ans *= num
    ans %= MOD
print((ans - 1) % MOD)

Solution (Python):
from collections import Counter

N = int(input())
S = input()
MOD = 10**9 + 7

ans, C = 0, Counter(S)
for i in range(N):
    sub_ans = 1
    for x in C:
        if x != S[i]:
            sub_ans = ((C[x] + 1) * sub_ans) % MOD
    ans = (ans + sub_ans) % MOD
    C[S[i]] -= 1
print(ans)

Solution (Python):
import math
import collections
import fractions
import itertools
import functools
import operator
import bisect

def lowmod(a, b, mod):
    a -= b
    if a >= mod:
        a -= mod
    return a

def solve():
    n = int(input())
    s = input()
    c = collections.Counter(s)
    mod = 10**9+7
    ans = 1
    for i in c:
        ans *= (c[i]+1)
        ans %= mod
    ans = lowmod(ans, 1, mod)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()

Solution (Python):
from collections import Counter

MOD = 10**9+7

N = int(input())
s = input()
d = Counter(s)
res = 1
for value in d.values():
  res *= value + 1
  res %= MOD
res -= 1
print(res)

Solution (Python):
from collections import Counter

n = int(input())
s = Counter(input())
mod = 10 ** 9 + 7

ans = 1
for i in s.values():
    ans = ans * (i + 1) % mod
print(ans - 1)

Solution (Python):
n = int(input())
S = list(input())



from collections import defaultdict
d = defaultdict(int)
for s in S:
    d[s] += 1
ans = 1
mod = 10**9 + 7
for k in d.keys():
    ans *= (d[k]+1)
    ans %= mod
ans -= 1
print(ans)

Solution (Python):
from collections import Counter

N = int(input())
S = input()

mod = 10**9+7

cnt = Counter(S)

res = 1
for v in cnt.values():
    res *= v+1
    res %= mod

print((res-1)%mod)

Solution (Python):
from collections import Counter

N = int(input())
S = list(input())

ac = Counter(S)
ans = 0
for value in ac.values():
    if ans == 0:
        ans = value+1
    else:
        ans = ans*(value+1)

MOD = 10**9+7
print((ans-1) % MOD)

Solution (Python):
from collections import Counter
n = int(input().rstrip())
c = Counter(input().rstrip())
MOD = 10**9+7

ans = 1
for v in c.values():
    ans *= v+1
    ans %= MOD

print(ans-1)

Solution (Python):
import sys
from collections import defaultdict, deque, Counter
import math


from bisect import bisect_left, bisect_right





input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)


def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD


def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD


def kaijyo(n):
    ret = [1]
    for i in range(1, n + 1):
        ret.append((ret[-1] * i)% MOD)
    return ret


def solve():
    n = getN()
    s = getS()
    c = Counter(s)
    ans = 1
    for v in c.values():
        
        ans *= v + 1
        ans %= MOD

    print(ans-1)


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    
    solve()

Solution (Python):
import sys,collections
input = sys.stdin.readline
m=10**9+7

N=int(input())
S=input().rstrip()
Sc = collections.Counter(S)
cnt = 1
for s in Sc.values():
    cnt *= (s+1)
print((cnt-1)%m)

Solution (Python):
import collections
N = int(input())
S = input()
A = collections.Counter(S)
B = list("qwertyuiopasdfghjklzxcvbnm")
C = []
for i in B:
    C.append(A[i])
D = [i+1 for i in C if i != 0]
ans = 1
for i in range(len(D)):
    ans *= D[i]
print((ans-1)%(10**9 + 7))

Solution (Python):
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = input()
a = [0]*26

for x in s:
    a[ord(x)-ord('a')] += 1

ans = 1
for x in a:
    ans *= x + 1

ans = ( ans - 1 ) % ( 10**9 + 7 )
print(ans)

Solution (Python):
n=int(input())
s=list(input())
num=[0]*26
for i in range(n):
    num[ord(s[i])-97]+=1
ans=1
for i in range(26):
    ans*=num[i]+1
    ans%=10**9+7
ans-=1
ans%=10**9+7
print(ans)

Solution (Python):
N=int(input())
S=input()
K=10**9+7

T={}
for s in S:
    if s in T:
        T[s]+=1
    else:
        T[s]=2

X=1
for a in T:
    X=(X*T[a])%K
print((X-1)%K)

Solution (Python):
N=int(input())
S=list(input())

from collections import*
C=Counter(S)

ans=1
for c in C.values():
    ans*=(c+1)%(10**9+7)
ans=(ans-1)%(10**9+7)

print(ans)

Solution (Python):

from collections import Counter

n = int(input())
s = input()
c = Counter(s)
mod = 10**9 + 7
ans = 1
for i in c.values():
    ans = (i + 1) * ans % mod
print((ans - 1) % mod)

Solution (Python):
import sys
from collections import Counter

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    s = input()

    res = 1
    D = Counter(s)
    for v in D.values():
        res *= (v + 1)
        res %= mod
    print(res - 1)


if __name__ == '__main__':
    resolve()

Solution (Python):
A=int(input())
l=list(input())
mod=10**9+7
import collections
l=list(collections.Counter(l).values())
l=[i+1 for i in l]
ans=1
for i in l:
   ans*=i
   ans%=mod
print(ans-1)

Solution (Python):
_=input()
s=input()
ans=1
for i in set(s):
    ans*=s.count(i)+1
    ans%=10**9+7
print(ans-1)

Solution (Python):
from collections import *
_=input()
c=Counter(input())
ans=1
for i in c.values():
    ans*=i+1
    ans%=10**9+7
print(ans-1)

Solution (Python):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter
    from string import ascii_lowercase

    n = int(readline())
    s = input()
    ans = 0
    counter = Counter()

    for char in s:
        counter[char] += 1
        t = 1
        for char2 in ascii_lowercase:
            if char == char2:
                continue
            t *= (counter[char2] + 1)
            t %= MOD
        ans += t
        ans %= MOD

    print(ans)


if __name__ == '__main__':
    main()

Solution (Python):






import collections





N = int(input())
S = input()





ans = 1
for tmp in collections.Counter(S).items():
    x = tmp[1]+1
    ans *= x
print((ans-1)%(10**9+7))

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
MOD = 10 ** 9 + 7
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = SS()

    
    ans = 1
    cnt = collections.Counter(S)
    for i in cnt.values():
        ans *= (i + 1)
        ans %= MOD
    ans -= 1

    print(ans)

if __name__ == '__main__':
    resolve()

Solution (Python):
import collections

n = int(input())
a = input()
ans = 1
mod = 10**9+7
a = collections.Counter(a)
for v in a.values():
    ans *= (v+1) % mod
print((ans-1) % mod)

Solution (Python):
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
from math import sqrt
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7





N = getN()
S = input()

ans = 1



for i in Counter(S).items():
    ans *= (i[1] + 1) % mod
print((ans - 1) % mod)

Solution (Python):


import math

import itertools
from collections import deque
from collections import Counter

from fractions  import gcd

import bisect
n=int(input())
s=list(input())
c=Counter(s)
c=c.values()
ans=1
mod=10**9+7
for i in c:
    ans*=(i+1)
    ans%=mod
print(ans-1)

Solution (Python):
MOD = 10**9 + 7
N = int(input())
S = input()

X = {}

for s in S:
    if not(s in X):
        X[s] = 0

    X[s] += 1

ans = 1
for v in X.values():
    ans = ans*(v+1)%MOD

print((ans-1)%MOD)

Solution (Python):
import sys
input = sys.stdin.readline
N = int(input())
S = input()[: -1]
table = [S.count(chr(ord("a") + x)) for x in range(26)]
res = 1
mod = 10 ** 9 + 7
for x in range(26):
  res *= table[x] + 1
  res %= mod
print(res - 1)

Solution (Python):
from collections import Counter

N = int(input())
S = input()

d = Counter(S)

m = 10 ** 9 + 7

ans = 1
for k, v in d.items():
    ans = ans * (v + 1) % m
print((ans - 1) % m)

Solution (Python):
from collections import Counter

N = int(input())
S = input()
MOD = 10 ** 9 + 7
counter = Counter(S)
ans = 1
for e in counter.values():
    ans = ans * (e + 1) % MOD
print(ans - 1)

Solution (Python):
from collections import Counter

N = int(input())
S = input()
L = Counter(S)
MOD = 10**9 + 7

ans = 1
for k in L.keys():
    ans *= ((L[k]+1) % MOD)

print((ans-1)%MOD)

Solution (Python):
from collections import Counter
n = int(input())
S = input()
R = 1000000007


count = Counter(S)
ans = 1
for c in count.values():
    ans = ans * (c + 1) % R

print(ans - 1)

Solution (Python):

import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd, ceil



import string

from bisect import bisect_left
MOD = int(1e9)+7
INF = float('inf')


def solve():
    
    n = int(input())
    s = input()
    cnt = defaultdict(int)
    for e in s:
        cnt[e] += 1
    ans = 0
    for i in range(n):
        e = s[i]
        x = n - i - cnt[e]
        xd = 1
        cnt[e] -= 1
        for c in cnt:
            if cnt[c] and c != e:
                xd *= (cnt[c]+1)
        ans += xd
        ans %= MOD
    
    print(ans%MOD)

t = 1

for case in range(1,t+1):
    ans = solve()


"""

azyxwvutsrqponmlkjihgfedcb

"""

Solution (Python):
n = int(input())
s = input()
ans = 1
for x in set(s):
    ans *= s.count(x)+1
print((ans-1)%(10**9+7))

Solution (Python):
n = int(input())
s = input()
ans = 1
for x in set(s):
    ans *= s.count(x)+1
print((ans-1)%(10**9+7))

Solution (Python):
from collections import Counter
n = int(input())
s = list(input())
c = Counter(s)
ans = 1
for i in c.values():
    ans =  (ans * (i+1)) % 1000000007
print(ans-1)

Solution (Python):
from collections import Counter
n = int(input())
S = input()
mod = pow(10,9)+7
cS = Counter(list(S))
ans = 1
for key in cS.keys():
    ans *= (cS[key]+1)%mod
print((ans-1)%mod)

Solution (Python):
def count(l):
    res = {}
    for d in l:
        if d in res:
            res[d] += 1
        else:
            res[d] = 1
    return res

n = int(input())
string = input()
cnt = count(string)
mod = 10**9 + 7
ans = 1
for v in cnt.values():
    ans *= v + 1
    ans %= mod 
print(ans - 1)

Solution (Python):
import sys
from collections import Counter
sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    s = input()
    D = Counter(s)
    res = 1
    for v in D.values():
        res = res * (v + 1) % mod
    print(res - 1)


if __name__ == '__main__':
    resolve()

Solution (Python):
from collections import defaultdict
mod = 10**9+7
n = int(input())
s = list(input())
ans = 1
dd = defaultdict(lambda:0)
for i in s:
    dd[i] += 1
for key in dd:
    ans *= dd[key]+1
    ans %= mod
ans -= 1
print(ans)

Solution (Python):
n=int(input())
s=str(input())
s=list(s)
import collections
c=collections.Counter(s)
values, counts = zip(*c.most_common())
temp=list(counts)
l=len(temp)
ans=1
for i in range(l):
  ans=ans*(temp[i]+1)
print((ans-1)%(10**9+7))

Solution (Python):
n=int(input())
s=input()
mod=10**9+7
from collections import Counter

c=list(Counter(s).values())

ans=1

for i in c:
    ans*=(i+1)

print((ans-1)%mod)

Solution (Python):
N=int(input())
s=list(input())
from collections import Counter
d=Counter(s)
ans=1
for v in d.values():
  ans*=(v+1)
ans-=1
ans=ans%(10**9+7)
print(ans)

Solution (Python):
from collections import Counter

N = int(input())
S = input()

C = Counter(S)

res = 1
for v in C.values():
    res *= (v + 1)
    res %= 10 ** 9 + 7

print(res - 1)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
S = input()

ans = 1
for x in Counter(S).values():
	ans *= x+1
	ans %= mod
print((ans-1)%mod)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees, log2, log
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *
 
N = INT()
S = list(input())

cnt = Counter(S).values()

ans = 1
for x in cnt:
	ans = ans*(x+1)%mod

print((ans-1%mod))