#include <bits/stdc++.h>
using namespace std;
const int maxn = 100 + 1;
int n, m;
char a[maxn][maxn];
int minx[300], maxx[300], miny[300], maxy[300];
inline void Max(int &a, int b) {
  if (a < b) a = b;
}
inline void Min(int &a, int b) {
  if (a > b) a = b;
}
char str[4] = "RGB";
inline bool solve() {
  for (int i = 0; i < 3; ++i)
    if (maxx[str[i]] - minx[str[i]] != maxx[str[0]] - minx[str[0]])
      return false;
    else if (maxy[str[i]] - miny[str[i]] != maxy[str[0]] - miny[str[0]])
      return false;
  if (3 * (maxx[str[0]] - minx[str[0]] + 1) *
          (maxy[str[0]] - miny[str[0]] + 1) !=
      n * m)
    return false;
  return true;
}
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; ++i) scanf("%s", a[i]);
  memset(minx, 7, sizeof(minx));
  memset(miny, 7, sizeof(miny));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      Max(maxx[a[i][j]], i);
      Max(maxy[a[i][j]], j);
      Min(minx[a[i][j]], i);
      Min(miny[a[i][j]], j);
    }
  }
  puts(solve() ? "YES" : "NO");
}
