Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = []
    for i in range(N):
        s.append("".join(sorted(list(input().strip()))))
    s = sorted(s)
    
    tmp = []
    check = [False] * N
    ans = 0
    for i in range(N-1):
        count = 1
        for j in range(i+1, N):
            if not check[j]:
                ok = True
                for k in range(10):
                    if s[i][k] != s[j][k]:
                        ok = False
                        break
                if ok:
                    count += 1
                    check[j] = True
        if count > 1:
            tmp.append(count)
    
    ans = 0
    for n in tmp:
        ans += (n * (n-1))//2
    print(ans)


if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N = int(input())
    s = []
    for i in range(N):
        s.append("".join(sorted(list(input().strip()))))
    s = sorted(s)
    # print(s)
    tmp = []
    pre = s[0]
    count = 1
    for i in range(1, N):
        if s[i] == pre:
            count += 1
        else:
            if count > 1:
                tmp.append(count)
            count = 1
        if i == N-1:
            if count > 1:
                tmp.append(count)
        pre = s[i]
    ans = 0
    for n in tmp:
        ans += (n * (n-1))//2
    print(ans)


if __name__ == "__main__":
    main()
### BUGGY CODE ###

import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*M
C=[0]*M
for i in range(M):
    B[i],C[i]=map(int,input().split())

for i in range(M):
    A = np.sort(A)
    for j in range(B[i]):
        if A[j] < C[i]:
            A[j]=C[i]
        else:
            break
        if j==N-1:
            break
print(sum(A))      




### FIXED CODE ###

#!/usr/bin/env python3
import bisect
import numpy as np

N, M = list(map(int, input().split()))
a_list = list(map(int, input().split()))
bc_list = []

for i in range(M):
    b, c = list(map(int, input().split()))
    bc_list.append((b, c))

bc_list = sorted(bc_list, key=lambda x: x[1], reverse=True)
a_list = sorted(a_list)

fix_list = []
s = 0
b, c = bc_list[0]
bc_index = 0
count_b = 0

for a in a_list:
    if count_b >= b:
        bc_index += 1
        if bc_index >= len(bc_list):
            s += a
            continue
        count_b = 0
        b, c = bc_list[bc_index]

    if a < c:
        s += c
    else:
        s += a
    count_b += 1

ans = s
print(ans)
### BUGGY CODE ###

from math import factorial as step
n=int(input())
a=list(map(int,input().split()))
dic={}
sms={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]] += 1
  else:
    dic[a[i]] = 1

def ncr(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return step(n) // (step(r) * step(n-r))

for k,v in dic.items():
  sms[k] = ncr(v,2)
all=sum(sms.values())
for i in range(n):
  print(all-sms[a[i]]+ncr(dic[a[i]]-1,2))

### FIXED CODE ###

from math import factorial as step
n=int(input())
a=list(map(int,input().split()))
dic={}
for i in range(n):
  if a[i] in dic:
    dic[a[i]] += 1
  else:
    dic[a[i]] = 1

def ncr(n, r):
    if n < 0 or r < 0 or n - r < 0:
        return 0
    return step(n) // (step(r) * step(n-r))

# valueのncrのリストを作っておく
all = sum([ncr(v,2) for v in dic.values()])
for i in range(n):
  print(all-dic[a[i]]+1)
### BUGGY CODE ###

N = int(input())
A = list(map(int, input().split()))

ans = 1
for a in A:
    ans *= a

if ans > 10**18:
    print(-1)
else:
    print(ans)


### FIXED CODE ###

import sys
import numpy as np

N = int(input())
A = list(map(int, input().split()))

if len(np.where(np.array(A) == 0)[0]) != 0:
    print(0)
    sys.exit(0)

ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        sys.exit(0)

print(ans)
### BUGGY CODE ###

s = input()
n = len(s)
old_length=-1
for i in range(n):
  if old_length==len(s):
    break
  old_length=len(s)
  s=s.replace('01','').replace('10','').replace('01','').replace('10','')
print(n-len(s))

### FIXED CODE ###

s = input()
c1,c2=s.count('0'),s.count('1'),
print(min(c1,c2)*2)
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')] * 10 ** 5

dp[0] = 0
for i in range(1, N):
  tmp = i
  if tmp > K:
    tmp = K
  for j in range(1,tmp + 1):
      dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]))

