#include <bits/stdc++.h>
using namespace std;
char s[105][105];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  map<char, int> M;
  M['R'] = 0, M['B'] = 0, M['G'] = 0;
  if (n % 3 == 0) {
    for (int i = 0; i < n; i += n / 3) {
      char c = s[i][0];
      for (int j = i; j < i + n / 3; j++)
        for (int k = 0; k < m; k++)
          if (c != s[j][k]) M[c] = -1;
      if (M[c] == 0) {
        M[c] = 1;
      }
    }
  }
  if (M['R'] == 1 && M['G'] == 1 && M['B'] == 1) return 0 * puts("YES");
  M['R'] = 0, M['B'] = 0, M['G'] = 0;
  if (m % 3 == 0) {
    for (int i = 0; i < m; i += m / 3) {
      char c = s[0][i];
      for (int j = i; j < i + m / 3; j++)
        for (int k = 0; k < n; k++) {
          if (c != s[k][j]) M[c] = -1;
        }
      if (M[c] == 0) M[c] = 1;
    }
  }
  if (M['R'] == 1 && M['G'] == 1 && M['B'] == 1) return 0 * puts("YES");
  puts("NO");
  return 0;
}
