#ifdef Kaushal_26 #include #else #include using namespace std; #define clog if (0) cerr #define lvl(...) 42 #define dbg(...) 42 #endif #define int long long #define overload5(a, b, c, d, e, ...) e #define FORS(i, a, b, c) for(int i = (a); i < (int)(b); i += c) #define FOR1(i, a, b) for(int i = (a); i < (int)(b); ++i) #define F0R(i, a) for(int i = (0); i < (int)(a); ++i) #define ROFS(i, a, b, c) for(int i = (b) - 1; i >= (int)(a); i -= c) #define ROF1(i, a, b) for(int i = (b) - 1; i >= (int)(a); --i) #define R0F(i, a) for(int i = (a) - 1; i >= (int)(0); --i) #define FOR(...) overload5(__VA_ARGS__, FORS, FOR1, F0R)(__VA_ARGS__) #define ROF(...) overload5(__VA_ARGS__, ROFS, ROF1, R0F)(__VA_ARGS__) #define REP(i, x) for(auto &i : x) template auto V(const T& value, int size) { return vector(size, value); } template auto V(const T& value, int size, D... w) { auto W = V(value, w...); return vector(size, W); } template bool ckmin(T &a, const T b) { return b < a ? a = b, 1 : 0; } template bool ckmax(T &a, const T b) { return b > a ? a = b, 1 : 0; } bool ok(char a, char b) { if(a >= 'A' && a <= 'Z') a = a - 'A' + 'a'; if(b >= 'A' && b <= 'Z') b = b - 'A' + 'a'; return a == b; } int N, M , K; auto prefix_function(string s) { int n = (int)s.length(); vector pi(n); vector ip(n); for (int i = 1; i < n; i++) { if(i > M) ip[i] = ip[i - 1]; int j = pi[i-1]; while (j > 0 && !ok(s[i], s[j])) j = pi[j-1]; dbg(i, j, s[i], s[j]); if(i > M && s[i] != s[j]) ip[i]++; if (ok(s[i], s[j])) j++; pi[i] = j; } return make_pair(pi, ip); } void solve() { cin >> N >> M >> K; string a, b; cin >> a >> b; auto [p, q] = prefix_function(b + "#" + a); dbg(p, q); int ret = 0; FOR(i, M + 1, p.size()) { if(p[i] >= M && q[i] - q[i - M] <= K && q[i] - q[i - M] != 0) { ret++; dbg(i - M - 1); } } cout << ret << "\n"; } signed main() { cin.tie(0)->sync_with_stdio(0); #ifdef Kaushal_26 for(int TestCase = 1; ; TestCase++) { clog << endl; dbg(TestCase); solve(); } #else solve(); #endif return 0; } // 1.77245