sequence = input()
symbol = input()

def occ_check(seq, sym):
    let_count = 0
    dig_count = 0

    # The function needs to check whether the input symbol is a letter or number:
    if sym.isdigit(): # If the symbol is a number
        for char in seq:
            if char == sym:
                dig_count += 1
        return dig_count
    elif sym.isalpha(): # If the symbol is a letter
        sym = sym.lower() # Normalize the input letter to lowercase for easier matching
        for char in seq:
            if char.lower() == sym:
                let_count += 1
        return let_count

print(occ_check(sequence, symbol))