#include <bits/stdc++.h>
using namespace std;
struct node {
  int x, y, s;
};
char a[5][500005];
int book[5][500005];
int main() {
  int n, k;
  cin >> n >> k;
  queue<node> q;
  node now, next;
  for (int i = 1; i <= 2; i++) scanf("%s", a[i] + 1);
  int p = 0;
  now.x = 1;
  now.y = 1;
  now.s = 0;
  q.push(now);
  book[1][1] = 1;
  int flag = 0;
  while (!q.empty()) {
    now = q.front();
    int tx, ty;
    for (int i = 0; i < 3; i++) {
      if (i == 0) {
        tx = now.x;
        ty = now.y + 1;
      }
      if (i == 1) {
        tx = now.x;
        ty = now.y - 1;
      }
      if (i == 2) {
        if (now.x == 1)
          tx = 2;
        else
          tx = 1;
        ty = now.y + k;
      }
      if (ty > n) {
        flag = 1;
        break;
      }
      if (book[tx][ty] == 1 || a[tx][ty] == 'X' || ty <= now.s + 1 || tx < 1)
        continue;
      if (book[tx][ty] == 0) {
        book[tx][ty] = 1;
        next.x = tx;
        next.y = ty;
        next.s = now.s + 1;
        q.push(next);
      }
    }
    p++;
    q.pop();
    if (flag) break;
  }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
