#include <bits/stdc++.h>
using namespace std;
int dp[4][210000];
bool b[4][210000], mas[4][210000];
int n, k;
char s[100100];
int inf = -100000000;
int rec(int x, int y) {
  if (b[x][y] == 1) return dp[x][y];
  b[x][y] = 1;
  if (mas[x][y] == 1) {
    dp[x][y] = inf;
    return inf;
  }
  if (y == 0) {
    dp[x][y] = inf;
    return inf;
  }
  dp[x][y] = inf;
  dp[x][y] = max(dp[x][y], rec(x, y - 1));
  if (y + 1 <= n) dp[x][y] = max(dp[x][y], rec(x, y + 1) - 2);
  int z;
  if (x == 1)
    z = 2;
  else
    z = 1;
  if (y >= k) dp[x][y] = max(dp[x][y], rec(z, y - k) + k - 1);
  if (dp[x][y] <= 0) dp[x][y] = inf;
  return dp[x][y];
}
int main() {
  cin >> n >> k;
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    mas[1][i + 1] = (s[i] == 'X');
  }
  dp[1][1] = 1;
  b[1][1] = 1;
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    mas[2][i + 1] = (s[i] == 'X');
  }
  for (int i = n + 1; i <= n + k; i++) {
    if (rec(1, i) > 0) {
      cout << "YES" << endl;
      return 0;
    }
    if (rec(2, i) > 0) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  return 0;
}
