#include <bits/stdc++.h>
using namespace std;
int n, m;
vector<string> s;
int fver() {
  char b1 = s[0][0];
  if (b1 == 'R' || b1 == 'G' || b1 == 'B')
    for (int i = 0; i < m / 3; i++)
      for (int j = 0; j < n; j++) {
        if (s[j][i] != b1) {
          return 0;
        }
      }
  else {
    return 0;
  }
  char b2 = s[0][m / 3];
  if ((b2 == 'R' || b2 == 'G' || b2 == 'B') && b2 != b1)
    for (int i = m / 3; i < 2 * m / 3; i++)
      for (int j = 0; j < n; j++) {
        if (s[j][i] != b2) {
          return 0;
        }
      }
  else {
    return 0;
  }
  char b3 = s[0][2 * m / 3];
  if ((b3 == 'R' || b3 == 'G' || b3 == 'B') && b3 != b2 && b3 != b1)
    for (int i = 2 * m / 3; i < m; i++)
      for (int j = 0; j < n; j++) {
        if (s[j][i] != b3) {
          return 0;
        }
      }
  else {
    return 0;
  }
  cout << "YES";
  return 1;
}
int fgor() {
  char b1 = s[0][0];
  if (b1 == 'R' || b1 == 'G' || b1 == 'B')
    for (int i = 0; i < n / 3; i++)
      for (int j = 0; j < m; j++) {
        if (s[i][j] != b1) return 0;
      }
  else {
    return 0;
  }
  char b2 = s[n / 3][0];
  if ((b2 == 'R' || b2 == 'G' || b2 == 'B') && b2 != b1)
    for (int i = n / 3; i < 2 * n / 3; i++)
      for (int j = 0; j < m; j++) {
        if (s[i][j] != b2) return 0;
      }
  else {
    return 0;
  }
  char b3 = s[2 * n / 3][0];
  if ((b3 == 'R' || b3 == 'G' || b3 == 'B') && b3 != b2 && b3 != b1)
    for (int i = 2 * n / 3; i < n; i++)
      for (int j = 0; j < m; j++) {
        if (s[i][j] != b3) return 0;
      }
  else {
    return 0;
  }
  cout << "YES";
  return 1;
}
int main() {
  std::ios_base::sync_with_stdio(false);
  cin >> n >> m;
  if (m % 3 != 0 && n % 3 != 0) {
    cout << "NO";
    return 0;
  }
  s.resize(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  if (n % 3 == 0) {
    int ans = fgor();
    if (ans == 1) return 0;
  }
  if (m % 3 == 0) {
    int ans = fver();
    if (ans == 1) return 0;
  }
  cout << "NO";
  return 0;
}
