#if __INCLUDE_LEVEL__ == 0 #include __BASE_FILE__ namespace { void solve() { int n, m, k; scan(n, m, k); std::string s, t; scan(s, t); auto s_lower = s; for (char& c : s_lower) { c = std::tolower(c); } auto t_lower = t; for (char& c : t_lower) { c = std::tolower(c); } RollingHash rh_s(s_lower.begin(), s_lower.end()); RollingHash rh_t(t_lower.begin(), t_lower.end()); std::basic_string ans(n - m + 1, true); for (const int i : rep(n - m + 1)) { ans[i] = rh_s.get(i, i + m) == rh_t.get(0, m); } using mint = atcoder::modint998244353; std::vector s_islower(n); std::vector s_isupper(n); for (const int i : rep(n)) { s_islower[i] = std::islower(s[i]) != 0; s_isupper[i] = std::isupper(s[i]) != 0; } std::vector t_islower(m); std::vector t_isupper(m); for (const int i : rep(m)) { t_islower[i] = std::islower(t[i]) != 0; t_isupper[i] = std::isupper(t[i]) != 0; } ranges::reverse(t_islower); ranges::reverse(t_isupper); auto v01 = atcoder::convolution(s_islower, t_isupper); auto v10 = atcoder::convolution(s_isupper, t_islower); for (const int i : rep(n - m + 1)) { const int d = (v01[i + m - 1] + v10[i + m - 1]).val(); ans[i] &= 1 <= d && d <= k; } print(ranges::count(ans, true)); } // カス } // namespace int main() { std::ios::sync_with_stdio(false); std::cin.tie(nullptr); solve(); } #else // __INCLUDE_LEVEL__ #include #include template struct RollingHash { static inline std::mt19937 rng_{ uint32_t(std::chrono::steady_clock::now().time_since_epoch().count())}; static inline std::array base{std::vector{1, rng_() % P}, std::vector{1, rng_() % P}}; std::array, 2> h; RollingHash() { h[0] = h[1] = {0}; } template RollingHash(Iterator first, Iterator last) { int n = std::distance(first, last); for (int z : {0, 1}) base[z].reserve(n + 1), h[z].reserve(n + 1); for (h[0] = h[1] = {0}; first != last;) push_back(*first++); } template void push_back(const T& a) { for (int z : {0, 1}) { h[z].push_back((uint64_t(h[z].back()) * base[z][1] + a) % P); while (base[z].size() < h[z].size()) base[z].push_back(uint64_t(base[z].back()) * base[z][1] % P); } } void pop_back() { for (int z : {0, 1}) h[z].pop_back(); } int get(int l, int r, int z) const { return (h[z][r] + uint64_t(P - h[z][l]) * base[z][r - l]) % P; } std::array get(int l, int r) const { return {get(l, r, 0), get(l, r, 1)}; } friend int lcp(const RollingHash& ha, int la, int ra, const RollingHash& hb, int lb, int rb) { int ok = 0, ng = std::min(ra - la, rb - lb) + 1; while (ng - ok > 1) { int mid = (ok + ng) / 2; (ha.get(la, la + mid) == hb.get(lb, lb + mid) ? ok : ng) = mid; } return ok; } friend int strcmp(const RollingHash& ha, int la, int ra, const RollingHash& hb, int lb, int rb) { int m = lcp(ha, la, ra, hb, lb, rb); if (la + m == ra && lb + m == rb) return 0; if (la + m == ra) return -1; if (lb + m == rb) return +1; return ha.get(la + m, la + m + 1, 0) - hb.get(lb + m, lb + m + 1, 0); } }; template bool chmin(T& x, U&& y) { return y < x && (x = std::forward(y), true); } template bool chmax(T& x, U&& y) { return x < y && (x = std::forward(y), true); } template T inf() { T ret; std::memset(&ret, 0x3f, sizeof(ret)); return ret; } template T inf() { return std::numeric_limits::infinity(); } template concept Range = std::ranges::range && !std::convertible_to; template concept Tuple = std::__is_tuple_like::value && !Range; namespace std { istream& operator>>(istream& is, Range auto&& r) { for (auto&& e : r) { is >> e; } return is; } istream& operator>>(istream& is, Tuple auto&& t) { return apply([&](auto&... xs) -> istream& { return (is >> ... >> xs); }, t); } ostream& operator<<(ostream& os, Range auto&& r) { for (string_view sep = ""; auto&& e : r) { os << exchange(sep, " ") << e; } return os; } ostream& operator<<(ostream& os, Tuple auto&& t) { const auto f = [&](auto&... xs) -> ostream& { [[maybe_unused]] string_view sep = ""; ((os << exchange(sep, " ") << xs), ...); return os; }; return apply(f, t); } template * = nullptr> istream& operator>>(istream& is, T& x) { int v; is >> v; x = T::raw(v); return is; } template * = nullptr> ostream& operator<<(ostream& os, const T& x) { return os << x.val(); } } // namespace std #define DEF_INC_OR_DEC(op) \ auto& operator op(Range auto&& r) { \ for (auto&& e : r) { \ op e; \ } \ return r; \ } \ auto& operator op(Tuple auto&& t) { \ std::apply([](auto&... xs) { (op xs, ...); }, t); \ return t; \ } DEF_INC_OR_DEC(++) DEF_INC_OR_DEC(--) #undef DEF_INC_OR_DEC void scan(auto&&... xs) { std::cin >> std::tie(xs...); } void print(auto&&... xs) { std::cout << std::tie(xs...) << '\n'; } #define FWD(...) static_cast(__VA_ARGS__) template class fix { public: explicit fix(F f) : f_(std::move(f)) {} decltype(auto) operator()(auto&&... xs) const { return f_(std::ref(*this), FWD(xs)...); } private: F f_; }; template concept LambdaExpr = std::is_placeholder_v> != 0 || std::is_bind_expression_v>; auto operator++(LambdaExpr auto&& x, int) { return std::bind([](auto&& x) -> decltype(auto) { return FWD(x)++; }, FWD(x)); } auto operator--(LambdaExpr auto&& x, int) { return std::bind([](auto&& x) -> decltype(auto) { return FWD(x)--; }, FWD(x)); } #define DEF_UNARY_OP(op) \ auto operator op(LambdaExpr auto&& x) { \ return std::bind([](auto&& x) -> decltype(auto) { return op FWD(x); }, FWD(x)); \ } DEF_UNARY_OP(++) DEF_UNARY_OP(--) DEF_UNARY_OP(+) DEF_UNARY_OP(-) DEF_UNARY_OP(~) DEF_UNARY_OP(!) DEF_UNARY_OP(*) DEF_UNARY_OP(&) #undef DEF_UNARY_OP #define DEF_BINARY_OP(op) \ template \ requires LambdaExpr || LambdaExpr \ auto operator op(T1&& x, T2&& y) { \ return std::bind([](auto&& x, auto&& y) -> decltype(auto) { return FWD(x) op FWD(y); }, \ FWD(x), FWD(y)); \ } DEF_BINARY_OP(+=) DEF_BINARY_OP(-=) DEF_BINARY_OP(*=) DEF_BINARY_OP(/=) DEF_BINARY_OP(%=) DEF_BINARY_OP(^=) DEF_BINARY_OP(&=) DEF_BINARY_OP(|=) DEF_BINARY_OP(<<=) DEF_BINARY_OP(>>=) DEF_BINARY_OP(+) DEF_BINARY_OP(-) DEF_BINARY_OP(*) DEF_BINARY_OP(/) DEF_BINARY_OP(%) DEF_BINARY_OP(^) DEF_BINARY_OP(&) DEF_BINARY_OP(|) DEF_BINARY_OP(<<) DEF_BINARY_OP(>>) DEF_BINARY_OP(==) DEF_BINARY_OP(!=) DEF_BINARY_OP(<) DEF_BINARY_OP(>) DEF_BINARY_OP(<=) DEF_BINARY_OP(>=) DEF_BINARY_OP(&&) DEF_BINARY_OP(||) #undef DEF_BINARY_OP template requires LambdaExpr || LambdaExpr auto at(T1&& x, T2&& y) { return std::bind([](auto&& x, auto&& y) -> decltype(auto) { return FWD(x)[FWD(y)]; }, FWD(x), FWD(y)); } template auto get(LambdaExpr auto&& x) { return std::bind([](auto&& x) -> decltype(auto) { return std::get(FWD(x)); }, FWD(x)); } inline auto rep(int l, int r) { return std::views::iota(std::min(l, r), r); } inline auto rep(int n) { return rep(0, n); } inline auto rep1(int l, int r) { return rep(l, r + 1); } inline auto rep1(int n) { return rep(1, n + 1); } using namespace std::literals; using namespace std::placeholders; namespace ranges = std::ranges; namespace views = std::views; using i64 = std::int64_t; #endif // __INCLUDE_LEVEL__