#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1.0);
const int MAXN = 500005;
int n, k;
char s[MAXN], t[MAXN];
void solve() {
  long long ans = 0;
  int cnt = 1;
  bool dif = false;
  bool grk = false;
  for (int i = 0; i < n; i++) {
    if (!dif) {
      if (s[i] != t[i]) {
        cnt *= 2;
        dif = true;
      }
    } else {
      cnt *= 2;
      if (s[i] == 'b') {
        cnt--;
      }
      if (t[i] == 'a') {
        cnt--;
      }
    }
    if (cnt >= k) {
      grk = true;
    }
    if (grk) {
      ans += k;
    } else {
      ans += cnt;
    }
  }
  cout << ans << endl;
}
int main() {
  while (scanf("%d %d", &n, &k) == 2) {
    scanf("%s", s);
    scanf("%s", t);
    solve();
  }
}
