#include <bits/stdc++.h>
using namespace std;
char s[2][100003];
bool done[2][100002];
int dp[2][100002];
queue<int> q;
void upt(int fh1, int fh2, int fh3) {
  done[fh1][fh2] = 1;
  dp[fh1][fh2] = fh3;
  q.push(fh1);
  q.push(fh2);
}
int n, k;
int main() {
  while (~scanf("%d%d", &n, &k)) {
    scanf("%s%s", &s[0][1], &s[1][1]);
    memset(done, 0, sizeof(done));
    while (!q.empty()) q.pop();
    if (s[0][1] != 'X') {
      upt(0, 1, 0);
    }
    bool yes = 0;
    while (!q.empty()) {
      int x = q.front();
      q.pop();
      int y = q.front();
      q.pop();
      if (!done[x][y - 1] && y - 1 > dp[x][y] + 1 && s[x][y - 1] != 'X') {
        upt(x, y - 1, dp[x][y] + 1);
      }
      if (y + 1 > n) {
        yes = 1;
        break;
      }
      if (!done[x][y + 1] && s[x][y + 1] != 'X') {
        upt(x, y + 1, dp[x][y] + 1);
      }
      if (y + k > n) {
        yes = 1;
        break;
      }
      if (!done[!x][y + k] && s[!x][y + k] != 'X') {
        upt(!x, y + k, dp[x][y] + 1);
      }
    }
    printf(yes ? "YES\n" : "NO\n");
  }
}
