#include <bits/stdc++.h>
using namespace std;
int n, k;
string s, t;
int main(void) {
  ios::sync_with_stdio(false);
  cin >> n >> k >> s >> t;
  int leaf = 1, idxD = n;
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] != t[i]) {
      idxD = i;
      break;
    }
    ans++;
  }
  for (int i = idxD; i < n; i++) {
    leaf *= 2;
    if (s[i] == 'b') leaf--;
    if (t[i] == 'a') leaf--;
    if (leaf >= k) {
      ans += (long long)k * (n - i);
      break;
    }
    ans += leaf;
  }
  cout << ans << endl;
  return 0;
}
