#include <bits/stdc++.h>
using namespace std;
int n, k;
string s[2];
bool vis[2][100010];
void dfs(int hi, int whi, int wa) {
  if (hi <= wa) return;
  if (vis[whi][hi]) return;
  vis[whi][hi] = true;
  if (hi >= n) {
    puts("YES");
    exit(0);
  }
  if (s[whi ^ 1][hi + k] != 'X') dfs(hi + k, whi ^ 1, wa + 1);
  if (hi > 0 && s[whi][hi - 1] != 'X') dfs(hi - 1, whi, wa + 1);
  if (s[whi][hi + 1] != 'X') dfs(hi + 1, whi, wa + 1);
}
int main() {
  cin >> n >> k >> s[0] >> s[1];
  for (int i = 0; i <= 100010; i++) s[0].push_back('-'), s[1].push_back('-');
  dfs(0, 0, -1);
  puts("NO");
  return 0;
}
