#include <bits/stdc++.h>
using namespace std;
bool f[100000][2], used[100000][2];
int n, k, ans;
int q[1000000][3];
void bfs() {
  q[0][0] = 0;
  q[0][1] = 0;
  q[0][2] = 0;
  int h = -1, t = 1;
  while (h < t) {
    h++;
    int v1, v2, tt;
    v1 = q[h][0], v2 = q[h][1];
    tt = q[h][2];
    if (v1 >= n) {
      ans = 1;
      return;
    }
    if (v1 < 0) continue;
    if (used[v1][v2]) continue;
    if (!f[v1][v2]) continue;
    if (v1 < tt) continue;
    used[v1][v2] = 1;
    q[t][0] = v1 + 1, q[t][1] = v2, q[t][2] = tt + 1, t++;
    q[t][0] = v1 - 1, q[t][1] = v2, q[t][2] = tt + 1, t++;
    q[t][0] = v1 + k, q[t][1] = !v2, q[t][2] = tt + 1, t++;
  }
}
int main(void) {
  scanf("%d%d\n", &n, &k);
  for (int i = 0; i < n; i++) {
    char c;
    scanf("%c", &c);
    if (c == 'X')
      f[i][0] = 0;
    else
      f[i][0] = 1;
  }
  scanf("\n");
  for (int i = 0; i < n; i++) {
    char c;
    scanf("%c", &c);
    if (c == 'X')
      f[i][1] = 0;
    else
      f[i][1] = 1;
  }
  bfs();
  if (ans)
    cout << "YES";
  else
    cout << "NO";
}
