#include <bits/stdc++.h>
using namespace std;
const int N = 5e5 + 100;
long long n, k;
char s1[N], s2[N];
int main() {
  cin >> n >> k;
  cin >> s1 + 1;
  cin >> s2 + 1;
  long long tmp = 1, ans = 0;
  for (int i = 1; i <= n; i++) {
    tmp *= 2;
    if (s1[i] == 'b') tmp--;
    if (s2[i] == 'a') tmp--;
    if (tmp > k) tmp = k + 1;
    ans += min(tmp, k);
  }
  cout << ans;
}
