#include <bits/stdc++.h>
using namespace std;
long long l, r, n, k;
long long ans = 0;
char s[500010], b[500010];
int main() {
  cin >> n >> k;
  scanf("%s%s", s + 1, b + 1);
  for (int i = 1; i <= n; ++i) {
    if (s[i] == 'b') l++;
    if (b[i] == 'b') r++;
    ans += min((r - l + 1), k);
    if ((r - l + 1) <= k + 10) l *= 2, r *= 2, r -= l, l = 0;
  }
  cout << ans;
  return 0;
}
