#include <bits/stdc++.h>
using namespace std;
const int maxn = 500005;
char second[maxn], t[maxn];
vector<int> v;
long long tab[maxn];
int main() {
  int n, k;
  scanf("%d %d", &n, &k);
  scanf(" %s %s", second, t);
  int p = -1;
  for (int i = 0; second[i]; i++) {
    if (second[i] != t[i]) {
      p = i;
      break;
    }
  }
  if (p == -1 or k == 1) {
    printf("%d\n", n);
    return 0;
  }
  k -= 2;
  long long ret = (n - p) + n;
  for (int i = p + 1; second[i]; i++) {
    if (second[i] == 'a') v.push_back(n - i);
    if (t[i] == 'b') v.push_back(n - i);
  }
  int idx = n;
  long long sum = 0;
  for (int i = 0; i < v.size(); i++) {
    while (idx > v[i]) {
      sum += tab[idx];
      tab[idx - 1] += sum;
      if (sum > k) sum = k;
      ret += sum * idx;
      k -= sum;
      idx--;
    }
    if (!k) break;
    ret += v[i];
    tab[v[i] - 1]++;
    k--;
  }
  while (idx > 0) {
    sum += tab[idx];
    if (sum > k) sum = k;
    ret += sum * idx;
    k -= sum;
    idx--;
  }
  printf("%lld\n", ret);
}
