#include <bits/stdc++.h>
using namespace std;
struct pt {
  int in;
  int ti;
  int w;
  pt(int in = 0, int ti = 0, int w = 0) : in(in), ti(ti), w(w) {}
};
int used[2][100013];
int ground[2][100013];
int flag = 0;
int n, k;
void dfs(pt u) {
  used[u.w][u.in] = 1;
  if (flag || u.in <= u.ti) return;
  if (u.in + k >= n || u.in + 1 >= n) {
    flag = 1;
    return;
  }
  if (!used[1 - u.w][u.in + k] && !ground[1 - u.w][u.in + k]) {
    dfs(pt(u.in + k, u.ti + 1, 1 - u.w));
  }
  if (u.in >= 1 && !used[u.w][u.in - 1] && !ground[u.w][u.in - 1]) {
    dfs(pt(u.in - 1, u.ti + 1, u.w));
  }
  if (!used[u.w][u.in + 1] && !ground[u.w][u.in + 1]) {
    dfs(pt(u.in + 1, u.ti + 1, u.w));
  }
}
int main() {
  memset(used, 0, sizeof(used));
  cin >> n >> k;
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = 0; i < n; i++) {
    ground[0][i] = ((int)(s1[i] == 'X'));
    ground[1][i] = ((int)(s2[i] == 'X'));
  }
  dfs(pt(0, -1, 0));
  if (flag) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
