#include <bits/stdc++.h>
using namespace std;
int a[30];
bool checkFace(int i) {
  for (int j = 1; j <= 3; j++) {
    if (a[i] != a[i + j]) {
      return false;
    }
  }
  return true;
}
bool check() {
  if (checkFace(1) && checkFace(5) && checkFace(9) && checkFace(13) &&
      checkFace(17) && checkFace(21)) {
    return true;
  }
  return false;
}
bool rotateAndCheck(int x[4][2]) {
  int y = a[x[0][0]];
  int z = a[x[0][1]];
  for (int i = 0; i <= 2; i++) {
    a[x[i][0]] = a[x[i + 1][0]];
    a[x[i][1]] = a[x[i + 1][1]];
  }
  a[x[3][0]] = y;
  a[x[3][1]] = z;
  if (check()) {
    return true;
  }
  for (int count = 1; count <= 2; count++) {
    y = a[x[0][0]];
    z = a[x[0][1]];
    for (int i = 0; i >= -2; i--) {
      a[x[(i + 4) % 4][0]] = a[x[(i + 3) % 4][0]];
      a[x[(i + 4) % 4][1]] = a[x[(i + 3) % 4][1]];
    }
    a[x[1][0]] = y;
    a[x[1][1]] = z;
  }
  if (check()) {
    return true;
  }
  y = a[x[0][0]];
  z = a[x[0][1]];
  for (int i = 0; i <= 2; i++) {
    a[x[i][0]] = a[x[i + 1][0]];
    a[x[i][1]] = a[x[i + 1][1]];
  }
  a[x[3][0]] = y;
  a[x[3][1]] = z;
  return false;
}
int main() {
  for (int j = 1; j <= 24; j++) {
    cin >> a[j];
  }
  int b[4][2] = {{1, 3}, {5, 7}, {9, 11}, {24, 22}};
  if (rotateAndCheck(b)) {
    cout << "YES";
    return 0;
  }
  int c[4][2] = {{2, 4}, {6, 8}, {10, 12}, {23, 21}};
  if (rotateAndCheck(c)) {
    cout << "YES";
    return 0;
  }
  int d[4][2] = {{3, 4}, {17, 19}, {10, 9}, {16, 14}};
  if (rotateAndCheck(d)) {
    cout << "YES";
    return 0;
  }
  int e[4][2] = {{1, 2}, {18, 20}, {12, 11}, {15, 13}};
  if (rotateAndCheck(e)) {
    cout << "YES";
    return 0;
  }
  int f[4][2] = {{7, 8}, {15, 16}, {23, 24}, {19, 20}};
  if (rotateAndCheck(f)) {
    cout << "YES";
    return 0;
  }
  int g[4][2] = {{5, 6}, {13, 14}, {21, 22}, {17, 18}};
  if (rotateAndCheck(g)) {
    cout << "YES";
    return 0;
  }
  cout << "NO";
  return 0;
}
