#include <bits/stdc++.h>
using namespace std;
int n, k, distence[2][100010], ans;
char s[2][100010];
queue<pair<int, int> > q;
void bfs(int x, int y, int dis) {
  if (y > n) {
    cout << "YES" << endl;
    exit(0);
  };
  if (s[x][y] != 'X' && !distence[x][y] && y >= 0) {
    distence[x][y] = dis;
    if (dis <= y) q.push(pair<int, int>(x, y));
  }
}
int main() {
  cin >> n >> k;
  cin >> s[0];
  cin >> s[1];
  bfs(0, 0, 0);
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    int dis = distence[x][y] + 1;
    if (x == 0)
      bfs(x + 1, y + k, dis);
    else
      bfs(x - 1, y + k, dis);
    bfs(x, y + 1, dis);
    bfs(x, y - 1, dis);
  }
  cout << "NO" << endl;
  return 0;
}
