#include <bits/stdc++.h>
using namespace std;
char s[110][110];
void get_ans(int n, int m, char c, int &x, int &y) {
  x = -1, y = -1;
  int x1 = -1, y1 = -1, x2 = -1, y2 = -1;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (s[i][j] == c) {
        if (x1 == -1) x1 = i, y1 = j;
        x2 = i, y2 = j;
      }
  if (x1 == -1) return;
  for (int i = x1; i <= x2; i++)
    for (int j = y1; j <= y2; j++)
      if (s[i][j] != c) return;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if ((i >= x1 && i <= x2 && j >= y1 && j <= y2))
        continue;
      else if (s[i][j] == c)
        return;
  x = x2 - x1 + 1;
  y = y2 - y1 + 1;
}
int main() {
  int x1, y1, x2, y2, x3, y3;
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> s[i];
  get_ans(n, m, 'R', x1, y1);
  get_ans(n, m, 'G', x2, y2);
  get_ans(n, m, 'B', x3, y3);
  if (x1 == -1 || x2 == -1 || x3 == -3) {
    printf("NO\n");
    return 0;
  }
  if (x1 == x2 && x1 == x3 && y1 == y2 && y1 == y3)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
