#include <bits/stdc++.h>
using namespace std;
const int maxn = 110;
char maze1[maxn][maxn], maze2[maxn][maxn];
bool check(int n, int m) {
  if (n % 3) return false;
  char x[4] = "BGR";
  do {
    for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++) maze2[i][j] = x[i / (n / 3)];
    int i, j;
    for (i = 0; i < n; i++) {
      for (j = 0; j < m; j++)
        if (maze1[i][j] != maze2[i][j]) break;
      if (j < m) break;
    }
    if (i >= n) return true;
  } while (next_permutation(x, x + 3));
  return false;
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", maze1[i]);
  if (check(n, m)) {
    printf("YES");
    return 0;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      maze2[j][i] = maze1[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      maze1[j][i] = maze2[j][i];
    }
  }
  if (check(m, n)) {
    puts("YES");
    return 0;
  }
  puts("NO");
  return 0;
}
