#include <bits/stdc++.h>
using namespace std;
struct node {
  int h, s, preh, pres, vis, water, sec;
} n[400010][4];
int m, k, p, hh;
char c;
queue<node> q;
int main() {
  scanf("%d%d", &m, &k);
  getchar();
  for (int i = 1; i <= m; i++) {
    scanf("%c", &c);
    n[i][1].vis = n[i][2].vis = 0;
    n[i][1].h = n[i][2].h = i;
    n[i][1].s = 1;
    if (c == '-')
      n[i][1].sec = 1;
    else
      n[i][1].sec = 0;
  }
  getchar();
  for (int i = 1; i <= m; i++) {
    scanf("%c", &c);
    n[i][2].s = 2;
    if (c == '-')
      n[i][2].sec = 1;
    else
      n[i][2].sec = 0;
  }
  int side = 1, flag = 0;
  n[1][1].water = 0;
  n[1][1].vis = 1;
  n[1][1].preh = n[1][1].pres = -1;
  q.push(n[1][1]);
  while (!q.empty()) {
    node height = q.front();
    hh = height.h;
    side = height.s;
    q.pop();
    if (height.h <= height.water) {
      continue;
    }
    if (height.h > m) {
      printf("YES\n");
      flag = 1;
      break;
    }
    if (side == 1) {
      if (hh + 1 > m || (!n[hh + 1][1].vis && n[hh + 1][1].sec)) {
        n[hh + 1][1].h = hh + 1;
        n[hh + 1][1].vis = 1;
        n[hh + 1][1].preh = hh;
        n[hh + 1][1].pres = 1;
        n[hh + 1][1].water = height.water + 1;
        q.push(n[hh + 1][1]);
      }
      if (!n[hh - 1][1].vis && n[hh - 1][1].sec) {
        n[hh - 1][1].vis = 1;
        n[hh - 1][1].preh = hh;
        n[hh - 1][1].pres = 1;
        n[hh - 1][1].water = height.water + 1;
        q.push(n[hh - 1][1]);
      }
      if (hh + k > m || (!n[hh + k][2].vis && n[hh + k][2].sec)) {
        n[hh + k][2].h = hh + k;
        n[hh + k][2].vis = 1;
        n[hh + k][2].preh = hh;
        n[hh + k][2].pres = 1;
        n[hh + k][2].water = height.water + 1;
        q.push(n[hh + k][2]);
      }
    } else {
      if (hh + 1 > m || (!n[hh + 1][2].vis && n[hh + 1][2].sec)) {
        n[hh + 1][2].h = hh + 1;
        n[hh + 1][2].vis = 1;
        n[hh + 1][2].preh = hh;
        n[hh + 1][2].pres = 2;
        n[hh + 1][2].water = height.water + 1;
        q.push(n[hh + 1][2]);
      }
      if (!n[hh - 1][2].vis && n[hh - 1][2].sec) {
        n[hh - 1][2].vis = 1;
        n[hh - 1][2].preh = hh;
        n[hh - 1][2].pres = 2;
        n[hh - 1][2].water = height.water + 1;
        q.push(n[hh - 1][2]);
      }
      if (hh + k > m || (!n[hh + k][1].vis && n[hh + k][1].sec)) {
        n[hh + k][1].h = hh + k;
        n[hh + k][1].vis = 1;
        n[hh + k][1].preh = hh;
        n[hh + k][1].pres = 2;
        n[hh + k][1].water = height.water + 1;
        q.push(n[hh + k][1]);
      }
    }
  }
  if (!flag) printf("NO\n");
  return 0;
}
