#include <bits/stdc++.h>
using namespace std;
template <typename t>
using V = vector<t>;
int n, m;
bool fl;
V<V<int> > tab;
V<V<int> > tab2;
bool spr(V<V<int> >& tab, int v) {
  int i = 0;
  for (int k = 0; k < 3; ++k) {
    int st = i;
    for (; i < (k + 1) * v; ++i)
      for (int j = 0; j < tab[i].size(); ++j)
        if (tab[i][j] != tab[st][0]) return false;
  }
  fl = (tab[0][0] != tab[v][0]) and (tab[v][0] != tab[v * 2][0]) and
       (tab[v * 2][0] != tab[0][0]);
  return true;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> m;
  tab.resize(n, V<int>(m));
  tab2.resize(m, V<int>(n));
  for (int i = 0; i < n; ++i)
    for (int k = 0; k < m; ++k) {
      char c;
      cin >> c;
      if (c == 'R') {
        tab[i][k] = 0;
        tab2[k][i] = 0;
      }
      if (c == 'B') {
        tab[i][k] = 1;
        tab2[k][i] = 1;
      }
      if (c == 'G') {
        tab[i][k] = 2;
        tab2[k][i] = 2;
      }
    }
  if (n % 3 == 0) spr(tab, n / 3);
  if (m % 3 == 0) spr(tab2, m / 3);
  cout << (fl ? "YES" : "NO") << '\n';
}
