#include <bits/stdc++.h>
#pragma GCC optimize "O3"
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 1e5 + 5;
int dp[N][2];
int n, k;
string s[2];
queue<pair<int, int> > stany;
void solve() {
  memset(dp, inf, sizeof(dp));
  cin >> n >> k >> s[0] >> s[1];
  dp[1][0] = 0;
  stany.push({1, 0});
  while (!stany.empty()) {
    auto v = stany.front();
    stany.pop();
    for (auto x :
         {make_pair(v.first + 1, v.second), make_pair(v.first - 1, v.second),
          make_pair(v.first + k, v.second ^ 1)}) {
      x.first = max(1, min(n + 1, x.first));
      if (s[x.second][x.first - 1] == 'X') continue;
      if (dp[x.first][x.second] == inf && dp[v.first][v.second] + 1 < x.first) {
        dp[x.first][x.second] = dp[v.first][v.second] + 1;
        stany.push({x.first, x.second});
      }
    }
  }
  cout << (dp[n + 1][0] != inf || dp[n + 1][1] != inf ? "YES" : "NO") << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
