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):
def sub_count(S,N,M):
    S_dict,S_set = {},set()

    for i in range(N):
        if S[i] not in S_set:
            S_set.add(S[i])
            S_dict[S[i]] = 1
        else:
            S_dict[S[i]] += 1

    output = 1
    for s in S_set:
        output *= (S_dict[s]+1)
        output %= M
    output -= 1
    return output

def main():
    N = int(input())
    S = input()
    M = 10**9+7

    ans = sub_count(S,N,M)
    print(ans)

if __name__ == "__main__":
    main()

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

Solution (Python):
from collections import Counter

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

mod=10**9+7

ans=1
c=Counter(s)

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

print(ans-1)

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

mod = 10**9 + 7
res = 1
for k,v in dic.items():
    res *= v + 1
    res %= mod

print((res + mod - 1)%mod)

Solution (Python):
from collections import Counter
def myAnswer(N:int,S:list) -> int:
   counter = Counter(S)
   ans = 1
   for s in list(set(S)):
      ans *= counter[s] + 1

   return (ans - 1) % (10 ** 9 + 7)
def modelAnswer():
   return
def main():
   N = int(input())
   S = list(input())
   print(myAnswer(N,S))
if __name__ == '__main__':
   main()

Solution (Python):
from collections import Counter
mod=pow(10,9)+7
n=int(input())
s=input()
cs=Counter(s)
ans=1
for a in cs.values():
  ans*=a+1
  ans%=mod
print(ans-1)

Solution (Python):
from collections import Counter

n = int(input())
s = str(input())
d = Counter(s)
S = list(set(s))
ans = 1
for t in S:
    ans *= d[t] + 1
print((ans - 1) % (10** 9 + 7))

Solution (Python):
from collections import Counter

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

C = Counter(S)
count = 1
mod = 10**9 + 7
for i in C.values():
    count *= i+1
print((count-1)%mod)

Solution (Python):
from collections import Counter

n = int(input())
s = list(map(str, input().rstrip()))

c = Counter(s)

dp = 1
for x in c.values():
    dp = dp * (x + 1)

dp = (dp - 1) % (10 ** 9 + 7)

print(dp)

Solution (Python):
import sys


import math
import collections

import bisect
import itertools
import fractions

import copy
import heapq
import decimal

import queue

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))





def main():
    n = ni()
    s = input()

    c = collections.Counter(s)

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


if __name__ == '__main__':
    main()

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

c = collections.Counter(S)

ls = list(c.values())

ans = 1
for l in ls:
  ans *= (l+1)

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

Solution (Python):
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))



N = I()
S = list(input())

d = defaultdict(int)
for i in range(len(S)):
    d[S[i]] += 1

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

print(ans-1)

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

mod = 10**9+7

dic = {}
for i in range(N):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1

ans = 1
for key in dic:
    ans *= dic[key]+1
    ans %= mod

ans -= 1
print(ans)

Solution (Python):
N = int(input())
S = input()
from collections import Counter
c = Counter(S)
p = 10**9 + 7
result = 1
for v in c.values():
    result *= (v+1)
    result %= p
print((result - 1) % p)

Solution (Python):
from collections import Counter
n = int(input())
s = list(input())
C = Counter(s)
p = 1
for v in C.values():
    p = p * (v+1) % (10**9 +7)

print(p-1)

Solution (Python):
alphabetlist=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

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

dic={moji:0 for moji in alphabetlist}
for i in range(N):
    dic[S[i]]+=1

ans=1
mod=10**9+7
for moji in dic:
    ans*=dic[moji]+1
    ans%=mod

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

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

Solution (Python):
from collections import defaultdict

N = int(input())
S = input()
Q = int(1e9 + 7)

d = defaultdict(int)

for s in S:
    d[s] += 1

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

Solution (Python):
n=int(input())
ss=list(input())
mod=10**9+7
import collections

"""
ss=[s[0]]

for i in range(1,n):
    if s[i]!=s[i-1]:
        ss.append(s[i])
"""


c = collections.Counter(ss)

result=1
for k in c.keys():
    result=result*(c[k]+1)%mod

print((result-1)%mod)

