#include <bits/stdc++.h>
using namespace std;
bool valid(vector<int>& col) {
  bool res = true;
  for (int i = 0; i < 6; i++) {
    int cur = i * 4;
    int v = col[cur];
    res = res && (v == col[cur + 1]) && (v == col[cur + 2]) &&
          (v == col[cur + 3]);
  }
  return res;
}
bool check(vector<int>& vec, vector<int>& left, vector<int>& right, int cur) {
  vector<int> nvec = vec;
  int idx = 4 * cur;
  nvec[left[idx]] = vec[left[idx + 1]];
  nvec[left[idx + 1]] = vec[left[idx + 3]];
  nvec[left[idx + 3]] = vec[left[idx + 2]];
  nvec[left[idx + 2]] = vec[left[idx]];
  nvec[right[idx]] = vec[right[idx + 1]];
  nvec[right[idx + 1]] = vec[right[idx + 3]];
  nvec[right[idx + 3]] = vec[right[idx + 2]];
  nvec[right[idx + 2]] = vec[right[idx]];
  if (valid(nvec)) return true;
  nvec = vec;
  nvec[left[idx + 1]] = vec[left[idx]];
  nvec[left[idx]] = vec[left[idx + 2]];
  nvec[left[idx + 2]] = vec[left[idx + 3]];
  nvec[left[idx + 3]] = vec[left[idx + 1]];
  nvec[right[idx + 1]] = vec[right[idx]];
  nvec[right[idx]] = vec[right[idx + 2]];
  nvec[right[idx + 2]] = vec[right[idx + 3]];
  nvec[right[idx + 3]] = vec[right[idx + 1]];
  if (valid(nvec)) return true;
  return false;
}
int main() {
  vector<int> left = {12, 20, 4,  16, 13, 3, 8, 18, 15, 7, 23, 19,
                      21, 2,  10, 6,  5,  1, 9, 22, 17, 0, 11, 14};
  vector<int> right(24, 0), vec(24, 0);
  for (int i = 0; i < left.size(); i++) right[left[i]] = i;
  for (int i = 0; i < left.size(); i++) cin >> vec[i];
  bool possible = false;
  for (int i = 0; i < 6; i++) {
    if (!possible)
      possible = check(vec, left, right, i);
    else
      break;
  }
  if (possible)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
