#include <bits/stdc++.h>
using namespace std;
char W[110][110];
int n, m;
map<char, int> M;
int len[3];
bool rows() {
  int msk = 0;
  memset(len, 0, sizeof(len));
  for (int i = 0; i < n; i++) {
    int c = M[W[i][0]];
    if (!i || (i && W[i - 1][0] != W[i][0])) {
      if (msk & (1 << c)) return false;
      msk |= (1 << c);
      len[c] = 1;
    } else
      len[c]++;
    for (int j = 1; j < m; j++) {
      if (W[i][j] != W[i][j - 1]) return false;
    }
  }
  return msk == 7 && len[0] == len[1] && len[1] == len[2];
}
bool cols() {
  int msk = 0;
  memset(len, 0, sizeof(len));
  for (int i = 0; i < m; i++) {
    int c = M[W[0][i]];
    if (!i || (i && W[0][i - 1] != W[0][i])) {
      if (msk & (1 << c)) return false;
      msk |= (1 << c);
      len[c] = 1;
    } else
      len[c]++;
    for (int j = 1; j < n; j++) {
      if (W[j][i] != W[j - 1][i]) return false;
    }
  }
  return msk == 7 && len[0] == len[1] && len[1] == len[2];
}
string ans[2] = {"NO", "YES"};
int main() {
  M['R'] = 0;
  M['G'] = 1;
  M['B'] = 2;
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", W[i]);
  printf("%s\n", ans[rows() || cols()].c_str());
  return 0;
}