Solution (Python):
from collections import defaultdict
N = int(input())
S = input()
mod = 10 ** 9 + 7
d = defaultdict(int)
char = [chr(ord("a") + i) for i in range(26)]
ans = 1
for s in S:
    d[s] += 1
for v in d.values():
    ans *= v + 1
    ans %= mod
print(ans - 1)

Solution (Python):
from collections import Counter

N = int(input())
S = input()
SC = Counter(S)
mod = 10**9 + 7
ans = 1
for key, value in SC.items():
    ans *= (value+1)
    ans %= mod
print(ans-1)

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

s_c = Counter(s)

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

Solution (Python):
from collections import Counter
N = 1000000007
n = int(input())
s = input()
c = Counter(s)
k = c.keys()
ans = 1
for i in k:
    ans *= (c[i]+1)
    ans %= N
if ans!=0:
    ans -= 1
print(ans)

Solution (Python):
from collections import Counter

def solve():
    N = int(input())
    S = input()
    
    c = Counter(S)
    
    ans = 1
    for v in c.values():
        ans = ans*(v+1) % (10**9+7)
    return (ans-1) % (10**9+7)

print(solve())

Solution (Python):
import sys
input = sys.stdin.readline
n = int(input())
s = input().rstrip()
mod = 10**9+7

from collections import Counter
c = Counter(s)
ans = 0
for i in s:
  chk = 1
  for j,v in c.items():
    if j == i:
      continue
    chk *= v+1
  ans += chk
  ans %= mod
  c.update({i:-1})
  
print(ans%mod)

Solution (Python):
n = int(input())
s = str(input())

MOD = 10**9 + 7
s_d = {}
for curr_s in s:
    s_d.setdefault(curr_s,0)
    s_d[curr_s] += 1

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

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

Solution (Python):

import numpy as np

N,S = int(input()),input()
count = np.zeros(26)

for i in range(N):
    count[ord(S[i])-ord('a')] += 1

ans = 1
D =10**9+7

for i in range(26):
    ans = int((ans*(count[i]+1))%D)

print(ans-1)

Solution (Python):



"""
愚直に考えると、
各文字について、部分列に入れるか入れないか判断し、できた部分列について重複がないか判定する。
部分列作成部分だけで2^Nかかるので、到底間に合わない。

同一の部分列であっても、切り出した位置が異なれば違うものとして扱うので、例えばaaabがあったとき、a__b, _a_b, __abはいずれもabだが、それぞれカウントする。
なので上の例のabについては、（aの個数）x（bの個数）という計算になる。
こんな感じで考えると、それぞれの文字について、
・文字XXXを部分列にいれるか入れないか
・入れるのであれば、どの位置のXXXをぶぶんれつにいれるか
の 個数＋１の選択肢があるから、これの累積積をMODの世界でとっていけばよい

いずれの文字についても選ばない場合（部分列が空文字になる）も存在するので、その分は除く
"""


N = int(input())
S = input()
MOD = 10**9 + 7
from collections import Counter
c = Counter(S)
ans = 1

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

print(ans-1)

Solution (Python):
from collections import Counter
_=input()
s=list(Counter(list(input())).values())
mod=10**9+7
dp=[0]*len(s)
dp[0]=s[0]
for i in range(1,len(s)):
  dp[i]=dp[i-1]*(s[i]+1)+s[i]
print(dp[-1]%mod)

Solution (Python):
from collections import Counter

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


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

Solution (Python):
def main():
  from collections import Counter
  n = int(input())
  s = input()
  mod = 10**9+7
  c = Counter(s)
  cv = list(c.values())
  cl = len(cv)
  ans = 1
  for i in range(cl):
    ans *= (cv[i]+1)
  print((ans-1)%mod)
main()

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

Solution (Python):
from collections import Counter
N=int(input())
S=input()
mod = 10**9+7
d = Counter(S)
ans = 0
for i in S:
    tmp = 1
    d[i] -=1
    for k,v in d.items():
        if i!=k and v:
            tmp *=(v+1)
            tmp%=mod
    ans += tmp
    ans %=mod
print(ans)

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

import collections
c=collections.Counter(s)
c=c.most_common()

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

