#include <bits/stdc++.h>
char flag[105][105];
int row_check(int row, int column) {
  int i, j, k;
  int base;
  int stripe = row / 3;
  int color[3] = {0, 0, 0};
  for (i = 0; i < 3; i++) {
    base = i * stripe;
    if (flag[base][0] == 'R') color[0]++;
    if (flag[base][0] == 'G') color[1]++;
    if (flag[base][0] == 'B') color[2]++;
    for (j = base; j < base + stripe; j++)
      for (k = 0; k < column; k++)
        if (flag[j][k] != flag[base][0]) return 0;
  }
  if (color[0] == color[1] && color[0] == color[2] && color[0] == 1)
    return 1;
  else
    return 0;
}
int column_check(int row, int column) {
  int i, j, k;
  int base;
  int stripe = column / 3;
  int color[3] = {0, 0, 0};
  for (i = 0; i < 3; i++) {
    base = i * stripe;
    if (flag[0][base] == 'R') color[0]++;
    if (flag[0][base] == 'G') color[1]++;
    if (flag[0][base] == 'B') color[2]++;
    for (j = base; j < base + stripe; j++)
      for (k = 0; k < row; k++)
        if (flag[k][j] != flag[0][base]) return 0;
  }
  if (color[0] == color[1] && color[0] == color[2] && color[0] == 1)
    return 1;
  else
    return 0;
}
void flag_berland() {
  int row, column;
  int i, j;
  int row_c, column_c;
  scanf("%d %d", &row, &column);
  getchar();
  for (i = 0; i < row; i++) {
    gets(flag[i]);
  }
  row_c = column_c = 0;
  if (row % 3 == 0) row_c = row_check(row, column);
  if (column % 3 == 0) column_c = column_check(row, column);
  if (row_c || column_c)
    printf("YES");
  else
    printf("NO");
  return;
}
int main() {
  flag_berland();
  return 0;
}
