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