Solution (Python):
from collections import Counter

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

cnt = Counter(S)

slist = "abcdefghijklmnopqrstuvwxyz"
ans = 1
for s in slist:
    ans *= cnt[s] + 1

ans -= 1

ans = ans % MOD

print(ans)

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

Solution (Python):
import collections
mod = 10**9 + 7
N = int(input())
S = input()

C = collections.Counter(S)

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

print(ans-1)

Solution (Python):
from collections import Counter
n = int(input())
s = input()
mod = 10**9 + 7
ans = 1
scnt = Counter(s)
for cnt in scnt.values():
    ans = ans*(cnt+1) % mod

print(ans-1)

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

Solution (Python):
from collections import Counter


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


"""
異なる位置から取り出されたものは、同じものがあっても区別する
→各S[i]を入れるか入れないかみたいな話 : 2^N
→たとえば文字aについて、aが複数Sに入っていても、一つしか使えないが、使ったaが異なるなら出来上がりの部分列も区別する
→aを使わないorいずれかのaを一つだけ使う
"""

c = Counter(S)
ans = 1
MOD = 10**9 + 7
for v in c.values():
    ans *= v+1
    ans %= MOD

ans -= 1 
print(ans)

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

from collections import Counter

c = Counter(s)

ans = 1
for k,v in c.items():
    ans *=(v+1)%p

ans -=1
print(ans%p)

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

from collections import Counter

c = Counter(list(s))

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

print(res - 1)

Solution (Python):
from _collections import defaultdict
n=int(input())
S=input()
X=defaultdict(int)
for s in S:
    X[s]+=1
ans=1
for v in X.values():
    ans*=(v+1)
print((ans-1)%(10**9+7))

Solution (Python):
from collections import Counter

n = int(input())
S = input()
counts = Counter(S)
mod = int(1e9) + 7
ans = 1
for count in counts.values():
    ans *= (count + 1)
    ans %= mod
ans -= 1
print(ans)

Solution (Python):
from collections import Counter

if __name__ == '__main__':
    n = int(input())
    s = list(input())
    s = Counter(s)
    s = s.most_common()
    ans = 1

    for k, v in s:
        if v > 1:
            ans *= v + 1
        else:
            ans *= 2
        ans %= (10 ** 9 + 7)

    print(ans - 1)

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

    cc = collections.Counter(S)
    output = 1
    for k in cc.keys():
        output *= (cc[k] + 1)
        output %= MOD
    print(output-1)
    return

if __name__ == '__main__':
    main()

Solution (Python):
n=int(input())
s=input()
mod = 1e9+7
ans = [1]*30
for c in s:
    ans[ord(c)-ord('a')]+=1
res = 1
for i in range(29):
    res *= ans[i]
    res %= mod
print(int((res-1)%mod))

Solution (Python):
from collections import Counter
import itertools as it
MOD = 10 ** 9 + 7
n = int(input())
s = input()

b = Counter(s)
c = list(b)

ans = 1
for i in b:
    ans = ans * (b[i]+1) % MOD
    
print((ans + MOD - 1) % MOD)

Solution (Python):
from collections import Counter

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

cnt = Counter(list(s))
ans = 1
for v in cnt.values():
    ans *= v + 1
    ans %= MOD
print(ans - 1)

Solution (Python):



def main():
  MAX = 10**9 + 7
  counts = [0] * 26
  
  n = int(input())
  dp = [[0]*2 for _ in range(26)] 
  for c in list(input().strip()):
    counts[ord(c) - 97] += 1
    
  dp[0][0] = 1
  dp[0][1] = counts[0]
  for i, count in enumerate(counts[1:], 1):
    if count == 0:
      dp[i] = dp[i-1]
      continue
    dp[i][0] = sum(dp[i-1]) % MAX
    dp[i][1] = (dp[i][0] * counts[i]) % MAX
  
  print((sum(dp[-1]) - 1) % MAX)

if __name__=='__main__':
  main()

Solution (Python):

import sys
from collections import Counter

def main():
    N = int(input())
    S = input()
    L = Counter(S)
    p = 10**9 + 7
    ans = 1
    for l in L.items():
        ans =  ans * (l[1] + 1) % p
    print((ans - 1) % p)

