#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(NULL);
  std::cout.tie(NULL);
  long long n, m;
  cin >> n >> m;
  string s1, s2;
  cin >> s1 >> s2;
  long long now = 1, ans = 0;
  for (int i = 0; i < n; ++i) {
    if (s1[i] == s2[i]) {
      now = now * 2 - 1;
    } else if (s1[i] < s2[i]) {
      now = now * 2;
    } else {
      now = now * 2 - 2;
    }
    now = min(now, (long long)1e9);
    ans += min(now, m);
  }
  cout << ans << endl;
  return 0;
}
