#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const int N = 100100;
int n, m;
char a[202][202];
bool solve1() {
  int r = 0, b = 0, g = 0;
  vector<int> v[3];
  for (int i = 0; i < n; i++) {
    char al = a[i][0];
    if (al == 'R') v[0].push_back(i);
    if (al == 'B') v[1].push_back(i);
    if (al == 'G') v[2].push_back(i);
    for (int j = 0; j < m; j++) {
      if (al != a[i][j]) return 0;
    }
  }
  if (v[0].size() != v[1].size() || v[0].size() != v[2].size()) return 0;
  for (int i = 1; i < v[0].size(); i++) {
    if (v[0][i] - v[0][i - 1] > 1) return 0;
  }
  for (int i = 1; i < v[1].size(); i++) {
    if (v[1][i] - v[1][i - 1] > 1) return 0;
  }
  for (int i = 1; i < v[2].size(); i++) {
    if (v[2][i] - v[2][i - 1] > 1) return 0;
  }
  return 1;
}
bool solve2() {
  int r = 0, b = 0, g = 0;
  vector<int> v[3];
  for (int j = 0; j < m; j++) {
    char al = a[0][j];
    if (al == 'R') v[0].push_back(j);
    if (al == 'B') v[1].push_back(j);
    if (al == 'G') v[2].push_back(j);
    for (int i = 0; i < n; i++) {
      if (al != a[i][j]) return 0;
    }
  }
  if (v[0].size() != v[1].size() || v[0].size() != v[2].size()) return 0;
  for (int i = 1; i < v[0].size(); i++) {
    if (v[0][i] - v[0][i - 1] > 1) return 0;
  }
  for (int i = 1; i < v[1].size(); i++) {
    if (v[1][i] - v[1][i - 1] > 1) return 0;
  }
  for (int i = 1; i < v[2].size(); i++) {
    if (v[2][i] - v[2][i - 1] > 1) return 0;
  }
  return 1;
}
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  if (solve1() || solve2())
    cout << "YES" << endl;
  else
    cout << "NO";
  return 0;
}