if __name__ == '__main__':
    main()

Solution (Python):
from collections import defaultdict
mod = 10**9 + 7
n = int(input())
d = defaultdict(int)
for c in list(input()):
    d[c] += 1

res = 1
for c in d:
    res *= (d[c]+1)
    res %= mod
res = res + mod - 1
res %= mod
print(res)

Solution (Python):
n = int(input())
s = input()
dic = {}
for i in range(n):
  if s[i] in dic:
    dic[s[i]] += 1
  else:
    dic[s[i]] = 1
ans = 1
for v in dic.values():
  ans *= (1 + v)
  ans %= 10**9 + 7
ans -= 1
print(ans)

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

ans=1
for i in S.values():
    ans *=i+1
print((ans-1)%(10**9+7))

Solution (Python):

N = int(input())
S = input()
s = set(S)
s_count = [S.count(c) + 1 for c in s]

tmp = 1
for i in s_count:
    tmp *= i

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

Solution (Python):
n = int(input())
s = input()
from collections import Counter
c = dict(Counter(s))
ans = 0
for i in c:
    ans *= c[i]+1
    ans += c[i]
print(ans%(10**9+7))

Solution (Python):

import collections
n = int(input())
s = list(input())

ans = 1
c = collections.Counter(s)
for i in set(s):
    ans *= (c[i] + 1)
print((ans - 1) % (pow(10, 9) + 7))

Solution (Python):
n = int(input())
s = input()
li_s = list(s)

import collections
c = collections.Counter(li_s)
cci = c.items()

tmp = 1
for cc in cci:
    
    tmp *= (cc[1]+1)
print((tmp-1)%(10**9+7))

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import Counter

n = int(readline())
s = list(readline().rstrip().decode())
ans = 1
mod = 10 ** 9 + 7
for v in Counter(s).values():
    ans *= v + 1
    ans %= mod
print((ans - 1) % mod)

Solution (Python):
from collections import defaultdict
n=int(input())
s=input()
mod=pow(10,9)+7
sd=defaultdict(lambda:1)
for i in range(n):
      sd[s[i]]+=1
ans=1
for k in sd.keys():
      ans*=(sd[k])%mod
print(ans%mod-1)

Solution (Python):
mod = 10**9+7
n = int(input())
s = input()
d = {}
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
result = 1
for i, j in d.items():
    result = (result*(j+1))%mod

print((result-1)%mod)

Solution (Python):
mod = 10**9+7
n = int(input())
s = input()
d = {}
for i in s:
    if i in d:
        d[i] += 1
    else:
        d[i] = 1
result = 1
for i, j in d.items():
    result = (result*(j+1))%mod

print((result-1)%mod)

Solution (Python):
n=int(input())
s=input()
import collections
c = collections.Counter(s)

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

Solution (Python):
from collections import Counter

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

c = Counter(S)
ans = 1

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

print((ans-1)%MOD)

Solution (Python):
import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    _ = rl()
    S = input()
    MOD = 10 ** 9 + 7
    
    counter = defaultdict(int)
    for si in S:
        counter[si] += 1
    
    ans = 1
    s = set(S)
    for si in s:
        ans = ans * (counter[si] + 1) % MOD
    ans -= 1
    print(ans)


if __name__ == '__main__':
    solve()

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

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

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

Solution (Python):
from collections import Counter
N = int(input())
S = input()
MOD = 10**9+7
c = Counter(S)
ans = 1
for k in c.keys():
  ans *= (c[k]+1)
  ans %= MOD
print(ans-1)

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

table = collections.defaultdict(int)
for i in range(N):
    table[S[i]] += 1
ans = 1
mod = 10**9 + 7
alpha = 'abcdefghijklmnopqrstuvwxyz'
for x in alpha:
    ans *= table[x] + 1
    ans %= mod

print((ans-1) % mod)

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

dic = {s[0]:1}
ans = 1
for i in range(1,n):
    if s[i] not in dic:
        ret = 1
        for v in dic.values():
            ret *= v + 1
            ret %= MOD
        ans += ret
        dic[s[i]] = 1
    else:
        ret = 1
        for k,v in dic.items():
            if k == s[i]:
                continue
            else:
                ret *= v + 1
                ret %= MOD
        ans += ret
        dic[s[i]] += 1
    ans %= MOD
