//Java版代码 import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String t = sc.next(); String p = sc.next(); int count = 0; int pos = 0; while (pos != -1) { pos = t.indexOf(p, pos); if (pos != -1) { count++; pos++; } } System.out.println(count); } } #Python版代码 import re t, p = input().split() pattern = '(?=' + p + ')' count = len(re.findall(pattern, t)) print(count)