#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
const int maxm = 1000 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long LINF = (1LL << 62);
const double PI = acos(-1.0);
int a[maxn], ini[maxn];
int b[6][8] = {{6, 5, 14, 13, 22, 21, 18, 17}, {8, 7, 16, 15, 24, 23, 20, 19},
               {1, 3, 5, 7, 9, 11, 24, 22},    {2, 4, 6, 8, 10, 12, 23, 21},
               {2, 1, 13, 15, 11, 12, 20, 18}, {4, 3, 14, 16, 9, 10, 19, 17}};
bool check() {
  for (int i = 0; i < 6; i++) {
    int x = a[i * 4 + 1];
    for (int j = i * 4 + 1; j <= i * 4 + 4; j++) {
      if (a[j] != x) return false;
    }
  }
  return true;
}
void cw_change(int k) {
  int x1 = a[b[k][6]], x2 = a[b[k][7]];
  for (int i = 7; i >= 2; i--) {
    a[b[k][i]] = a[b[k][i - 2]];
  }
  a[b[k][0]] = x1;
  a[b[k][1]] = x2;
}
void ccw_change(int k) {
  int x1 = a[b[k][0]], x2 = a[b[k][1]];
  for (int i = 0; i < 6; i++) {
    a[b[k][i]] = a[b[k][i + 2]];
  }
  a[b[k][6]] = x1;
  a[b[k][7]] = x2;
}
void init() {
  for (int i = 1; i <= 24; i++) a[i] = ini[i];
}
int main() {
  for (int i = 1; i <= 24; i++) {
    cin >> a[i];
    ini[i] = a[i];
  }
  bool flag = false;
  for (int i = 0; i < 6; i++) {
    init();
    cw_change(i);
    if (check()) {
      flag = true;
      break;
    }
    init();
    ccw_change(i);
    if (check()) {
      flag = true;
      break;
    }
  }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
