#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
const bool debug = false;
const int maxn = 2e5 + 7;
const int inf = 2e9 + 7;
const long long infl = 1e18 + 7;
const long double eps = 1e-9;
const long long mod = 1e9 + 7;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k, ans = 0;
  cin >> n >> k;
  string a, b;
  cin >> a >> b;
  if (k == 1) {
    cout << n;
    return 0;
  }
  long long cur = 1;
  for (int i = 0; i < a.size(); ++i) {
    cur *= 2;
    if (a[i] == 'b') cur--;
    if (b[i] == 'a') cur--;
    cur = min(cur, k);
    ans += cur;
  }
  cout << ans;
  return 0;
}
