#include <bits/stdc++.h>
using namespace std;
int n, k, water;
const int N = 1e5 + 9;
char s[2][N];
bool vis[2][N];
bool dfs(int r, int c) {
  if (c > n) {
    return 1;
  }
  if (c < water || vis[r][c] || s[r][c] == 'X') {
    return 0;
  }
  vis[r][c] = 1;
  water++;
  int ok = dfs(1 - r, c + k) || dfs(r, c + 1) || dfs(r, c - 1);
  water--;
  return ok;
}
int main() {
  while (~scanf("%d%d", &n, &k)) {
    scanf("%s%s", s[0] + 1, s[1] + 1);
    water = 1;
    memset(vis, 0, sizeof(vis));
    if (dfs(0, 1)) {
      printf("YES\n");
    } else {
      printf("NO\n");
    }
  }
  return 0;
}