print(ans)

Solution (Python):
from collections import Counter
N = int(input())
S = input()
ans = 0
mod = 10 ** 9 + 7
c = Counter(S)
for k in S:
    n = 1
    for i in range(ord("a"), ord("z") + 1):
        i = chr(i)
        if i in c and i != k:
            n *= c[i] + 1
            n %= mod
    ans = (ans + n) % mod
    c[k] -= 1
print(ans)

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

dct = dict(collections.Counter(S))

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

Solution (Python):

from collections import Counter, deque 












import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N=int(input())
    S=str(input())

    SS=Counter(S)

    ans=1
    for i in SS.values():
        ans*=(i+1)
    print((ans-1)%(10**9+7))

resolve()

Solution (Python):
n=int(input())
s=input()

n2a = lambda c: chr(c+64).lower()
al=[]
for i in range(1,27):
  c=s.count(n2a(i))
  if c!=0:
    al.append(c)
def func(nums):
  if len(nums)==1:
    return nums[0]%(10**9+7)
  elif len(nums)==2:
    return (nums[0]+nums[1]+nums[0]*nums[1])%(10**9+7)
  else:
    num=func(nums[1:])
    return (nums[0]+num+nums[0]*num)%(10**9+7)
print(func(al))

Solution (Python):
MOD = 1000000007

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

cnt = {}
for s in S:
    if s not in cnt:
        cnt[s] = 1
    else:
        cnt[s] += 1

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

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, acos, atan, asin, log, log10
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
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(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()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]
debugmode = True

n = INT()
s = list(STR())
t = list(set(s))
u = Counter(s)
v = []
for i in t:
    v.append(u[i] + 1)
ans = 1
for i in range(len(t)):
    ans *= v[i]
    ans %= mod
ans -= 1
print(ans % mod)

Solution (Python):

import collections
n = int(input())
s = list(input())

ans = 1
c = collections.Counter(s)
for i in set(s):
    ans *= (c[i] + 1)
print((ans - 1) % (pow(10, 9) + 7))

Solution (Python):
from collections import Counter

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

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

print(ans - 1)

Solution (Python):
n = int(input())
s = input()
mod = 10**9+7
cnt = {}
for x in s:
    if x not in cnt:cnt[x] = 1
    else:cnt[x] +=1
ans = 1
for key in cnt:
    v = cnt[key]
    ans *=(v+1)%mod
    ans %=mod
ans -= 1
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]




from collections import Counter
N = ii()
S = input()
l = Counter(S)
mod = 10**9+7

if len(l) == 1:
    print(N)
    exit()

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

print((ans-1) % mod)

Solution (Python):
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]




from collections import Counter
N = ii()
S = input()
l = Counter(S)
mod = 10**9+7

if len(l) == 1:
    print(N)
    exit()

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

print((ans-1) % mod)

Solution (Python):
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import Counter
    input = sys.stdin.readline

    N = int(input())
    S = input().rstrip('\n')

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


if __name__ == '__main__':
    main()

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

from collections import Counter

c = Counter(S)

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

Solution (Python):
import collections

count = collections.Counter
mod = 1000000007

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

    valuelist = list(count(S).values())
    ans = 1
    for v in valuelist:
        ans = (ans * (v + 1))%mod

    ans -= 1

    print(ans)


if __name__ == "__main__":
    main()

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

dict = {ch: 0 for ch in 'abcdefghijklmnopqrstuvwxyz'}
for i in range(n):
    dict[s[i]] += 1

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

Solution (Python):
from collections import Counter
MOD = 10**9 + 7
n = int(input())
c = Counter(input())
ans = 1
for k,v in c.items():
  ans = (ans*(v+1)) % MOD
  
print(ans-1)

Solution (Python):
from math import factorial
from collections import Counter
p=10**9+7

N=int(input())
S=input()
T=list(S)
d=dict(Counter(T))

var=1
for num in d:
  var = var*(d[num]+1) %p

print(var-1)

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

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

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

