#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int n, k;
bool mp[2][maxn];
struct point {
  int x, y, cnt;
} head, p;
queue<point> q;
void bfs() {
  q.push((point){0, 1, 0});
  mp[0][1] = 1;
  while (!q.empty()) {
    head = q.front();
    q.pop();
    p = head;
    p.y--;
    p.cnt++;
    if (p.y > 0 && mp[p.x][p.y] == 0 && p.y > p.cnt) {
      mp[p.x][p.y] = 1;
      q.push(p);
    }
    p = head;
    p.y++;
    p.cnt++;
    if (p.y > n) {
      cout << "YES";
      return;
    }
    if (mp[p.x][p.y] == 0) {
      mp[p.x][p.y] = 1;
      q.push(p);
    }
    p = head;
    p.x = !head.x;
    p.y += k;
    p.cnt++;
    if (p.y > n) {
      cout << "YES";
      return;
    }
    if (mp[p.x][p.y] == 0) {
      mp[p.x][p.y] = 1;
      q.push(p);
    }
  }
  cout << "NO";
}
int main() {
  memset(mp, 0, sizeof(mp));
  cin >> n >> k;
  for (int i = 0; i <= 1; i++) {
    for (int j = 1; j <= n; j++) {
      char c;
      cin >> c;
      if (c == 'X') mp[i][j] = 1;
    }
  }
  bfs();
  return 0;
}
