#include <bits/stdc++.h>
using namespace std;
inline int min(int a, int b) { return a < b ? a : b; }
char s[2][100005];
int dp[2][100005];
bool gao(int n, int k) {
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = (1 << 30);
    }
  }
  queue<pair<int, int> > que;
  que.push(pair<int, int>(0, 0));
  dp[0][0] = 0;
  while (que.empty() == false) {
    int i = que.front().first;
    int j = que.front().second;
    int t = dp[i][j];
    que.pop();
    if (j + 1 >= n || j + k >= n) {
      return true;
    }
    if (s[i][j + 1] != 'X') {
      if (t + 1 < dp[i][j + 1]) {
        dp[i][j + 1] = t + 1;
        que.push(pair<int, int>(i, j + 1));
      }
    }
    if (j > 0 && s[i][j - 1] != 'X' && j - 1 >= t + 1) {
      if (t + 1 < dp[i][j - 1]) {
        dp[i][j - 1] = t + 1;
        que.push(pair<int, int>(i, j - 1));
      }
    }
    if (s[1 - i][j + k] != 'X') {
      if (t + 1 < dp[1 - i][j + k]) {
        dp[1 - i][j + k] = t + 1;
        que.push(pair<int, int>(1 - i, j + k));
      }
    }
  }
  return false;
}
int main() {
  int n, k;
  while (scanf("%d %d", &n, &k) != EOF) {
    scanf("%s", s[0]);
    scanf("%s", s[1]);
    bool ans = gao(n, k);
    puts(ans ? "YES" : "NO");
  }
  return 0;
}
