#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printVector(const T& t) {
  if (t.size() > 0)
    cout << t[0];
  else {
    cout << "\n";
    return;
  }
  for (int i = int(1); i < int(t.size()); i++) {
    cout << " " << t[i];
  }
  cout << "\n";
}
using ll = long long;
const int mode = 0;
void solve() {
  int n;
  ll k;
  cin >> n >> k;
  string s, t;
  cin >> s >> t;
  reverse(s.begin(), s.end());
  reverse(t.begin(), t.end());
  ll ans = 0;
  while (s.back() == t.back()) {
    ans++;
    s.pop_back();
    t.pop_back();
    if (s.empty()) {
      cout << ans << endl;
      return;
    }
  }
  ll avail = 1;
  ll row = 1;
  ll INF = 1e10;
  for (int i = (int)s.size() - 1; i >= 0; i--) {
    row *= 2;
    row = min(row, INF);
    if (s[i] == t[i]) {
      avail = 2 * avail - 1;
    } else if (s[i] == 'a') {
      avail = 2 * avail;
    } else {
      avail = 2 * avail - 2;
    }
    avail = min(avail, INF);
    ans += min(row, min(avail, k));
  }
  cout << ans << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  if (mode == 0) {
    solve();
  } else {
    cin >> t;
    while (t--) {
      solve();
    }
  }
}
