#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
const long long N = 1e6 + 10;
const long long inf = (long long)1e18 + 10ll;
const long long mod = 1e9 + 7;
const long long eps = 1e-9;
const char spc = 29;
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());
using namespace std;
long long n, k;
string s, t;
long long dp[N];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> s >> t;
  dp[0] = 1;
  for (long long i = 0; i < n; ++i) {
    dp[i + 1] = dp[i] * 2ll;
    if (s[i] == t[i]) --dp[i + 1];
    if (s[i] > t[i]) dp[i + 1] -= 2;
    dp[i + 1] = min(dp[i + 1], inf);
  }
  long long ans = 0;
  for (long long i = 1; i <= n; ++i) ans += min(k, dp[i]);
  cout << ans << "\n";
}