print(dp[N-1])


### FIXED CODE ###

N,K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('inf')] * 10 ** 5

dp[0] = 0
for i in range(1, N):
  tmp = i
  if tmp > K:
    tmp = K
  for j in range(1,tmp + 1):
      dp[i] = min(dp[i], dp[i - j] + abs(h[i - j] - h[i]))

print(dp[N-1])
### BUGGY CODE ###

n,q = map(int,input().split())
imos = []
for i in range(n):
    s,t,x = map(int,input().split())
    imos.append((s-x,x))
    imos.append((t-x,-x))
ans = set()
j = 0
for i in range(q):
    d = int(input())
    imos.append((d,1e100))
imos.sort()
for t,stop in imos:
    if stop == 1e100:
        if ans:
            print(min(ans))
        else:
            print(-1)
    elif stop > 0:
        ans.add(stop)
    else:
        ans.remove(-stop)


### FIXED CODE ###

import sys
input = sys.stdin.readline

n,q = map(int,input().split())
imos = []
for i in range(n):
    s,t,x = map(int,input().split())
    imos.append((s-x,x))
    imos.append((t-x,-x))
ans = set()
j = 0
for i in range(q):
    d = int(input())
    imos.append((d,1e100))
imos.sort()
m = 1e100
flag = False
for t,stop in imos:
    if stop == 1e100:
        if ans:
            if not flag:
                m = min(ans)
                flag = True
            print(m)
        else:
            print(-1)
    elif stop > 0:
        ans.add(stop)
        if stop < m:
            m = stop
            flag = True
    else:
        ans.remove(-stop)
        if m == -stop:flag = False
### BUGGY CODE ###

s=input()
k=int(input())
uselist=[]
count=0
checker=0

alphabet="abcdefghijklmnopqrstuvwxyz"
while count<=5 and checker<=26:
    for i in alphabet:
        for j in range(len(s)):
            if s[j]==i:
                uselist.append((j,i))
                count+=1
        checker+=1
anslist=[]
for some in uselist:
    for j in range(some[0],len(s)):
        anslist.append(s[some[0]:j+1:])
anslist=sorted(set(anslist))
print(anslist[k-1])
    
    


### FIXED CODE ###

s=input()
k=int(input())
uselist=[]
count=0
checker=0
alphabet="abcdefghijklmnopqrstuvwxyz"
while count<=5 and checker<=26:
    for i in alphabet:
        for j in range(len(s)):
            if s[j]==i:
                uselist.append((j,i))
                count+=1
        checker+=1
anslist=[]
for some in uselist:
    count=0
    for j in range(some[0],len(s)):
        anslist.append(s[some[0]:j+1:])
        count+=1
        if count>5:
            break
            
anslist=sorted(set(anslist))

print(anslist[k-1])
### BUGGY CODE ###

'''
参考: https://beta.atcoder.jp/contests/agc026/submissions/2849460
'''

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

s_left = s[:n]
s_right = s[n:]
m = dict()

for i in range(1 << n):
    s_red, s_blue = '', ''
    for j in range(n):
        if i & (1 << j):
            s_red = s_red  + s_left[j]
        else:
            s_blue = s_left[j] + s_blue
    tpl = (s_red, s_blue)
    if tpl in m:
        m[tpl] += 1
    else:
        m[tpl] = 1

ans = 0
for i in range(1 << n):
    s_red, s_blue = '', ''
    for j in range(n):
        if i & (1 << j):
            s_red = s_right[j] + s_red
        else:
            s_blue = s_blue + s_right[j]
        tpl = (s_red, s_blue)
    if tpl in m:
        ans += m[tpl]
print(ans)


### FIXED CODE ###

def main():
    from collections import defaultdict

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

    L, R = S[:N], S[N * 2 - 1:N - 1:-1]

    def make_counter(s: str) -> defaultdict(int):
        ret = defaultdict(int)
        for bit in range(1 << N):
            red, blue = '', ''
            for j in range(N):
                if (bit >> j) & 1:
                    red += s[j]
                else:
                    blue += s[j]

            ret[red + '_' + blue] += 1
        return ret

    ld = make_counter(L)
    rd = make_counter(R)

    print(sum(ld[key] * rd[key] for key in ld))


if __name__ == '__main__':
    main()
### BUGGY CODE ###

