#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n, m;
  cin >> n >> m;
  string s[n];
  for (long long int i = 0; i < n; i++) cin >> s[i];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (s[i][j] == 'R') s[i][j] = '0';
      if (s[i][j] == 'G') s[i][j] = '1';
      if (s[i][j] == 'B') s[i][j] = '2';
    }
  }
  if (m % 3 and n % 3) {
    cout << "NO";
    exit(0);
  }
  if (n % 3 == 0) {
    long long int t = n / 3;
    long long int cnt[3] = {0, 0, 0};
    char c = s[0][0];
    for (long long int i = 0; i < t; i++) {
      for (long long int j = 0; j < m; j++) {
        if (s[i][j] == c) cnt[c - '0']++;
      }
    }
    c = s[t][0];
    for (long long int i = t; i < 2 * t; i++) {
      for (long long int j = 0; j < m; j++) {
        if (s[i][j] == c) cnt[c - '0']++;
      }
    }
    c = s[2 * t][0];
    for (long long int i = 2 * t; i < n; i++) {
      for (long long int j = 0; j < m; j++) {
        if (s[i][j] == c) cnt[c - '0']++;
      }
    }
    if (cnt[0] == m * t and cnt[1] == m * t and cnt[2] == m * t) {
      cout << "YES";
      exit(0);
    }
  }
  if (m % 3 == 0) {
    long long int t = m / 3;
    long long int cnt[3] = {0, 0, 0};
    char c = s[0][0];
    for (long long int j = 0; j < t; j++) {
      for (long long int i = 0; i < n; i++) {
        if (s[i][j] == c) cnt[c - '0']++;
      }
    }
    c = s[0][t];
    for (long long int j = t; j < 2 * t; j++) {
      for (long long int i = 0; i < n; i++) {
        if (s[i][j] == c) cnt[c - '0']++;
      }
    }
    c = s[0][2 * t];
    for (long long int j = 2 * t; j < m; j++) {
      for (long long int i = 0; i < n; i++) {
        if (s[i][j] == c) cnt[c - '0']++;
      }
    }
    if (cnt[0] == n * t and cnt[1] == n * t and cnt[2] == n * t) {
      cout << "YES";
      exit(0);
    }
  }
  cout << "NO";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int T = 1;
  while (T--) solve();
  return 0;
}
