#include <bits/stdc++.h>
using namespace std;
int n, k;
int visited[2][100001];
string walls[2];
queue<pair<int, int> > q;
void relax(int x, int y, int t) {
  if (walls[x][y] == 'X' || y < 0 || visited[x][y] != 0 || y < t - 1) return;
  q.push(make_pair(x, y));
  visited[x][y] = t;
}
void bfs() {
  q.push(make_pair(0, 0));
  visited[0][0] = 1;
  while (!q.empty()) {
    int x = q.front().first;
    int y = q.front().second;
    q.pop();
    int t = visited[x][y];
    if (y + k >= n) {
      cout << "YES";
      return;
    }
    relax(x, y - 1, t + 1);
    relax(x, y + 1, t + 1);
    relax(1 - x, y + k, t + 1);
  }
  cout << "NO";
}
int main() {
  cin >> n >> k;
  string s;
  getline(cin, s);
  getline(cin, walls[0]);
  getline(cin, walls[1]);
  bfs();
  return 0;
}