nm = input().split()
n = int(nm[0])
m = int(nm[1])
X = input().split()
Y = input().split()
X = map(int, X)
X = list(X)
Y = map(int, Y)
Y = list(Y)
S = 0
for i in range(n - 1):
	for j in range(m - 1):
		s = (X[i + 1] - X[i]) * (Y[j + 1] - Y[j])
		s = (i + 1) * (n - i - 1) * (j + 1) * (m - j - 1) * s
		S += s
ans = S % 1000000007
print(ans)

### FIXED CODE ###

#設定
import sys
input = sys.stdin.buffer.readline

#ライブラリインポート
from collections import defaultdict

con = 10 ** 9 + 7
#入力受け取り
def getlist():
	return list(map(int, input().split()))

#処理内容
def main():
	N, M = getlist()
	x = getlist()
	y = getlist()
	X = 0
	Y = 0
	for i in range(N - 1):
		X += ((x[i + 1] - x[i]) * (i + 1) * (N - i - 1)) % con
		X %= con
	for i in range(M - 1):
		Y += ((y[i + 1] - y[i]) * (i + 1) * (M - i - 1)) % con
		Y %= con
	print(X * Y % con)


if __name__ == '__main__':
	main()
### BUGGY CODE ###

n = int(input())
an = list(map(int, input().split()))

from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcma = lcm_list(an)
ans = 0
for a in an:
    ans += lcma // a
mod=10**9+7
print(ans%mod)

### FIXED CODE ###

n = int(input())
an = list(map(int, input().split()))

from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

