#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<string> v(n);
  for (int i = 0; i < n; i++) cin >> v[i];
  bool flag = 0;
  map<char, int> mp;
  string finalcheck = "";
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    cnt += (v[i].find('R') != string::npos);
    cnt += (v[i].find('G') != string::npos);
    cnt += (v[i].find('B') != string::npos);
    if (cnt > 1) {
      flag = 1;
      break;
    } else {
      if (v[i].find('R') != string::npos) {
        mp['R']++;
        finalcheck += 'r';
      } else if (v[i].find('G') != string::npos) {
        mp['G']++;
        finalcheck += 'g';
      } else if (v[i].find('B') != string::npos) {
        mp['B']++;
        finalcheck += 'b';
      }
    }
  }
  bool f[3] = {0, 0, 0};
  for (int i = 0; i < finalcheck.size();) {
    if (finalcheck[i] == 'r') {
      if (f[0]) return cout << "NO" << endl, 0;
      while (finalcheck[i] == 'r') {
        i++;
      }
      f[0] = 1;
    } else if (finalcheck[i] == 'g') {
      if (f[1]) return cout << "NO" << endl, 0;
      while (finalcheck[i] == 'g') {
        i++;
      }
      f[1] = 1;
    } else if (finalcheck[i] == 'b') {
      if (f[2]) return cout << "NO" << endl, 0;
      while (finalcheck[i] == 'b') {
        i++;
      }
      f[2] = 1;
    }
  }
  if (!flag && (mp['R'] == mp['G'] && mp['G'] == mp['B'] && mp['B'] == mp['R']))
    return cout << "YES" << endl, 0;
  finalcheck = "";
  flag = 0;
  mp['R'] = mp['G'] = mp['B'] = 0;
  for (int i = 0; i < m; i++) {
    string s = "";
    for (int j = 0; j < n; j++) {
      s += v[j][i];
    }
    int cnt = 0;
    cnt += (s.find('R') != string::npos);
    cnt += (s.find('G') != string::npos);
    cnt += (s.find('B') != string::npos);
    if (cnt > 1) {
      flag = 1;
      break;
    } else {
      if (s.find('R') != string::npos) {
        mp['R']++;
        finalcheck += 'r';
      } else if (s.find('G') != string::npos) {
        mp['G']++;
        finalcheck += 'g';
      } else if (s.find('B') != string::npos) {
        mp['B']++;
        finalcheck += 'b';
      }
    }
  }
  memset(f, 0, sizeof(f));
  for (int i = 0; i < finalcheck.size();) {
    if (finalcheck[i] == 'r') {
      if (f[0]) return cout << "NO" << endl, 0;
      while (finalcheck[i] == 'r') {
        i++;
      }
      f[0] = 1;
    } else if (finalcheck[i] == 'g') {
      if (f[1]) return cout << "NO" << endl, 0;
      while (finalcheck[i] == 'g') {
        i++;
      }
      f[1] = 1;
    } else if (finalcheck[i] == 'b') {
      if (f[2]) return cout << "NO" << endl, 0;
      while (finalcheck[i] == 'b') {
        i++;
      }
      f[2] = 1;
    }
  }
  if (!flag && (mp['R'] == mp['G'] && mp['G'] == mp['B'] && mp['B'] == mp['R']))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