S = Counter(s)
a = 1
for v in S.values():
    a = a*(1+v) % mod

print(a-1)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, 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
from fractions import gcd
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

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

Solution (Python):
n = int(input())
s = list(input())
mod = 10 ** 9 + 7
alph_count = [0] * 200
ans = 0
for i in s:
    m = ord(i)
    alph_count[m] += 1
    c = 1
    for j in range(97, 123):
        if not m == j:
            c *= alph_count[j] + 1
        c %= mod
    ans += c
    ans %= mod
print(ans)

Solution (Python):
def resolve():
    '''
    code here
    '''
    import sys
    N = int(input())
    S = sys.stdin.readline().strip()
    mod = pow(10, 9) + 7
    set_S = set([item for item in S])
    res = 1

    for s in set_S:
        cnt = 1
        for letter in S:
            if s == letter:
                cnt += 1
        res *= cnt
        res %= mod

    mod = pow(10, 9) + 7
    print(res-1)

if __name__ == "__main__":
    resolve()

Solution (Python):
from collections import defaultdict
mod = pow(10, 9) + 7
N = int(input())
S = input()
d = defaultdict(int)
for s in S:
  d[s] += 1
ans = 1
for c in d:
  ans *= (d[c] + 1)
  ans %= mod
print(ans - 1)

Solution (Python):
from collections import defaultdict
N = int(input())
S = input()
d = defaultdict(int)
for s in S:
  d[s] += 1
ans = 1
for c in d:
  ans *= (d[c] + 1)
mod = pow(10, 9) + 7
print((ans - 1) % mod)

Solution (Python):
import collections

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

MOD = 10 ** 9 + 7
c = collections.Counter(S)
ans = 1
for k, v in c.items():
    ans *= v + 1
    ans %= MOD

ans -= 1
print(ans)

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

Solution (Python):
from collections import Counter
mod = 10**9 + 7
n = int(input())
s = [i for i in input()]
cnt = Counter(s)
l = len(cnt)
val = list(cnt.values())
val = [i + 1 for i in val if i != 1]
ans = 2**(l-len(val)) % mod
for vi in val: ans *= vi % mod
print((ans - 1) % mod)

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

Solution (Python):
from collections import Counter
from functools import reduce


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

    c = Counter(s)
    ans = reduce(lambda x, y: x * y, map(lambda x: x + 1, c.values())) - 1
    print(ans % (10**9+7))


if __name__ == "__main__":
    main()

Solution (Python):
import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

from collections import defaultdict

n = ni()
s = ns()

dic = defaultdict(lambda: 1)
for i in range(n):
    dic[s[i]] += 1

ans = 1
for k, v in dic.items():
    ans *= v
    ans %= mod

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

Solution (Python):
import collections
N=int(input())
S=list(input())
l=[]
c=collections.Counter(S)
num=1
p=10**9+7
values=list(c.values())	
key=list(c.keys())	
for i in range(len(key)):
    l.append([key[i],values[i]])

for i in range(len(l)):
    num=num*(l[i][1]+1)
print((num-1)%p)

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

d=dd(int)
for ss in s:
    d[ss]+=1

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

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

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

Solution (Python):

from collections import Counter
n = int(input())
a = Counter(input())
ans = 1
for v,c in a.items(): ans = ans * (1+c)%1000000007
print(ans-1)

Solution (Python):



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


word_dic = {}
ans = 1
INF = 10**9 + 7


for s in S:
    if not s in word_dic:
        word_dic[s] = 1
    else:
        word_dic[s] += 1


for w in word_dic:
    tmp = word_dic[w]
    ans = (ans * (tmp + 1))%INF
ans -= 1
print(ans % INF)

Solution (Python):






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

Solution (Python):
from collections import Counter

mod = 10 ** 9 + 7
n = int(input())
s = input()
d = Counter(s)
res = 1
for v in d.values():
    res = res * (v + 1) % mod

print(res - 1)

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

n = int(input())
s = input().rstrip()

from collections import Counter

c = Counter(s)

n_ = len(c.keys())

ans = 1

for i in c.keys():
    ans *= (c[i] + 1)
    ans %= mod

ans -= 1

print(ans)