#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);
const double eps = 1e-9;
int n, k;
string s[3];
bool vis[3][100010];
struct J {
  int w, lr, lv;
};
bool valid(int x, int i, int u, int w) {
  if (x > n) {
    cout << "YES";
    exit(0);
  }
  if (i == 2) {
    if (x > 1 && x > w && s[u ^ 3][x] != 'X' && vis[u ^ 3][x] == false)
      return true;
    else
      return false;
  }
  if (x > 1 && x > w && s[u][x] != 'X' && vis[u][x] == false)
    return true;
  else
    return false;
}
string bfs() {
  queue<J> q;
  J x;
  x.w = 0, x.lr = 1, x.lv = 1;
  q.push(x);
  int fx[] = {1, -1, k};
  while (!q.empty()) {
    J u = q.front();
    q.pop();
    for (int i = 0; i < 3; i++) {
      int xx = u.lv + fx[i];
      if (valid(xx, i, u.lr, u.w + 1)) {
        J v;
        v.w = u.w + 1, v.lv = xx;
        if (i == 2)
          v.lr = u.lr ^ 3;
        else
          v.lr = u.lr;
        vis[v.lr][xx] = 1;
        q.push(v);
      }
    }
  }
  return "NO";
}
int main() {
  cin >> n >> k;
  cin >> s[1] >> s[2];
  s[1] = '#' + s[1];
  s[2] = '#' + s[2];
  if (s[1][1] == 'X') {
    cout << "NO";
    return 0;
  }
  cout << bfs() << endl;
  return 0;
}
