#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 100;
bool wall[2][maxn];
int step[2][maxn];
int n, k;
bool dfs(int side, int h, int t) {
  step[side][h] = t;
  if (h < t) return false;
  if (h >= n) return true;
  bool ans = 0;
  if (!wall[side ^ 1][h + k] &&
      (step[side ^ 1][h + k] > t + 1 || step[side ^ 1][h + k] == -1)) {
    ans |= dfs(side ^ 1, h + k, t + 1);
  }
  if (!wall[side][h + 1] &&
      (step[side][h + 1] > t + 1 || step[side][h + 1] == -1)) {
    ans |= dfs(side, h + 1, t + 1);
  }
  if (h - 1 >= 0 && !wall[side][h - 1] &&
      (step[side][h - 1] > t + 1 || step[side][h - 1] == -1)) {
    ans |= dfs(side, h - 1, t + 1);
  }
  return ans;
}
int main() {
  memset(wall, 0, sizeof(wall));
  memset(step, -1, sizeof(step));
  scanf("%d%d", &n, &k);
  char s[maxn];
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'X') wall[0][i] = 1;
  }
  scanf("%s", s);
  for (int i = 0; i < n; i++) {
    if (s[i] == 'X') wall[1][i] = 1;
  }
  bool ans = dfs(0, 0, 0);
  if (ans) {
    printf("YES\n");
  } else
    printf("NO\n");
}
