// Slower C++ solution:
#include <bits/stdc++.h>

#define fi first

#define se second

#define lson l,m,rt<<1

#define rson m+1,r,rt<<1|1

#define lowbit(x) x&-x

#define pb push_back

#define MP make_pair

#define clr(a) memset(a,0,sizeof(a))

#define INF(a) memset(a,0x3f,sizeof(a))

#define FIN freopen("in.txt","r",stdin)

#define fuck(x) cout<<"["<<x<<"]"<<endl

using namespace std;

typedef long long ll;

typedef unsigned long long ull;

typedef pair<int, int>pii;

typedef pair<ll, ll>pll;

typedef vector<int> VI;

//head

const int MX = 5e5 + 7;

const int inf = 0x3f3f3f3f;



int n, k;

char s[MX], t[MX];

int dp[MX], sum[MX];

struct Queue {

    pii a[MX];

    int s, t;

    void init() {

        s = 1; t = 0;

    }

    void update(int pos, int val) {

        while (s <= t && val < a[t].se) t--;

        a[++t] = MP(pos, val);

        while (s <= t && a[t].fi - a[s].fi >= k) s++;

    }

    int query() {

        if (s > t) return inf;

        return a[s].se;

    }

} q;



int main() {

    // FIN;

    scanf("%d%d", &n, &k);

    scanf("%s%s", s + 1, t + 1);

    t[0] = '*';

    for (int i = 1; i <= n; i++)

        sum[i] = sum[i - 1] + (t[i] != t[i - 1]);

    q.init();

    dp[0] = 0; q.update(0, 2 * dp[0] - sum[1]);

    for (int i = 1; i <= n; i++) {

        dp[i] = inf;

        if (s[i] == t[i]) {

            dp[i] = dp[i - 1];

            q.update(i, 2 * dp[i] - sum[i + 1]);

            continue;

        }

        // cout << i << " " << q.query() << " " << sum[i]  << endl;

        dp[i] = min(dp[i], (q.query() + sum[i] + 3) / 2);

        q.update(i, 2 * dp[i] - sum[i + 1]);

    }

    printf("%d\n", dp[n]);

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.096149873913799x):


#include <cstdio>

#include <cstring>

#include <iostream>

#include <algorithm>

using namespace std;

//dp[i]:前i个位置染完的最小花费

//dp[0] = 0, dp[others] = INF

//if(a[i] == b[i]) dp[i] = dp[i-1]

//else dp[i] = min{dp[j] + cost(j+1, i)|max(0, i-k) <= j < i}

//cost(x, y):ceil((sum[i]-sum[j+1])/2)+1=(sum[i]-sum[j+1]+1)/2+1

//dp[i]=min{(2*dp[j]-sum[j+1]+sum[i]+3)/2|max(0, i-k) <= j < i}

//f[j] = 2*dp[j] - sum[j+1]//用长度为k的单调队列维护

//dp[i]=min{(f[j]+sum[i]+3)/2}

//f[i] = 2*dp[i]-sum[i+1]入队

const int maxn =  5e5 + 10;

const int INF = 0x3f3f3f3f;

int n, k;

char s[maxn], t[maxn];

int sum[maxn];

int dp[maxn];

struct Queue {

    struct Node {

        int pos, val;

    }node[maxn];

    int l, r;

    void init() { l = 1, r = 0; }

    void update(int pos, int val) {

        while (l <= r && val < node[r].val) r--;

        node[++r] = Node{pos, val};

        while (l <= r && node[r].pos - node[l].pos >= k) l++;

    }

    int query() {

        if (l > r) return INF;

        return node[l].val;

    }

}que;

int main() {

    scanf("%d%d", &n, &k);

    scanf("%s%s", s+1, t+1);

    sum[0] = 0, t[0] = '#';

    for (int i = 1; i <= n; i++) sum[i] = sum[i-1] + (t[i] != t[i-1]);

    dp[0] = 0;

    que.init();

    que.update(0, 2*dp[0]-sum[1]);

    for (int i = 1; i <= n; i++) {

        dp[i] = INF;

        if (s[i] == t[i]) dp[i] = dp[i-1];

        else {

            //cout << i << ":" << que.query() << endl;

            dp[i] = min(dp[i], (que.query()+sum[i]+3)/2);

        }

        que.update(i, 2*dp[i]-sum[i+1]);

        //cout << dp[i] << "test" << endl;

    }

    printf("%d\n", dp[n]);

    return 0;

}