#include <bits/stdc++.h>
using namespace std;
int dist[2 * 100000 + 2 + 5], N, K;
vector<int> G[2 * 100000 + 2 + 5];
void addedge(const string &wall, const string &wall2, int i, int offs) {
  int here = i + offs, there = i + N - offs;
  if (wall[i] == 'X') return;
  if (i != 0 && wall[i - 1] != 'X') G[here].push_back(here - 1);
  if (i == N - 1 || wall[i + 1] != 'X') G[here].push_back(here + 1);
  if (i + K >= N) {
    G[here].push_back(2 * N);
  } else if (wall2[i + K] != 'X') {
    G[here].push_back(there + K);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string L, R;
  cin >> N >> K >> L >> R;
  for (int i = 0; i < N; i++) {
    addedge(L, R, i, 0);
    addedge(R, L, i, N);
  }
  memset(dist, -1, sizeof(dist));
  queue<int> q;
  dist[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int fr = q.front(), d = dist[fr];
    q.pop();
    for (int to : G[fr]) {
      if (dist[to] == -1 && (to % N > d || to >= 2 * N)) {
        dist[to] = d + 1;
        q.push(to);
      }
    }
  }
  if (dist[2 * N] != -1 || dist[2 * N + 1] != -1)
    cout << "YES\n";
  else
    cout << "NO\n";
}
