#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
int m, n, num[3];
char g[110][110];
char p[3] = {'B', 'R', 'G'};
bool vis[4];
int main() {
  while (~scanf("%d%d", &m, &n)) {
    int flag = 1;
    memset(vis, 0, sizeof vis);
    memset(num, 0, sizeof num);
    for (int(i) = 0; (i) < (m); (i)++) {
      scanf("%s", g[i]);
      for (int(j) = 0; (j) < (n); (j)++)
        for (int(k) = 0; (k) < (3); (k)++)
          if (g[i][j] == p[k]) num[k]++;
    }
    if (num[0] != num[1] || num[1] != num[2] || num[2] != num[0] ||
        m % 3 && n % 3) {
      puts("NO");
      continue;
    }
    if (m == 1) {
      for (int(i) = 0; (i) < (3); (i)++) {
        int y = -1;
        int o = i * n / 3;
        for (int(j) = 0; (j) < (3); (j)++)
          if (!vis[j] && g[0][o] == p[j]) vis[j] = 1, y = j;
        if (y == -1) {
          flag = 0;
          break;
        }
        for (int(j) = 0; (j) < (n / 3); (j)++) {
          if (g[0][j + o] != p[y]) {
            flag = 0;
            break;
          }
        }
      }
      puts(flag ? "YES" : "NO");
      continue;
    } else if (n == 1) {
      for (int(i) = 0; (i) < (3); (i)++) {
        int y = -1;
        int o = i * m / 3;
        for (int(j) = 0; (j) < (3); (j)++)
          if (!vis[j] && g[o][0] == p[j]) vis[j] = 1, y = j;
        if (y == -1) {
          flag = 0;
          break;
        }
        for (int(j) = 0; (j) < (m / 3); (j)++) {
          if (g[o + j][0] != p[y]) {
            flag = 0;
            break;
          }
        }
      }
      puts(flag ? "YES" : "NO");
      continue;
    }
    int tag = 1;
    int x = -1;
    for (int(i) = 0; (i) < (3); (i)++)
      if (g[0][0] == p[i]) {
        x = i;
        break;
      }
    for (int(i) = 0; (i) < (n); (i)++)
      if (g[0][i] != p[x]) {
        tag = 0;
        break;
      }
    if (!tag) {
      bool rt[110][110];
      memset(rt, 0, sizeof rt);
      for (int(i) = 0; (i) < (m); (i)++)
        for (int(j) = 0; (j) < (n); (j)++)
          if (!rt[i][j] && !rt[j][i]) {
            swap(g[i][j], g[j][i]);
            rt[i][j] = rt[j][i] = 1;
          }
      swap(m, n);
    }
    if (m % 3) {
      puts("NO");
      continue;
    }
    for (int i = 0; i < 3; i++) {
      int v = m / 3 * i;
      int y = -1;
      for (int j = 0; j < 3; j++)
        if (!vis[j] && p[j] == g[v][0]) vis[j] = 1, y = j;
      if (y == -1) {
        flag = 0;
        break;
      }
      for (int(k) = 0; (k) < (m / 3); (k)++) {
        int o = k + m / 3 * i;
        for (int(j) = 0; (j) < (n); (j)++) {
          if (g[o][j] == p[y])
            continue;
          else {
            flag = 0;
            break;
          }
        }
      }
    }
    puts(flag ? "YES" : "NO");
  }
  return 0;
}
