s = gets.chomp
t = gets.chomp
chars = s.split("").uniq
hash = Hash[*(chars.zip((0..chars.size-1).to_a).flatten)]

s_bits = [0] * chars.size
s.each_char.with_index do |c, i|
    s_bits[hash[c]] |= (1 << i)
end

t_bits = [0] * chars.size
t.each_char.with_index do |c, i|
    next if !hash[c]
    t_bits[hash[c]] |= (1 << i)
end

num = 0 
mask = 2 ** t.size - 1 
(s.size - t.size + 1).times do |i| 
    diff = nil 
    (0..t_bits.size-1).each do |k| 
        x = t_bits[k]
        y = (s_bits[k] >> i) & mask
        z = x ^ y   
        next if z == 0
        if z & (z - 1) == 0
            if diff && diff != z
                diff = nil 
                break
            else
                diff = z 
            end 
        else
            diff = nil 
            break
        end 
    end 
    num += 1 if diff
end
p num