#include using namespace std; #define ll long long void testcase() { ll n, q, ni; cin >> n >> q; string s, si; cin >> s; for(ll i = 0; i < q; ++i) { cin >> ni >> si; ll ans = 0; for(ll j = 0; j < n; ++j) { if(s[j] == si[0]) { bool here = true; ll skipped = 0; for(ll k = 1; k < ni; ++k) { while(s[k+j+skipped] == '.') skipped++; if(s[j+k+skipped] != si[k]) { here = false; break; } } if(here) { ans++; ll skipped = 0; for(ll k = 0; k < ni; ++k){ while(s[k + j + skipped] == '.') skipped++; s[j + k + skipped] = '.'; } } } } cout << ans << "\n"; } } int main() { testcase(); }