#include <bits/stdc++.h>
#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:1048576")
using namespace std;
int IT_MAX = 1 << 18;
const long long MOD = 1000000009;
const int INF = 0x3f3f3f3f;
const long long LL_INF = 1234567890123456789ll;
const double PI = acos(-1);
const double EPS = 1e-8;
char in[105][105];
char u[105][105];
bool isValid(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++) u[i][j] = x[i / (N / 3)];
    int i, j;
    for (i = 0; i < N; i++) {
      for (j = 0; j < M; j++)
        if (in[i][j] != u[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, i, j;
  scanf("%d %d", &N, &M);
  for (i = 0; i < N; i++) scanf("%s", in[i]);
  if (isValid(N, M)) return !printf("YES\n");
  for (i = 0; i < N; i++)
    for (j = 0; j < M; j++) u[j][i] = in[i][j];
  for (i = 0; i < N; i++)
    for (j = 0; j < M; j++) in[j][i] = u[j][i];
  if (isValid(M, N)) return !printf("YES\n");
  return !printf("NO\n");
}
