#include <bits/stdc++.h>
using namespace std;
const int MAXn = 1e5 + 10;
vector<pair<int, bool> > bfs;
int n, k;
string s[2];
bool flag[2][2 * MAXn];
int main() {
  cin >> n >> k;
  cin >> s[0] >> s[1];
  bfs.push_back(pair<int, bool>(0, 0));
  flag[0][0] = true;
  for (int i = 0, level = 0; i < bfs.size(); level++)
    for (int j = bfs.size(); i < j; i++) {
      pair<int, bool> p = bfs[i];
      if (p.first >= n) return cout << "YES", 0;
      if (s[p.second][p.first] == 'X' || level > p.first) continue;
      if (p.first > 0 && !flag[p.second][p.first - 1]) {
        flag[p.second][p.first - 1] = true;
        bfs.push_back(pair<int, bool>(p.first - 1, p.second));
      }
      if (!flag[p.second][p.first + 1]) {
        flag[p.second][p.first + 1] = true;
        bfs.push_back(pair<int, bool>(p.first + 1, p.second));
      }
      if (!flag[!p.second][p.first + k]) {
        flag[!p.second][p.first + k] = true;
        bfs.push_back(pair<int, bool>(p.first + k, !p.second));
      }
    }
  cout << "NO";
}
