#include <bits/stdc++.h>
using namespace std;

const int N = 510000;

int dp[N], sum[N];
char s[N], t[N];

int main() {
	ios_base::sync_with_stdio(0);
	int n, m; cin >> n >> m >> s + 1 >> t + 1;
	for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + (i > 1 && t[i] != t[i - 1]);
	set<pair<int, int> > S[2];
	S[0].insert(make_pair(0, 0));
	for (int i = 1; i <= n; i++) {
		if (i == 1) {
			dp[i] = (s[i] != t[i]);
		} else {
			dp[i] = dp[i - 1] + (s[i] != t[i]);
			if (i > m) S[sum[i - m] & 1].erase(make_pair(2 * dp[i - m - 1] - sum[i - m], i - m - 1));
			for (int j = 0; j < 2; j++) {
				if (S[j].empty()) continue;
				auto it = S[j].begin();
				if (sum[i] + 1 + j & 1) {
					dp[i] = min(dp[i], (sum[i] + it->first) / 2 + 1);
				} else {
					dp[i] = min(dp[i], (sum[i] + it->first + 1) / 2 + 1);
				}
			}
		}
		if (i < n) S[sum[i + 1] & 1].insert(make_pair(2 * dp[i] - sum[i + 1], i));
	}
	cout << dp[n] << endl;
	return 0;
}

