#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, m, f = 0;
  cin >> n >> m;
  string s[n];
  for (i = 0; i < n; i++) cin >> s[i];
  if (n % 3 != 0 && m % 3 != 0) {
    cout << "NO";
    return 0;
  }
  if (n % 3 == 0) {
    int j = n / 3, x1 = 0, x2 = 0, x3 = 0;
    for (i = 0; i < n; i = i + j) {
      int h, k;
      char x = s[i][0];
      if (x1 == 0 && x == 'R')
        x1 = 1;
      else if (x2 == 0 && x == 'G')
        x2 = 1;
      else if (x3 == 0 && x == 'B')
        x3 = 1;
      else
        break;
      for (k = i; k < i + j; k++) {
        for (h = 0; h < m; h++) {
          if (s[k][h] != x) break;
        }
        if (h < m) break;
      }
      if (k < i + j) break;
    }
    if (i >= n) f = 1;
  }
  if (f == 0 && m % 3 == 0) {
    int j = m / 3, x1 = 0, x2 = 0, x3 = 0;
    for (i = 0; i < m; i = i + j) {
      int h, k;
      char x = s[0][i];
      if (x1 == 0 && x == 'R')
        x1 = 1;
      else if (x2 == 0 && x == 'G')
        x2 = 1;
      else if (x3 == 0 && x == 'B')
        x3 = 1;
      else
        break;
      for (k = i; k < i + j; k++) {
        for (h = 0; h < n; h++) {
          if (s[h][k] != x) break;
        }
        if (h < n) break;
      }
      if (k < i + j) break;
    }
    if (i >= m) f = 1;
  }
  if (f == 0)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
