#include <bits/stdc++.h>
using namespace std;
int n, m, k, res;
const int MN = 110;
char d[MN][MN];
bool check() {
  cerr << "start" << endl;
  bool res = false;
  if (n % 3 != 0) return false;
  char al[] = {'R', 'B', 'G'};
  for (int p = 0; p < 6; p++) {
    bool ok = true;
    for (int k = 0; k < 3 && ok; k++) {
      for (int i = k * (n / 3); i < (k + 1) * (n / 3) && ok; i++) {
        for (int j = 0; j < m; j++) {
          if (d[i][j] != al[k]) {
            ok = false;
            cerr << "for " << al[0] << al[1] << al[2] << " ";
            cerr << i << " " << j << endl;
            break;
          }
        }
      }
    }
    res = res || ok;
    next_permutation(al, al + 3);
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int i, j, a, b;
  cin >> n >> m;
  for (i = 0; i < n; i++) cin >> d[i];
  a = check();
  for (i = 0; i < max(n, m); i++) {
    for (j = i + 1; j < max(n, m); j++) {
      b = d[i][j];
      d[i][j] = d[j][i];
      d[j][i] = b;
    }
  }
  b = n;
  n = m;
  m = b;
  cerr << "turn" << endl;
  b = check();
  if (a || b) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
