s = gets.chomp
t = gets.chomp
chars = s.split("").uniq

s_bits = chars.map do |c|
    bits = 0
    s.each_char.with_index do |x, i|
        bits |= (1 << i) if x == c
    end
    bits
end

t_bits = chars.map do |c|
    bits = 0
    t.each_char.with_index do |x, i|
        bits |= (1 << i) if x == c
    end
    bits
end

num = 0
mask = 2 ** t.size - 1
(s.size - t.size + 1).times do |i|
    diff_pos = {}
    (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
            diff_pos[z] = 1
        else
            diff_pos = nil
            break
        end
        break if diff_pos.size > 1
    end
    num += 1 if diff_pos && diff_pos.size == 1
end
p num