#include using namespace std; using ll = long long; using P = pair; #define rep(i, a, b) for(ll i = a; i < b; ++i) #define rrep(i, a, b) for(ll i = a; i >= b; --i) constexpr ll inf = 4e18; struct SetupIO { SetupIO() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(30); } } setup_io; template vector z_algorithm(const vector& s) { int n = (int)s.size(); if(n == 0) return {}; vector z(n); z[0] = 0; for(int i = 1, j = 0; i < n; ++i) { int& k = z[i]; k = (j + z[j] <= i) ? 0 : min(j + z[j] - i, z[i - j]); while(i + k < n and s[k] == s[i + k]) ++k; if(j + z[j] < i + z[i]) j = i; } z[0] = n; return z; } vector z_algorithm(const string& s) { int n = (int)s.size(); vector s2(n); for(int i = 0; i < n; ++i) { s2[i] = s[i]; } return z_algorithm(s2); } template struct StaticModint { using mint = StaticModint; static constexpr uint32_t mod() { return m; } static constexpr mint raw(uint32_t v) { mint a; a._v = v; return a; } constexpr StaticModint() : _v(0) {} template constexpr StaticModint(const T& v) { static_assert(is_integral_v); if constexpr(is_signed_v) { int64_t x = int64_t(v % int64_t(m)); if(x < 0) x += m; _v = uint32_t(x); } else _v = uint32_t(v % m); } constexpr uint32_t val() const { return _v; } constexpr mint& operator++() { return *this += 1; } constexpr mint& operator--() { return *this -= 1; } constexpr mint operator++(int) { mint res = *this; ++*this; return res; } constexpr mint operator--(int) { mint res = *this; --*this; return res; } constexpr mint& operator+=(mint rhs) { if(_v >= m - rhs._v) _v -= m; _v += rhs._v; return *this; } constexpr mint& operator-=(mint rhs) { if(_v < rhs._v) _v += m; _v -= rhs._v; return *this; } constexpr mint& operator*=(mint rhs) { return *this = *this * rhs; } constexpr mint& operator/=(mint rhs) { return *this *= rhs.inv(); } constexpr mint operator+() const { return *this; } constexpr mint operator-() const { return mint{} - *this; } constexpr mint pow(long long n) const { assert(0 <= n); if(n == 0) return 1; mint x = *this, r = 1; while(1) { if(n & 1) r *= x; n >>= 1; if(n == 0) return r; x *= x; } } constexpr mint inv() const { if constexpr(prime) { assert(_v); return pow(m - 2); } else { auto eg = inv_gcd(_v, m); assert(eg.first == 1); return eg.second; } } friend constexpr mint operator+(mint lhs, mint rhs) { return lhs += rhs; } friend constexpr mint operator-(mint lhs, mint rhs) { return lhs -= rhs; } friend constexpr mint operator*(mint lhs, mint rhs) { return uint64_t(lhs._v) * rhs._v; } friend constexpr mint operator/(mint lhs, mint rhs) { return lhs /= rhs; } friend constexpr bool operator==(mint lhs, mint rhs) { return lhs._v == rhs._v; } friend constexpr bool operator!=(mint lhs, mint rhs) { return lhs._v != rhs._v; } friend istream& operator>>(istream& in, mint& x) { long long a; in >> a; x = a; return in; } friend ostream& operator<<(ostream& out, const mint& x) { return out << x.val(); } private: uint32_t _v = 0; static constexpr bool prime = []() -> bool { if(m == 1) return 0; if(m == 2 or m == 7 or m == 61) return 1; if(m % 2 == 0) return 0; uint32_t d = m - 1; while(d % 2 == 0) d /= 2; for(uint32_t a : {2, 7, 61}) { uint32_t t = d; mint y = mint(a).pow(t); while(t != m - 1 && y != 1 && y != m - 1) { y *= y; t <<= 1; } if(y != m - 1 && t % 2 == 0) return 0; } return 1; }(); static constexpr pair inv_gcd(int32_t a, int32_t b) { if(a == 0) return {b, 0}; int32_t s = b, t = a, m0 = 0, m1 = 1; while(t) { const int32_t u = s / t; s -= t * u; m0 -= m1 * u; swap(s, t); swap(m0, m1); } if(m0 < 0) m0 += b / s; return {s, m0}; } }; using modint998244353 = StaticModint<998244353>; using modint1000000007 = StaticModint<1000000007>; constexpr ll pow_mod(ll x, ll n, ll mod) { assert(n >= 0 and mod >= 1); x %= mod; if(x < 0) x += mod; ll res = 1; while(n > 0) { if(n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } constexpr int primitive_root(int m) { if(m == 2) return 1; if(m == 167772161) return 3; if(m == 469762049) return 3; if(m == 754974721) return 11; if(m == 998244353) return 3; int divs[20] = {}; divs[0] = 2; int cnt = 1; int x = (m - 1) / 2; while(x % 2 == 0) x /= 2; for(int i = 3; (long long)(i)*i <= x; i += 2) { if(x % i == 0) { divs[cnt++] = i; while(x % i == 0) { x /= i; } } } if(x > 1) { divs[cnt++] = x; } for(int g = 2;; ++g) { bool ok = true; for(int i = 0; i < cnt; ++i) { if(pow_mod(g, (m - 1) / divs[i], m) == 1) { ok = false; break; } } if(ok) return g; } } constexpr int countr_zero(unsigned int n) { int res = 0; while(!(n & (1 << res))) ++res; return res; } template struct FFT_Info { static constexpr int rank2 = countr_zero(mint::mod() - 1); array root; array iroot; array rate2; array irate2; array rate3; array irate3; FFT_Info() { root[rank2] = mint(g).pow((mint::mod() - 1) >> rank2); iroot[rank2] = root[rank2].inv(); for(int i = rank2 - 1; i >= 0; --i) { root[i] = root[i + 1] * root[i + 1]; iroot[i] = iroot[i + 1] * iroot[i + 1]; } { mint prod = 1, iprod = 1; for(int i = 0; i <= rank2 - 2; ++i) { rate2[i] = root[i + 2] * prod; irate2[i] = iroot[i + 2] * iprod; prod *= iroot[i + 2]; iprod *= root[i + 2]; } } { mint prod = 1, iprod = 1; for(int i = 0; i <= rank2 - 3; ++i) { rate3[i] = root[i + 3] * prod; irate3[i] = iroot[i + 3] * iprod; prod *= iroot[i + 3]; iprod *= root[i + 3]; } } } }; template void butterfly(vector& a) { int n = (int)a.size(); int h = __builtin_ctz((unsigned int)n); static const FFT_Info info; int len = 0; while(len < h) { if(h - len == 1) { int p = 1 << (h - len - 1); mint rot = 1; for(int s = 0; s < (1 << len); ++s) { int offset = s << (h - len); for(int i = 0; i < p; ++i) { auto l = a[i + offset]; auto r = a[i + offset + p] * rot; a[i + offset] = l + r; a[i + offset + p] = l - r; } if(s + 1 != (1 << len)) rot *= info.rate2[__builtin_ctz(~(unsigned int)(s))]; } ++len; } else { int p = 1 << (h - len - 2); mint rot = 1, imag = info.root[2]; for(int s = 0; s < (1 << len); ++s) { mint rot2 = rot * rot; mint rot3 = rot2 * rot; int offset = s << (h - len); for(int i = 0; i < p; ++i) { auto mod2 = 1ULL * mint::mod() * mint::mod(); auto a0 = 1ULL * a[i + offset].val(); auto a1 = 1ULL * a[i + offset + p].val() * rot.val(); auto a2 = 1ULL * a[i + offset + 2 * p].val() * rot2.val(); auto a3 = 1ULL * a[i + offset + 3 * p].val() * rot3.val(); auto a1na3imag = 1ULL * mint(a1 + mod2 - a3).val() * imag.val(); auto na2 = mod2 - a2; a[i + offset] = a0 + a2 + a1 + a3; a[i + offset + 1 * p] = a0 + a2 + (2 * mod2 - (a1 + a3)); a[i + offset + 2 * p] = a0 + na2 + a1na3imag; a[i + offset + 3 * p] = a0 + na2 + (mod2 - a1na3imag); } if(s + 1 != (1 << len)) rot *= info.rate3[__builtin_ctz(~(unsigned int)(s))]; } len += 2; } } } template void butterfly_inv(vector& a) { int n = (int)a.size(); int h = __builtin_ctz((unsigned int)n); static const FFT_Info info; int len = h; while(len) { if(len == 1) { int p = 1 << (h - len); mint irot = 1; for(int s = 0; s < (1 << (len - 1)); ++s) { int offset = s << (h - len + 1); for(int i = 0; i < p; ++i) { auto l = a[i + offset]; auto r = a[i + offset + p]; a[i + offset] = l + r; a[i + offset + p] = (unsigned long long)(mint::mod() + l.val() - r.val()) * irot.val(); } if(s + 1 != (1 << (len - 1))) irot *= info.irate2[__builtin_ctz(~(unsigned int)(s))]; } --len; } else { int p = 1 << (h - len); mint irot = 1, iimag = info.iroot[2]; for(int s = 0; s < (1 << (len - 2)); ++s) { mint irot2 = irot * irot; mint irot3 = irot2 * irot; int offset = s << (h - len + 2); for(int i = 0; i < p; ++i) { auto a0 = 1ULL * a[i + offset + 0 * p].val(); auto a1 = 1ULL * a[i + offset + 1 * p].val(); auto a2 = 1ULL * a[i + offset + 2 * p].val(); auto a3 = 1ULL * a[i + offset + 3 * p].val(); auto a2na3iimag = 1ULL * mint((mint::mod() + a2 - a3) * iimag.val()).val(); a[i + offset] = a0 + a1 + a2 + a3; a[i + offset + 1 * p] = (a0 + (mint::mod() - a1) + a2na3iimag) * irot.val(); a[i + offset + 2 * p] = (a0 + a1 + (mint::mod() - a2) + (mint::mod() - a3)) * irot2.val(); a[i + offset + 3 * p] = (a0 + (mint::mod() - a1) + (mint::mod() - a2na3iimag)) * irot3.val(); } if(s + 1 != (1 << (len - 2))) irot *= info.irate3[__builtin_ctz(~(unsigned int)(s))]; } len -= 2; } } } template vector convolution_naive(const vector& a, const vector& b) { int n = (int)a.size(), m = (int)b.size(); vector res(n + m - 1); if(n < m) { for(int j = 0; j < m; ++j) { for(int i = 0; i < n; ++i) { res[i + j] += a[i] * b[j]; } } } else { for(int i = 0; i < n; ++i) { for(int j = 0; j < m; ++j) { res[i + j] += a[i] * b[j]; } } } return res; } template vector convolution(vector a, vector b) { int n = (int)a.size(), m = (int)b.size(); if(n == 0 or m == 0) return {}; int z = 1; while(z < n + m - 1) z *= 2; assert((mint::mod() - 1) % z == 0); if(min(n, m) <= 60) return convolution_naive(a, b); a.resize(z); b.resize(z); butterfly(a); butterfly(b); for(int i = 0; i < z; ++i) a[i] *= b[i]; butterfly_inv(a); a.resize(n + m - 1); mint iz = mint(z).inv(); for(int i = 0; i < n + m - 1; ++i) a[i] *= iz; return a; } vector convolution_ll(const vector& a, const vector& b) { int n = (int)a.size(), m = (int)b.size(); if(!n or !m) return {}; static constexpr unsigned long long MOD1 = 754974721; static constexpr unsigned long long MOD2 = 167772161; static constexpr unsigned long long MOD3 = 469762049; static constexpr unsigned long long M2M3 = MOD2 * MOD3; static constexpr unsigned long long M1M3 = MOD1 * MOD3; static constexpr unsigned long long M1M2 = MOD1 * MOD2; static constexpr unsigned long long M1M2M3 = MOD1 * MOD2 * MOD3; static constexpr unsigned long long i1 = 190329765; static constexpr unsigned long long i2 = 58587104; static constexpr unsigned long long i3 = 187290749; static constexpr int MAX_AB_BIT = 24; assert(n + m - 1 <= (1 << MAX_AB_BIT)); using mint1 = StaticModint; using mint2 = StaticModint; using mint3 = StaticModint; vector a1(n), b1(m); vector a2(n), b2(m); vector a3(n), b3(m); for(int i = 0; i < n; ++i) a1[i] = a[i]; for(int i = 0; i < n; ++i) a2[i] = a[i]; for(int i = 0; i < n; ++i) a3[i] = a[i]; for(int i = 0; i < m; ++i) b1[i] = b[i]; for(int i = 0; i < m; ++i) b2[i] = b[i]; for(int i = 0; i < m; ++i) b3[i] = b[i]; vector c1 = convolution(a1, b1); vector c2 = convolution(a2, b2); vector c3 = convolution(a3, b3); vector c(n + m - 1); for(int i = 0; i < n + m - 1; ++i) { unsigned long long x = 0; x += (c1[i].val() * i1) % MOD1 * M2M3; x += (c2[i].val() * i2) % MOD2 * M1M3; x += (c3[i].val() * i3) % MOD3 * M1M2; ll diff = c1[i].val() - ((ll)x % (ll)MOD1 + (ll)MOD1) % (ll)MOD1; if(diff < 0) diff += MOD1; static constexpr unsigned long long offset[5] = {0, 0, M1M2M3, 2 * M1M2M3, 3 * M1M2M3}; x -= offset[diff % 5]; c[i] = x; } return c; } int main(void) { int n, m, k; cin >> n >> m >> k; string s, t; cin >> s >> t; string u = t + '?' + s; rep(i, 0, n + m + 1) { u[i] = tolower(u[i]); } vector z = z_algorithm(u); vector a(n), b(m); rep(i, 0, n) { a[i] = 1; if(islower(s[i])) a[i] = -1; } rep(i, 0, m) { b[m - 1 - i] = 1; if(islower(t[i])) b[m - 1 - i] = -1; } vector c = convolution_ll(a, b); int ans = 0; rep(i, 0, n) { if(z[m + 1 + i] != m) continue; int tmp = c[m - 1 + i]; int cnt = (m - tmp) / 2; if(1 <= cnt and cnt <= k) ans++; } cout << ans << '\n'; }