#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:167772160000")
using namespace std;
char grid[110][110];
set<char> have;
int n, m;
pair<int, int> chk(char c) {
  int minn1, minn2, maxx1, maxx2;
  minn1 = minn2 = 1000;
  maxx1 = maxx2 = -1;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (m); j++) {
      if (grid[i][j] == c) {
        minn1 = min(minn1, i);
        minn2 = min(minn2, j);
        maxx1 = max(maxx1, i);
        maxx2 = max(maxx2, j);
      }
    }
  for (int i = minn1; i <= maxx1; i++)
    for (int j = minn2; j <= maxx2; j++)
      if (grid[i][j] != c) {
        cout << "NO";
        exit(0);
      }
  return pair<int, int>(maxx1 - minn1, maxx2 - minn2);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (m); j++) {
      cin >> grid[i][j];
      have.insert(grid[i][j]);
    }
  if (have.size() != 3) {
    cout << "NO";
    return 0;
  }
  set<pair<int, int> > ans;
  ans.insert(chk('R'));
  ans.insert(chk('G'));
  ans.insert(chk('B'));
  if (ans.size() == 1) {
    cout << "YES";
  } else
    cout << "NO";
  return 0;
}
