#include <bits/stdc++.h>
using namespace std;
int main() {
  char s1[4];
  char s2[4];
  cin >> s1[0] >> s1[1] >> s1[3] >> s1[2];
  cin >> s2[0] >> s2[1] >> s2[3] >> s2[2];
  string rs1, rs2;
  for (int i = 0; i < 4; i++) {
    if (s1[i] != 'X') rs1 += s1[i];
  }
  for (int i = 0; i < 4; i++) {
    if (s2[i] != 'X') rs2 += s2[i];
  }
  for (int i = 0; i < 3; i++) {
    bool ok = true;
    for (int j = 0; j < 3; j++) {
      ok &= (rs1[j] == rs2[(j + i) % 3]);
    }
    if (ok) {
      cout << "YES\n";
      return 0;
    }
  }
  cout << "NO\n";
  return 0;
}
