#include <bits/stdc++.h>
using namespace std;
int a[30], b[30];
vector<int> v;
bool is() {
  for (int i = 1; i <= 24; i += 4) {
    for (int j = i; j < i + 4; j++) {
      if (b[j] != b[i]) return 0;
    }
  }
  return 1;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 1; i <= 24; i++) cin >> a[i];
  for (int i = 1; i <= 24; i++) b[i] = a[i];
  v.push_back(1), v.push_back(3), v.push_back(5), v.push_back(7),
      v.push_back(9), v.push_back(11), v.push_back(24), v.push_back(22);
  for (int i = 0; i < 8; i++) {
    b[v[(i + 2) % 8]] = a[v[i]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < 8; i++) {
    b[v[i]] = a[v[(i + 2) % 8]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  v.clear();
  for (int i = 1; i <= 24; i++) b[i] = a[i];
  v.push_back(2), v.push_back(4), v.push_back(6), v.push_back(8),
      v.push_back(10), v.push_back(12), v.push_back(23), v.push_back(21);
  for (int i = 0; i < 8; i++) {
    b[v[(i + 2) % 8]] = a[v[i]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < 8; i++) {
    b[v[i]] = a[v[(i + 2) % 8]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  v.clear();
  for (int i = 1; i <= 24; i++) b[i] = a[i];
  v.push_back(13), v.push_back(14), v.push_back(5), v.push_back(6),
      v.push_back(17), v.push_back(18), v.push_back(21), v.push_back(22);
  for (int i = 0; i < 8; i++) {
    b[v[(i + 2) % 8]] = a[v[i]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < 8; i++) {
    b[v[i]] = a[v[(i + 2) % 8]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  v.clear();
  for (int i = 1; i <= 24; i++) b[i] = a[i];
  v.push_back(15), v.push_back(16), v.push_back(7), v.push_back(8),
      v.push_back(19), v.push_back(20), v.push_back(23), v.push_back(24);
  for (int i = 0; i < 8; i++) {
    b[v[(i + 2) % 8]] = a[v[i]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < 8; i++) {
    b[v[i]] = a[v[(i + 2) % 8]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  v.clear();
  for (int i = 1; i <= 24; i++) b[i] = a[i];
  v.push_back(3), v.push_back(4), v.push_back(17), v.push_back(19),
      v.push_back(10), v.push_back(9), v.push_back(16), v.push_back(14);
  for (int i = 0; i < 8; i++) {
    b[v[(i + 2) % 8]] = a[v[i]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < 8; i++) {
    b[v[i]] = a[v[(i + 2) % 8]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  v.clear();
  for (int i = 1; i <= 24; i++) b[i] = a[i];
  v.push_back(1), v.push_back(2), v.push_back(22), v.push_back(24),
      v.push_back(12), v.push_back(11), v.push_back(15), v.push_back(13);
  for (int i = 0; i < 8; i++) {
    b[v[(i + 2) % 8]] = a[v[i]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  for (int i = 0; i < 8; i++) {
    b[v[i]] = a[v[(i + 2) % 8]];
  }
  if (is()) {
    cout << "YES";
    return 0;
  }
  v.clear();
  cout << "NO";
  return 0;
}
