#include <bits/stdc++.h>
using namespace std;
string g[105];
vector<char> ans = {'B', 'G', 'R'};
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; ++i) cin >> g[i];
  if (n % 3 == 0) {
    vector<char> c;
    for (int k = 0; k < 3; ++k) {
      int A = k * (n / 3);
      int B = (k + 1) * (n / 3);
      char last = 0;
      for (int i = A; i < B; ++i) {
        for (int j = 0; j < m; ++j) {
          if (last != 0 && g[i][j] != last) goto skp;
          last = g[i][j];
        }
      }
      c.push_back(g[A][0]);
    }
    sort(c.begin(), c.end());
    if (c == ans) {
      cout << "YES\n";
      return 0;
    }
  }
skp:;
  if (m % 3 == 0) {
    vector<char> c;
    for (int k = 0; k < 3; ++k) {
      int A = k * (m / 3);
      int B = (k + 1) * (m / 3);
      char last = 0;
      for (int j = A; j < B; ++j) {
        for (int i = 0; i < n; ++i) {
          if (last != 0 && g[i][j] != last) goto sk2;
          last = g[i][j];
        }
      }
      c.push_back(g[0][A]);
    }
    sort(c.begin(), c.end());
    if (c == ans) {
      cout << "YES\n";
      return 0;
    }
  }
sk2:;
  cout << "NO\n";
}
