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 = 0 
    (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 += 1
        else
            diff = 0 
            break
        end 
    end 
    num += 1 if diff == 2
end
p num