#include <bits/stdc++.h>
using namespace std;
int color[30];
int colornow[30];
int op0[10][10] = {{2, 4, 6, 8, 10, 12, 23, 21},
                   {3, 4, 17, 19, 10, 9, 16, 14},
                   {13, 14, 5, 6, 17, 18, 21, 22}};
int op1[10][10] = {{6, 8, 10, 12, 23, 21, 2, 4},
                   {17, 19, 10, 9, 16, 14, 3, 4},
                   {5, 6, 17, 18, 21, 22, 13, 14}};
int op2[10][10] = {{23, 21, 2, 4, 6, 8, 10, 12},
                   {16, 14, 3, 4, 17, 19, 10, 9},
                   {21, 22, 13, 14, 5, 6, 17, 18}};
int vis[30];
int isok() {
  int ret = 0;
  for (int i = 1; i <= 24; i += 4) {
    if (colornow[i] == colornow[i + 1] && colornow[i + 1] == colornow[i + 2] &&
        colornow[i + 2] == colornow[i + 3]) {
      ret++;
    }
  }
  if (ret == 6) return 1;
  return 0;
}
int main() {
  for (int i = 1; i <= 24; i++) scanf("%d", &color[i]);
  int flag = 0;
  for (int i = 0; i < 3; i++) {
    memset(vis, 0, sizeof(vis));
    for (int j = 0; j < 8; j++) {
      colornow[op0[i][j]] = color[op1[i][j]];
      vis[op0[i][j]] = 1;
    }
    for (int j = 1; j <= 24; j++) {
      if (!vis[j]) colornow[j] = color[j];
    }
    if (isok()) flag = 1;
    memset(vis, 0, sizeof(vis));
    for (int j = 0; j < 8; j++) {
      colornow[op0[i][j]] = color[op2[i][j]];
      vis[op0[i][j]] = 1;
    }
    for (int j = 1; j <= 24; j++) {
      if (!vis[j]) colornow[j] = color[j];
    }
    if (isok()) flag = 1;
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
