#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e5 + 5;
int n, k;
string wall[2];
bool mark[2][maxn];
int t[2][maxn];
bool bfs() {
  mark[0][0] = 1;
  queue<pair<int, int>> q;
  q.push({0, 0});
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    if (t[x][y] > y) continue;
    int my[] = {1, -1, k};
    int mx[] = {0, 0, 1};
    for (int i = 0; i < 3; i++) {
      int newx = x + mx[i];
      newx = newx % 2;
      int newy = y + my[i];
      if (newy >= n) return 1;
      if (newy >= 0 && !mark[newx][newy] && wall[newx][newy] != 'X') {
        q.push({newx, newy});
        mark[newx][newy] = 1;
        t[newx][newy] = t[x][y] + 1;
      }
    }
  }
  return 0;
}
int main() {
  cin >> n >> k >> wall[0] >> wall[1];
  if (bfs())
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
