#include <bits/stdc++.h>
using namespace std;
int n, k;
int water, flag;
int visited[2][100005];
string wall[2];
void bfs(int x, int y) {
  flag = 0, water = 0;
  visited[x][y] = 1;
  queue<pair<int, int> > q;
  q.push(make_pair(x, y));
  while (q.size() != 0) {
    int sz = q.size();
    while (sz--) {
      int a = q.front().first;
      int b = q.front().second;
      q.pop();
      if (b + k > n || b + 1 > n) {
        flag = 1;
        return;
      }
      if (wall[a][b + 1] != 'X' && visited[a][b + 1] == 0) {
        visited[a][b + 1] = 1;
        q.push(make_pair(a, b + 1));
      }
      if (b - 1 >= 0 && wall[a][b - 1] != 'X' && b - 1 > water &&
          visited[a][b - 1] == 0) {
        visited[a][b - 1] = 1;
        q.push(make_pair(a, b - 1));
      }
      if (a == 0) {
        if (wall[1][b + k] != 'X' && visited[1][b + k] == 0) {
          visited[1][b + k] = 1;
          q.push(make_pair(1, b + k));
        }
      }
      if (a == 1) {
        if (wall[0][b + k] != 'X' && visited[0][b + k] == 0) {
          visited[0][b + k] = 1;
          q.push(make_pair(0, b + k));
        }
      }
    }
    water++;
  }
}
int main() {
  cin >> n >> k;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      visited[i][j] = 0;
    }
  }
  cin >> wall[0];
  cin >> wall[1];
  bfs(0, 0);
  if (flag == 1)
    cout << "YES";
  else
    cout << "NO";
}
