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