lcma = lcm_list(an)
ans = 0
for i in range(n):
    ans += (lcma//an[i])
mod=10**9+7
print(ans%mod)
### BUGGY CODE ###

from functools import reduce
from fractions import gcd
from collections import deque
N = int(input())
A = list(map(int, input().split()))

A_deque = deque(A)


def func_gcd(numbers):
    return reduce(gcd, numbers)

ans = 0
for _ in range(N):
    a = A_deque.popleft()
    ans = max(ans, func_gcd(A_deque))
    A_deque.append(a)

print(ans)

### FIXED CODE ###

N = int(input())
import fractions

a = list(map(int, input().split()))

gcd_start = [0]
gcd_end = [0]

ans = a[0]
gcd_start.append(ans)
for i in range(1, N-1):
    ans = fractions.gcd(ans, a[i])
    gcd_start.append(ans)

ans = a[-1]
gcd_end.append(ans)
for i in range(-2, -N, -1):
    ans = fractions.gcd(ans, a[i])
    gcd_end.append(ans)

ans_max = 0
for i in range(N):
    ans = fractions.gcd(gcd_end[-i-1], gcd_start[i])
    ans_max = max(ans, ans_max)

print(ans_max)
### BUGGY CODE ###

import numpy as np

n, nt = map(int, input().split())
ms = np.sort(np.array(list(map(int, input().split()))))
fs = np.sort(np.array(list(sorted(map(int, input().split())))))[::-1]
r = ms*fs

for i in range(nt):
  idx = np.argmax(r)
  if ms[idx] < 1:
    break
  ms[idx] -= 1
  r[idx] = ms[idx] * fs[idx]

print(np.max(ms*fs))

### FIXED CODE ###

import numpy as np
N, train_max = map(int, input().split())
members = np.sort(list(map(int, input().split())))
members_sum = members.sum()
foods = np.sort(list(map(int, input().split())))[::-1]

inferenced_time_max = int(1e+6 * 1e+6)
inferenced_time_min = -1

while inferenced_time_max > inferenced_time_min+1:
  inferenced_time = (inferenced_time_max + inferenced_time_min) // 2
  inferenced_members = np.minimum(members, inferenced_time // foods)
  if members_sum - inferenced_members.sum() <= train_max:
    inferenced_time_max = inferenced_time
  else:
    inferenced_time_min = inferenced_time

print(inferenced_time_max)
### BUGGY CODE ###

N = int(input())
abcde = [int(input()) for _ in range(5)]

# 移動者の状態
transferee = [N] + [0 for _ in range(5)]

# 毎ターンできる限りの人を次の都市に輸送
time = 0 # 現在時刻
while transferee[-1] != N:
    for i in range(0, 5)[::-1]:
        if transferee[i] - abcde[i] >= 0:
            transferee[i+1] += abcde[i]
            transferee[i] -= abcde[i]
        else:
            transferee[i+1] += transferee[i]
            transferee[i] = 0

    time += 1

print(time)

### FIXED CODE ###

import math

N = int(input())
abcde = [int(input()) for _ in range(5)]

# 交通機関のうち、最初の輸送可能乗客数を持つものに合わせる
X = min(abcde)
print(math.ceil(N / X) - 1 + 5)
### BUGGY CODE ###

def resolve():
    S = list(input())
    S.reverse()
    substr = ''
    p = ['dream', 'dreamer', 'erase', 'eraser']
    for i in S:
        substr = i + substr
        if substr in p:
            substr = ''
    ans = 'YES' if substr == '' else 'NO'
    print(ans)


if __name__ == "__main__":
    resolve()


### FIXED CODE ###

def resolve():
    S = list(input())
    S.reverse()
    substr = ''
    p = ['dream', 'dreamer', 'erase', 'eraser']
    for i in S:
        substr = i + substr
        if substr in p:
            substr = ''
    ans = 'YES' if substr == '' else 'NO'
    print(ans)


if __name__ == "__main__":
    resolve()
### BUGGY CODE ###

def main():
    MOD = 998244353

    N, S = map(int, input().split())
    A = tuple(map(int, input().split()))

    DP0 = [[0] * (S + 1) for _ in range(N + 1)]
    DP1 = [[0] * (S + 1) for _ in range(N + 1)]
    DP2 = [[0] * (S + 1) for _ in range(N + 1)]

    DP0[0][0] = 1

    for i in range(N):
        DP0[i + 1][0] = DP0[i][0] 
        DP1[i + 1][0] = DP0[i][0] + DP1[i][0]
        a = A[i]
        if a > S:
            for j in range(1, S + 1):
                DP1[i + 1][j] = DP1[i][j] #以前から合計jになっている場合のみOK
        else:
            for j in range(1, a):
                DP1[i + 1][j] = DP1[i][j] #以前から合計jになっている場合のみOK
            for j in range(a, S + 1):
                DP1[i + 1][j] = (DP1[i][j] + DP0[i][j - a] + DP1[i][j - a]) % MOD
                # DP[i + 1][j][1] = (DP[i][j][0] + DP[i][j][1] + DP[i + 1][j - a][1]) % MOD

        DP2[i + 1][S] = (DP1[i][S] + DP2[i][S])
        if a <= S:
            DP2[i + 1][S] += DP0[i][S - a] + DP1[i][S - a]
        DP2[i + 1][S] %= MOD

    print (DP2[N][S])

    # for i in range(N + 1):
    #     print (DP[i])

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    MOD = 998244353

    N, S = map(int, input().split())
    A = tuple(map(int, input().split()))

    DP0 = [[0] * (S + 1) for _ in range(N + 1)]
    DP1 = [[0] * (S + 1) for _ in range(N + 1)]
    DP2 = [[0] * (S + 1) for _ in range(N + 1)]

    DP0[0][0] = 1

    for i in range(N):
        DP0[i + 1][0] = DP0[i][0] 
        DP1[i + 1][0] = DP0[i][0] + DP1[i][0]
        a = A[i]
        if a > S:
            for j in range(1, S + 1):
                DP1[i + 1][j] = DP1[i][j] #以前から合計jになっている場合のみOK
        else:
            for j in range(1, a):
                DP1[i + 1][j] = DP1[i][j] #以前から合計jになっている場合のみOK
            for j in range(a, S + 1):
                DP1[i + 1][j] = (DP1[i][j] + DP0[i][j - a] + DP1[i][j - a]) % MOD
                # DP[i + 1][j][1] = (DP[i][j][0] + DP[i][j][1] + DP[i + 1][j - a][1]) % MOD

        DP2[i + 1][S] = (DP1[i][S] + DP2[i][S])
        if a <= S:
            DP2[i + 1][S] += DP0[i][S - a] + DP1[i][S - a]
        DP2[i + 1][S] %= MOD

    print (DP2[N][S])

    # for i in range(N + 1):
    #     print (DP[i])

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n = int(input())
height = [int(x) for x in input().split()]
cnt =0

for i_index, i in enumerate(height[:-1]):
    if i+i_index >= n:
        continue

    for j_index, j in enumerate(height[i_index+i+1:]):
        if j+i == j_index+i+1:
            cnt += 1
            # print(i,j,j_index)
            
print(cnt)

### FIXED CODE ###

# n = int(input())
# height = [int(x) for x in input().split()]
# cnt =0

# for i_index, i in enumerate(height[:-1]):
#     if i+i_index >= n:
#         continue

#     for j_index, j in enumerate(height[i_index+i+1:]):
#         if j+i == j_index+i+1:
#             cnt += 1
#             # print(i,j,j_index)
            
# print(cnt)
def count(dic,x):
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1
 
N=int(input())
A=list(map(int,input().split()))
dic1={}
dic2={}
s=0
for i in range(N):
    count(dic1,i-A[i])
    count(dic2,i+A[i])
for x in dic1:
    if x in dic2:
        s+=dic1[x]*dic2[x]
print(s)
### BUGGY CODE ###

import math

def main():
    N = int(input())
    S = input()
    
    r = 0
    for i in range(N):
        for j in range(i, N):
            for k in range(j, N):
                if (i+k)/2 == j:
                    continue
                if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
                    r += 1
    print(r)

if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import Counter
def main():
    n=int(input())
    s=input()
    d=Counter(s)
    a=d["R"]*d["G"]*d["B"]
    for i in range(n):
        t=min(n-i-1, i)
        for j in range(t+1):
            if s[i-j] != s[i] and s[i-j] != s[i+j] and s[i] != s[i+j]:
                a-=1
    print(a)
    
if __name__ == "__main__":
    main()
### BUGGY CODE ###

import numpy as np


def main(N, scores):
    M = N - 1
    def max_score(d):
        even_steps = [scores[i] for i in range(0, M - d, d)]
        odd_steps = [scores[i] for i in range(M, d, -d)]
        scores_at_even_steps = np.cumsum(even_steps)
        scores_at_odd_steps = np.cumsum(odd_steps)
        cum_scores = scores_at_even_steps + scores_at_odd_steps

        if M % d > 0:
            return max(cum_scores)
        else:
            k = M // d + 1
            return max(cum_scores[: k // 2])

    corner_case = scores[0] + scores[M]
    otherwise = max(max_score(d) for d in range(1, M))
    return max(corner_case, otherwise)


N = int(input())
scores = [int(a) for a in input().split()]
result = main(N, scores)

print(result)

### FIXED CODE ###

def cumsum(itr):
    arr = []
    val = 0
    for x in itr:
        val += x
        arr.append(val)
    return arr


def main(N, scores):
    M = N - 1

    def max_score(d):
        steps = (scores[i] + scores[-i - 1] for i in range(0, M - d, d))
        cum_scores = cumsum(steps)

        if M % d > 0:
            return max(cum_scores)
        else:
            k = M // d + 1
            return max(cum_scores[: k // 2])

    corner_case = scores[0] + scores[M]
    otherwise = max(max_score(d) for d in range(1, M))
    return max(corner_case, otherwise)


N = int(input())
scores = [int(a) for a in input().split()]
result = main(N, scores)

print(result)
### BUGGY CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m = map(int,readline().split())
data = list(map(int,read().split()))
ab = data[:2*m]
q = data[2*m]
vdc = data[2*m+1:]

links = [[] for _ in range(n+1)]
it = iter(ab)
for a,b in zip(it,it):
    links[a].append(b)
    links[b].append(a)

ans = [0] * (n+1)
length = [-1] * (n+1)

for i in range(q-1,-1,-1):
    v,d,c = vdc[i*3:i*3+3]
    if( length[v] >= d):
        continue

    stack = [(v,d)]
    while(stack):
        vj,dj = stack.pop()
        if(ans[vj]==0):
            ans[vj] = c
        if(dj > 0):
            for vk in links[vj]:
                if( length[vk] < dj-1):
                    stack.append((vk,dj-1))

print('\n'.join(map(str,ans[1:])))

### FIXED CODE ###

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n,m = map(int,readline().split())
data = list(map(int,read().split()))
ab = data[:2*m]
q = data[2*m]
vdc = data[2*m+1:]

links = [[] for _ in range(n+1)]
it = iter(ab)
for a,b in zip(it,it):
    links[a].append(b)
    links[b].append(a)

ans = [0] * (n+1)
length = [-1] * (n+1)

for i in range(q-1,-1,-1):
    v,d,c = vdc[i*3:i*3+3]
    if( length[v] >= d):
        continue
    length[v] = d

    stack = [(v,d)]
    while(stack):
        vj,dj = stack.pop()
        if(ans[vj]==0):
            ans[vj] = c
        if(dj > 0):
            for vk in links[vj]:
                if( length[vk] < dj-1):
                    stack.append((vk,dj-1))
                    length[vk] = dj-1

print('\n'.join(map(str,ans[1:])))
### BUGGY CODE ###

N,M = map(int, input().split())
arr = [int(input()) for _ in range(0,M)]

arr = [-1]+arr+[N+1]
from math import factorial

count = 0
memo = {}
for i in range(0,len(arr)-1):
    start,end = arr[i],arr[i+1]
    span = end - start - 2 # the first step is taken by a certain step (with no choice)
    if span < 0:
        count = 0 # impossible
        break 
    nptn = int(span/2)
    regional_count = 0

    for k in range(0,nptn+1):
        key = '{} {}'.format(span,k)
        if key in memo.keys():
            regional_count += memo[key]
        else:
            val = factorial(span-k) // factorial(k) // factorial(span-2*k)
            regional_count += val
            memo[key] = val
    
    if count == 0:
        count += regional_count
    else:
        count *= regional_count
print(count % 1000000007)

### FIXED CODE ###

N,M = map(int, input().split())
arr = [int(input()) for _ in range(0,M)]
MOD = 10**9 + 7
stairs = [True for _ in range(0,N+1)]
for x in arr:
    stairs[x] = False

dp = [0 for _ in range(0,N+1)]

dp[0] = 1 if 0 not in arr else 0
dp[1] = 1 if 1 not in arr else 0

for i in range(2,N+1):
    if dp[i-1] == 0 and dp[i-2] == 0:
        break
    if stairs[i-1]: dp[i] += dp[i-1]
    if stairs[i-2]: dp[i] += dp[i-2]

    dp[i] %= MOD

print(dp[-1] % MOD)
### BUGGY CODE ###

N = int(input())
print(len([n for n in range(1,N+1,2) if set(str(n))=={'3','5','7'}]))

### FIXED CODE ###

N = int(input())
 
def dfs(s):
    if int(s) > N:
        return 0
    r = 1 if all([i in s for i in '357']) else 0
    for c in '357':
        r += dfs(s+c)
    return r

print(dfs('0'))
### BUGGY CODE ###

def cmb(n, r, mod):#コンビネーションの高速計算　
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 2*10**7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

H,W,K=map(int,input().split())
ans=K*((g1[H+W]*g2[H+W-K])%mod)
ans%=mod
for i in range(K):
    p=((K-i)*(g1[H+W-(i+1)]*g2[(H+W-K)]%mod))%mod
    q=(H+W)*cmb(H+W-1,i,mod)+(((2*H*W)%mod)*cmb(H+W-2,i-1,mod))%mod
    ans+=p*((q*g1[i])%mod)
    ans%=mod
print(ans)


### FIXED CODE ###

mod=10**9+7
def mul(a,b):
    x,y=a,b
    return (x*y)%mod

H,W,K=map(int,input().split())
mod=10**9+7
ans=0
const=1
for i in range(H+W-1,H+W-K,-1):
    const=(const*i)%mod

inv=pow(H+W-1,mod-2,mod)
temp1=mul(H+W,mul((K*(K+1)//2)%mod,const))
const=mul(const,inv)
u=(K*(K**2-1))//6
u%=mod
temp2=mul(2*H*W,mul(u,const))
ans=(temp1+temp2)%mod
const=mul(const,H+W-1)
ans+=mul(K,mul(H+W,const))
ans%=mod
print(ans)
### BUGGY CODE ###

S=input()
count=0
while "BW" in S:
    S=S.replace("BW","WB",1)
    count+=1
print(count)

### FIXED CODE ###

S=input()
count=0
def sigma(i):
    a=[b for b in range(0,i+1)]
    return sum(a)
place=0
flag=0
start=0
for i in range(len(S)):
    if S[i]=="B":
        flag=1
    elif S[i]=="W":
        if flag == 1:
            count += 1
            place += i - start
        else:
            start+=1
ans=place-sigma(count-1)
print(ans)