#include <bits/stdc++.h>
using namespace std;
string s[2];
int n, k;
bool jumped[2][100020];
void dfs(int lor, int p, int t) {
  if (s[lor][p] == 'X' || p <= t || jumped[lor][p]) return;
  if (p > n - k) {
    printf("YES");
    exit(0);
  }
  jumped[lor][p] = 1;
  dfs(lor, p - 1, t + 1);
  dfs((lor + 1) % 2, p + k, t + 1);
  dfs(lor, p + 1, t + 1);
}
int main() {
  cin >> n >> k >> s[0] >> s[1];
  n--;
  dfs(0, 0, -1);
  printf("NO");
}
