#include <bits/stdc++.h>
using namespace std;
const long long big = 2e9 + 5;
const long long md = 1e9 + 7;
string s, w;
int n, m, o = 1;
int main() {
  ios_base ::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> n >> m;
  cin >> s;
  cin >> w;
  long long ans = 0, now = 1;
  bool ch = false;
  for (int i = 0; i < n; i++) {
    if (s[i] != w[i]) ch = true;
    if (ch) {
      now *= 2LL;
      if (s[i] == 'b') now--;
      if (w[i] == 'a') now--;
      now = min(now, (long long)1e12);
    }
    ans += min(now, (long long)m);
  }
  cout << ans << endl;
  cout << endl;
  return 0;
}
