#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
int n, k;
string a[2];
bool b[2][500010];
void dfs(int whi, int pla, int water) {
  if (b[whi % 2][pla]) return;
  if (pla <= water) return;
  if (a[whi % 2][pla] == 'X') return;
  b[whi % 2][pla] = 1;
  if (pla + k > n) {
    puts("YES");
    exit(0);
  }
  dfs(whi + 1, pla + k, water + 1);
  dfs(whi, pla - 1, water + 1);
  dfs(whi, pla + 1, water + 1);
}
int main() {
  cin >> n >> k >> a[0] >> a[1];
  dfs(0, 0, -1);
  puts("NO");
  return 0;
}
