#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int n, m;
char s[110][110];
int mk[4];
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (s[i][j] == 'B')
        s[i][j] = 1;
      else if (s[i][j] == 'G')
        s[i][j] = 2;
      else if (s[i][j] == 'R')
        s[i][j] = 3;
  if (n % 3 == 0) {
    mk[1] = mk[2] = mk[3] = 0;
    bool mrk = 1;
    int col = -1;
    for (int i = 1; i <= n / 3; i++)
      for (int j = 1; j <= m; j++)
        if (col == -1)
          col = s[i][j];
        else if (col != s[i][j]) {
          mrk = 0;
          break;
        }
    if (mrk) mk[col] = 1;
    col = -1;
    for (int i = 1 + n / 3; i <= 2 * n / 3; i++)
      for (int j = 1; j <= m; j++)
        if (col == -1)
          col = s[i][j];
        else if (col != s[i][j]) {
          mrk = 0;
          break;
        }
    if (mrk) mk[col] = 1;
    col = -1;
    for (int i = 1 + 2 * n / 3; i <= n; i++)
      for (int j = 1; j <= m; j++)
        if (col == -1)
          col = s[i][j];
        else if (col != s[i][j]) {
          mrk = 0;
          break;
        }
    if (mrk) mk[col] = 1;
    if (mrk && mk[1] && mk[2] && mk[3]) {
      puts("YES");
      return 0;
    }
  }
  if (m % 3 == 0) {
    mk[1] = mk[2] = mk[3] = 0;
    bool mrk = 1;
    int col = -1;
    for (int j = 1; j <= m / 3; j++)
      for (int i = 1; i <= n; i++)
        if (col == -1)
          col = s[i][j];
        else if (col != s[i][j]) {
          mrk = 0;
          break;
        }
    if (mrk) mk[col] = 1;
    col = -1;
    for (int j = 1 + m / 3; j <= 2 * m / 3; j++)
      for (int i = 1; i <= n; i++)
        if (col == -1)
          col = s[i][j];
        else if (col != s[i][j]) {
          mrk = 0;
          break;
        }
    if (mrk) mk[col] = 1;
    col = -1;
    for (int j = 1 + 2 * m / 3; j <= m; j++)
      for (int i = 1; i <= n; i++)
        if (col == -1)
          col = s[i][j];
        else if (col != s[i][j]) {
          mrk = 0;
          break;
        }
    if (mrk) mk[col] = 1;
    if (mrk && mk[1] && mk[2] && mk[3]) {
      puts("YES");
      return 0;
    }
  }
  puts("NO");
}
