#include <bits/stdc++.h>
int m[24] = {1,  2,  3,  4,  13, 14, 15, 16, 5, 6,  7,  8,
             17, 18, 19, 20, 21, 22, 23, 24, 9, 10, 11, 12};
int c[6][24] = {0,  9,  2,  11, 4,  5,  6,  7,  8,  21, 10, 23, 14, 12, 15, 13,
                3,  17, 1,  19, 20, 18, 22, 16, 0,  18, 2,  16, 4,  5,  6,  7,
                8,  1,  10, 3,  13, 15, 12, 14, 23, 17, 21, 19, 20, 9,  22, 11,
                2,  0,  3,  1,  8,  9,  6,  7,  12, 13, 10, 11, 16, 17, 14, 15,
                4,  5,  18, 19, 20, 21, 22, 23, 1,  3,  0,  2,  16, 17, 6,  7,
                4,  5,  10, 11, 8,  9,  14, 15, 12, 13, 18, 19, 20, 21, 22, 23,
                13, 15, 2,  3,  1,  5,  0,  7,  8,  9,  10, 11, 12, 23, 14, 22,
                18, 16, 19, 17, 20, 21, 4,  6,  6,  4,  2,  3,  22, 5,  23, 7,
                8,  9,  10, 11, 12, 0,  14, 1,  17, 19, 16, 18, 20, 21, 15, 13};
int main() {
  int a[25], b[24];
  for (int i = 1; i <= 24; i++) scanf("%d", &a[i]);
  for (int i = 0; i < 24; i++) b[i] = a[m[i]];
  for (int i = 0; i < 6; i++) {
    bool che = true;
    for (int j = 0; j < 6; j++)
      if (b[c[i][j * 4]] != b[c[i][j * 4 + 1]] ||
          b[c[i][j * 4]] != b[c[i][j * 4 + 2]] ||
          b[c[i][j * 4]] != b[c[i][j * 4 + 3]])
        che = false;
    if (che) {
      printf("YES");
      return 0;
    }
  }
  printf("NO");
  return 0;
}
