#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios ::sync_with_stdio(false);
  cin.tie(0);
  long long n, m;
  cin >> n >> m;
  char matrix[n + 1][m + 1];
  for (long long i = 1; i <= n; i++) {
    string s;
    cin >> s;
    for (long long j = 1; j <= m; j++) {
      matrix[i][j] = s[j - 1];
    }
  }
  set<char> row[3], col[3];
  bool ans_row = 0, ans_col = 0;
  map<char, long long> r, c;
  if (n % 3 == 0) {
    long long pp = n / 3;
    ans_row = 1;
    for (long long i = 0; i < 3; i++) {
      long long start = (i * pp) + 1;
      long long endd = start + pp - 1;
      for (long long j = start; j <= endd; j++) {
        for (long long k = 1; k <= m; k++) {
          row[i].insert(matrix[j][k]);
        }
      }
      if (row[i].size() > 1) ans_row = 0;
      r[*row[i].begin()] += 1;
    }
  }
  if (m % 3 == 0) {
    long long pp = m / 3;
    ans_col = 1;
    for (long long i = 0; i < 3; i++) {
      long long start = (i * pp) + 1;
      long long endd = start + pp - 1;
      for (long long j = start; j <= endd; j++) {
        for (long long k = 1; k <= n; k++) {
          col[i].insert(matrix[k][j]);
        }
      }
      if (col[i].size() > 1) ans_col = 0;
      c[*col[i].begin()] += 1;
    }
  }
  if (ans_row == 1 && r['R'] == 1 && r['G'] == 1 && r['B'] == 1) {
    cout << "YES\n";
  } else if (ans_col == 1 && c['R'] == 1 && c['G'] == 1 && c['B'] == 1) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
