#include using namespace std; inline vector z_algorithm(const string &s) { int n = (int)s.length(); vector z(n); z[0] = n; for (int i = 1, l = 0, r = 0; i < n; i++) { if (i <= r) z[i] = min(r - i + 1, z[i - 1]); while (i + z[i] < n && s[z[i]] == s[i + z[i]]) z[i]++; if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1; } return z; } vector makeTable(string &s){ int n = s.size(); vector ret(n+1); ret[0] = -1; int j = -1; for(int i=0; i= 0 && s[i] != s[j]) j = ret[j]; ret[i+1] = ++j; } return ret; } vector kmp(string &str, string &word){ vector table = makeTable(word), ret; int m = 0, i = 0, n = str.size(); while(m + i < n){ if(word[i] == str[m+i]){ if(++i == (int)(word.size())){ ret.emplace_back(m); m += i - table[i]; i = table[i]; } } else{ m += i - table[i]; if(i > 0) i = table[i]; } } return ret; } int main() { string s, t; cin >> s >> t; int n = (int)s.size(), m = (int)t.size(); if (n < m) { cout << "0\n"; return 0; } if (m == 1) { for (int i = 0; i < n; i++) { if (s[i] == t[0]) { cout << "-1\n"; return 0; } } } auto res = kmp(s,t); int cur = 0, ans = 0; for (int i = 0; i < res.size(); i++) { if (cur <= res[i]) { cur = res[i] + m - 1; ans++; } } cout << ans << endl; return 0; }