from bisect import bisect_left
# 读取输入
K = int(input().strip())
S, c1, c2 = input().strip().split()
# 找到所有以c2结尾的字符位置
end_positions = [i for i, char in enumerate(S) if char == c2]
# 初始化计数器
count = 0
n = len(S)
# 遍历字符串,检查所有可能的子串
for start in range(n - K + 1):
if S[start] == c1: # 子串必须以c1开头
# 找到第一个以c2结尾且满足长度条件的位置
min_end = start + K - 1
idx = bisect_left(end_positions, min_end)
count += len(end_positions) - idx
# 输出结果
print(count)
0 回复
0 转发
0 喜欢
4 阅读



