#include <bits/stdc++.h>
using namespace std;
queue<pair<int, int> > q;
int n, k, f[2][100100];
bool visit[2][100100];
char s[2][100100];
int check(int x, int y) {
  if (y < 0) return 0;
  if (y >= n) return 1;
  if (s[x][y] == 'X' || visit[x][y]) return 0;
  return 1;
}
string bfs() {
  memset(visit, false, sizeof(visit));
  q.push(pair<int, int>(0, 0));
  visit[0][0] = true;
  while (!q.empty()) {
    pair<int, int> temp = q.front();
    q.pop();
    int x = temp.first;
    int y = temp.second;
    if (check(1 - x, y + k)) {
      if (y + k >= n) return "YES";
      f[1 - x][y + k] = f[x][y] + 1;
      visit[1 - x][y + k] = true;
      q.push(pair<int, int>(1 - x, y + k));
    }
    if (check(x, y + 1)) {
      f[x][y + 1] = f[x][y] + 1;
      visit[x][y + 1] = true;
      q.push(pair<int, int>(x, y + 1));
    }
    if (check(x, y - 1) && f[x][y] < y - 1) {
      f[x][y - 1] = f[x][y] + 1;
      visit[x][y - 1] = true;
      q.push(pair<int, int>(x, y - 1));
    }
  }
  return "NO";
}
int main() {
  cin >> n >> k;
  gets(s[0]);
  gets(s[0]);
  gets(s[1]);
  cout << bfs();
  return 0;
}
