import sys from collections import OrderedDict S = input() T = input() # if len(T) == 1 and S.count(T) == 0: # print(-1) # sys.exit() if len(T) == 1 and S.count(T) != 0: print(S.count(T)) sys.exit() # cnt = S.count(T) # if len(T) == 1 and cnt == 0: # print(cnt) # elif len(T) == 1 and cnt != 0: # print(-1) # else: # print(cnt) # Z-algorithm # https://qiita.com/masayoshi361/items/1be110f13412f5431da2 # https://perogram.hateblo.jp/entry/z_algo_revisit # https://qiita.com/Pro_ktmr/items/16904c9570aa0953bf05 def Z_algo(S): n = len(S) LCP = [0]*n i = 1 j = 0 c = 0 # 最も末尾側までLCPを求めたインデックス for i in range(1, n): # i番目からのLCPが以前計算したcからのLCPに含まれている場合 if i+LCP[i-c] < c+LCP[c]: LCP[i] = LCP[i-c] else: j = max(0, c+LCP[c]-i) while i+j < n and S[j] == S[i+j]: j += 1 LCP[i] = j c = i LCP[0] = n return LCP # min_T = "".join(OrderedDict.fromkeys(T)) # print(min_T) # print(Z_algo(S)) z_results = Z_algo(T+S) # print(z_results) results = [x for x in z_results[len(T):] if x >= len(T)] print(len(results))