#include <bits/stdc++.h>
using namespace std;
string s[2];
map<int, bool> vis[2][100010];
int cur[2][100010];
int n, k;
void dfs(bool l, int ind, int w) {
  if (ind <= w || ind < 0 || (ind < n && s[l][ind] == 'X') ||
      (ind < n && vis[l][ind][w]))
    return;
  if (ind + k >= n) {
    cout << "YES\n";
    exit(0);
  }
  if (cur[l][ind] <= w) return;
  cur[l][ind] = w;
  vis[l][ind][w] = 1;
  dfs(!l, ind + k, w + 1);
  dfs(l, ind + 1, w + 1);
  dfs(l, ind - 1, w + 1);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k >> s[0] >> s[1];
  for (int i = 0; i < 100010; i++) cur[0][i] = cur[1][i] = 1e9;
  dfs(0, 1, 0);
  dfs(1, k, 0);
  cout << "NO\n";
}
