#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const int N = 1e3 + 10, M = 1e6 + 10, inf = 1e9 + 7, MOD = 1e9 + 7;
const long long INF = 1e18 + 10, mod = 1e9 + 7;
char a[N][N];
map<char, int> mp;
char check(int l, int r, int m) {
  for (int j = l; j <= r; j++) {
    for (int i = 1; i <= m; i++)
      if (a[j][i] != a[l][1]) return ' ';
  }
  return a[l][1];
}
char check1(int l, int r, int n) {
  for (int i = l; i <= r; i++) {
    for (int j = 1; j <= n; j++)
      if (a[j][i] != a[1][l]) return ' ';
  }
  return a[1][l];
}
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", a[i] + 1);
  if (n % 3 == 0) {
    mp[check(1, n / 3, m)]++;
    mp[check(n / 3 + 1, n * 2 / 3, m)]++;
    mp[check(n * 2 / 3 + 1, n, m)]++;
    if (mp['R'] && mp['G'] && mp['B']) return 0 * printf("YES");
  }
  if (m % 3 == 0) {
    mp.clear();
    mp[check1(1, m / 3, n)]++;
    mp[check1(m / 3 + 1, m * 2 / 3, n)]++;
    mp[check1(m * 2 / 3 + 1, m, n)]++;
    if (mp['R'] && mp['G'] && mp['B']) return 0 * printf("YES");
  }
  printf("NO\n");
  return 0;
}
