#include <bits/stdc++.h>
using namespace std;
int n, k;
string s[2];
int timer[300100];
int used[300100];
int d[300100];
int q[300100];
vector<int> g[300100];
int get(int x, int y) { return y * 2 + x + 1; }
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> n >> k;
  cin >> s[0] >> s[1];
  int out = n * 2 + 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 2; ++j) {
      int x = get(j, i);
      timer[x] = i;
      if (s[j][i] != 'X') {
        int to = get(j ^ 1, i + k);
        if (to >= out) to = out;
        if (to == out || i + k < n && s[j ^ 1][i + k] != 'X')
          g[x].push_back(to);
        to = get(j, i + 1);
        if (to >= out) to = out;
        if (to == out || i + 1 < n && s[j][i + 1] != 'X') g[x].push_back(to);
        to = get(j, i - 1);
        if (to >= out) to = out;
        if (to == out || i && s[j][i - 1] != 'X') g[x].push_back(to);
      }
    }
  }
  timer[out] = n;
  int qs = 0, qt = 0;
  q[qt++] = 1;
  d[1] = 0;
  used[1] = 1;
  while (qs < qt) {
    int v = q[qs++];
    for (int to : g[v]) {
      if (!used[to]) {
        used[to] = 1;
        d[to] = d[v] + 1;
        if (d[to] <= timer[to]) q[qt++] = to;
      }
    }
  }
  if (used[out] && d[out] <= timer[out])
    cout << "YES";
  else
    cout << "NO";
}
