#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3F3F3F3F;
int n, k;
const int M = 100010;
char a[2][M];
int dist[2][M];
bool vis[2][M];
void bfs(int x, int y) {
  memset(vis, false, sizeof(vis));
  memset(dist, 0x3F, sizeof(dist));
  queue<pair<int, int> > q;
  dist[x][y] = 0;
  q.push(make_pair(x, y));
  while (!q.empty()) {
    pair<int, int> f = q.front();
    q.pop();
    int x = f.first, y = f.second;
    if (vis[x][y]) continue;
    vis[x][y] = true;
    if (dist[x][y] > y) continue;
    if (y + 1 >= n or y + k >= n) {
      printf("YES\n");
      return;
    }
    if (y + 1 < n and a[x][y + 1] != 'X')
      dist[x][y + 1] = min(dist[x][y + 1], dist[x][y] + 1),
                  q.push(make_pair(x, y + 1));
    if (y - 1 >= 0 and a[x][y - 1] != 'X')
      dist[x][y - 1] = min(dist[x][y - 1], dist[x][y] + 1),
                  q.push(make_pair(x, y - 1));
    int x2 = (x + 1) % 2;
    if (y + k < n and a[x2][y + k] != 'X')
      dist[x2][y + k] = min(dist[x2][y + k], dist[x][y] + 1),
                   q.push(make_pair(x2, y + k));
  }
  printf("NO\n");
}
int main() {
  scanf("%d%d", &n, &k);
  scanf("%s%s", a[0], a[1]);
  bfs(0, 0);
  return 0;
}
