n = sorted(input())
h = list(input())

def factorial(N):
    val = 1
    for i in range(len(N)):
        n = i + 1
        val = val * n
    return val

def calc(N, H):
    maxT = factorial(N)
    perms = []
    counter = 0
    for i in range(len(H)-len(N)+1):
        if len(perms) == maxT:
            return maxT
        tempL = H[i:i+len(N)]
        if tempL not in perms and sorted(tempL) == N:
            perms.append(tempL)
            counter += 1
    return counter

print(calc(n, h))