#include <bits/stdc++.h>
using namespace std;
const int MOD(1000000007);
const int INF((1 << 30) - 1);
const int MAXN(100005);
string a[2];
bool visited[2][MAXN];
int path[2][MAXN];
pair<int, int> q[2 * MAXN];
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  cin >> a[0] >> a[1];
  int fr = 0, bk = 0;
  q[bk++] = pair<int, int>(0, 0);
  visited[0][0] = 1;
  path[0][0] = 0;
  while (fr != bk) {
    int x = q[fr].first, y = q[fr++].second;
    if (a[x][y + 1] != 'X' && !visited[x][y + 1] && path[x][y] + 1 <= y + 1) {
      if (y + 1 >= n) {
        printf("YES");
        return 0;
      }
      q[bk++] = pair<int, int>(x, y + 1);
      visited[x][y + 1] = 1;
      path[x][y + 1] = path[x][y] + 1;
    }
    if (y > 0 && a[x][y - 1] != 'X' && !visited[x][y - 1] &&
        path[x][y] + 1 <= y - 1) {
      q[bk++] = pair<int, int>(x, y - 1);
      visited[x][y - 1] = 1;
      path[x][y - 1] = path[x][y] + 1;
    }
    if (a[!x][y + k] != 'X' && !visited[!x][y + k] && path[x][y] + 1 <= y + k) {
      if (y + k >= n) {
        printf("YES");
        return 0;
      }
      q[bk++] = pair<int, int>(!x, y + k);
      visited[!x][y + k] = 1;
      path[!x][y + k] = path[x][y] + 1;
    }
  }
  printf("NO");
}
