#include <bits/stdc++.h>
using namespace std;
string s[2];
int n, k, dp[2][100001], ans;
void bfs(int wall, int height, int seconds) {
  if (height >= n) ans = true;
  if (height >= n || s[wall][height] == 'X' || dp[wall][height] <= seconds ||
      seconds > height)
    return;
  dp[wall][height] = seconds;
  bfs((wall + 1) % 2, height + k, seconds + 1);
  bfs(wall, height + 1, seconds + 1);
  bfs(wall, height - 1, seconds + 1);
}
int main() {
  for (auto &i : dp)
    for (auto &j : i) j = 1e9;
  cin >> n >> k;
  cin >> s[0] >> s[1];
  bfs(0, 0, 0);
  cout << (ans ? "YES\n" : "NO\n");
  return 0;
}
