#include <bits/stdc++.h>
using namespace std;
const int inf = (int)1e9;
const int mod = (int)1e9 + 7;
const double pi = acos(-1.0);
const double eps = 1e-9;
int n, k;
string second[2];
int d[2][1000005];
bool used[2][1000005];
queue<pair<int, int> > q;
int main() {
  scanf("%d%d\n", &n, &k);
  getline(cin, second[0]);
  getline(cin, second[1]);
  d[0][0] = 0;
  used[0][0] = 1;
  q.push(make_pair(0, 0));
  while (!q.empty()) {
    pair<int, int> p = q.front();
    q.pop();
    int x = p.first, y = p.second;
    int dist = d[x][y];
    if (dist > y) continue;
    if (y + k >= n) {
      printf("YES\n");
      return 0;
    }
    if (second[x][y + 1] != 'X' && !used[x][y + 1]) {
      used[x][y + 1] = 1;
      d[x][y + 1] = dist + 1;
      q.push(make_pair(x, y + 1));
    }
    if (y && second[x][y - 1] != 'X' && !used[x][y - 1]) {
      used[x][y - 1] = 1;
      d[x][y - 1] = dist + 1;
      q.push(make_pair(x, y - 1));
    }
    if (second[1 - x][y + k] != 'X' && !used[1 - x][y + k]) {
      used[1 - x][y + k] = 1;
      d[1 - x][y + k] = dist + 1;
      q.push(make_pair(1 - x, y + k));
    }
  }
  printf("NO\n");
  return 0;
}
