#include <bits/stdc++.h>
using namespace std;
int arrayLeft[100010] = {0};
int arrayRight[100010] = {0};
class Walls {
 public:
  int height;
  int pathLength;
  int pos;
  bool onLeft;
  Walls() {
    height = 1;
    pathLength = 1000000;
    pos = 1;
    onLeft = true;
  }
};
int main() {
  int n, k;
  scanf("%d%d", &n, &k);
  Walls *wall = new Walls[2 * n];
  char a[100010], b[100010];
  a[0] = 'X';
  b[0] = 'X';
  scanf("%s%s", &a[1], &b[1]);
  int initialLimit = 0, finalLimit = 1;
  wall[0].pathLength = 0;
  arrayLeft[0] = 0;
  bool found = false;
  int count = 0;
  int waterHeight = 0;
  count = finalLimit;
  while (1) {
    for (int i = initialLimit; i < finalLimit; i++) {
      int pos = wall[i].pos;
      int pathLength = wall[i].pathLength;
      int height = wall[i].height;
      if ((height + 1 > n || height + k > n) && pathLength + 1 <= n) {
        found = true;
        break;
      }
      if (wall[i].onLeft) {
        if (arrayLeft[pos - 1] == 0 && a[pos - 1] == '-' &&
            height - 1 > waterHeight + 1) {
          arrayLeft[pos - 1] = 1;
          wall[count].height = height - 1;
          wall[count].pathLength = pathLength + 1;
          wall[count].pos = pos - 1;
          count++;
        }
        if (arrayLeft[pos + 1] == 0 && a[pos + 1] == '-' &&
            height > waterHeight) {
          arrayLeft[pos + 1] = 1;
          wall[count].height = height + 1;
          wall[count].pathLength = pathLength + 1;
          wall[count].pos = pos + 1;
          count++;
        }
        if (arrayRight[pos + k] == 0 && b[pos + k] == '-' &&
            height + k > waterHeight + 1) {
          arrayRight[pos + k] = 1;
          wall[count].height = height + k;
          wall[count].pathLength = pathLength + 1;
          wall[count].pos = pos + k;
          wall[count].onLeft = false;
          count++;
        }
      } else {
        if (arrayRight[pos - 1] == 0 && b[pos - 1] == '-' &&
            height - 1 > waterHeight + 1) {
          arrayRight[pos - 1] = 1;
          wall[count].height = height - 1;
          wall[count].pathLength = pathLength + 1;
          wall[count].pos = pos - 1;
          wall[count].onLeft = false;
          count++;
        }
        if (arrayRight[pos + 1] == 0 && b[pos + 1] == '-' &&
            height > waterHeight) {
          arrayRight[pos + 1] = 1;
          wall[count].height = height + 1;
          wall[count].pathLength = pathLength + 1;
          wall[count].pos = pos + 1;
          wall[count].onLeft = false;
          count++;
        }
        if (arrayLeft[pos + k] == 0 && a[pos + k] == '-' &&
            height + k > waterHeight + 1) {
          arrayLeft[pos + k] = 1;
          wall[count].height = height + k;
          wall[count].pathLength = pathLength + 1;
          wall[count].pos = pos + k;
          count++;
        }
      }
    }
    if (finalLimit == count) break;
    if (found) break;
    initialLimit = finalLimit;
    finalLimit = count;
    waterHeight++;
  }
  if (found) printf("YES\n");
  if (!found) printf("NO\n");
}
