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