#include <bits/stdc++.h>
using namespace std;
int n, m;
char s[105][105];
bool f1() {
  if (n % 3) return false;
  char t1 = s[1][1], t2 = s[n / 3 + 1][1], t3 = s[n / 3 + n / 3 + 1][1];
  if (t1 == t2 || t1 == t3 || t2 == t3 || t1 + t2 + t3 != 'R' + 'G' + 'B')
    return false;
  for (int i = 1; i <= n / 3; i++) {
    for (int j = 1; j <= m; j++)
      if (s[i][j] != t1) return false;
  }
  for (int i = n / 3 + 1; i <= n / 3 + n / 3; i++) {
    for (int j = 1; j <= m; j++)
      if (s[i][j] != t2) return false;
  }
  for (int i = n / 3 + n / 3 + 1; i <= n; i++) {
    for (int j = 1; j <= m; j++)
      if (s[i][j] != t3) return false;
  }
  return true;
}
bool f2() {
  if (m % 3) return false;
  char t1 = s[1][1], t2 = s[1][m / 3 + 1], t3 = s[1][m / 3 + m / 3 + 1];
  if (t1 == t2 || t1 == t3 || t2 == t3 || t1 + t2 + t3 != 'R' + 'G' + 'B')
    return false;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m / 3; j++)
      if (s[i][j] != t1) return false;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m / 3 + 1; j <= m / 3 + m / 3; j++)
      if (s[i][j] != t2) return false;
  }
  for (int i = 1; i <= n; i++) {
    for (int j = m / 3 + m / 3 + 1; j <= m; j++)
      if (s[i][j] != t3) return false;
  }
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) scanf(" %c", &s[i][j]);
  printf(f1() || f2() ? "YES" : "NO");
}
