#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include typedef long long ll; using namespace std; #ifndef LOCAL #define debug(x) ; #else #define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl; template ostream &operator<<(ostream &out, const pair &p) { out << "{" << p.first << ", " << p.second << "}"; return out; } template ostream &operator<<(ostream &out, const vector &v) { out << '{'; for (const T &item : v) out << item << ", "; out << "\b\b}"; return out; } #endif #define mod 1000000007 //1e9+7(prime number) #define INF 1000000000 //1e9 #define LLINF 2000000000000000000LL //2e18 #define SIZE 200010 /* KMP */ // A[i] := 文字列S[0,i-1]の接頭辞と接尾辞が最大何文字一致しているか (i-1未満) // len(A) == S.size() + 1 void KMP(const char *S, int *A){ A[0] = -1; int j = -1, n = strlen(S); for (int i = 0; i < n; i++) { while (j >= 0 && S[i] != S[j]) j = A[j]; j++; //KMP if (S[i+1] == S[j]) A[i+1] = A[j]; else A[i+1] = j; //MP //A[i+1] = j; } } char s[SIZE]; int main(){ int n, m, ans = 0; scanf("%s%d", s, &m); n = strlen(s); for(int i=0; i= 0; t = max(0, k[t]); } } ans += p[t] == '#'; } printf("%d\n", ans); return 0; }