#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 500, INF = 1e9;
int flag = 0, vis[2][N], n, k;
char s[2][N];
int gcd(int a, int b) { return !b ? a : gcd(b, a % b); }
long long qpow(long long a, long long b) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans *= a;
    a <<= 1, b >>= 1;
  }
  return ans;
}
void dfs(int pos, int num, int cnt) {
  if (pos >= n || flag) {
    flag = 1;
    return;
  }
  if (s[num][pos] == 'X' || pos <= cnt || vis[num][pos]) return;
  vis[num][pos] = 1;
  dfs(pos + k, num ^ 1, cnt + 1);
  dfs(pos + 1, num, cnt + 1);
  dfs(pos - 1, num, cnt + 1);
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n >> k;
  cin >> s[0] >> s[1];
  dfs(0, 0, -1);
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
