#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, flag_row = 0, flag_col = 0;
  string str1 = "", str2 = "";
  cin >> n >> m;
  char ara[105][105];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> ara[i][j];
    }
  }
  for (int i = 0; i < n; i++) {
    set<char> s;
    for (int j = 0; j < m; j++) {
      s.insert(ara[i][j]);
    }
    if (s.size() == 1)
      str1 += ara[i][0];
    else
      flag_row = 1;
  }
  for (int i = 0; i < m; i++) {
    set<char> s;
    for (int j = 0; j < n; j++) {
      s.insert(ara[j][i]);
    }
    if (s.size() == 1)
      str2 += ara[0][i];
    else
      flag_col = 1;
  }
  if (flag_row == 1 and flag_col == 1)
    cout << "NO" << endl;
  else {
    vector<int> vr1, vb1, vg1, vr2, vb2, vg2;
    int flag_ans1 = 0, flag_ans2 = 0;
    int r1 = 0, b1 = 0, g1 = 0, r2 = 0, g2 = 0, b2 = 0;
    for (int i = 0; i < str1.size(); i++) {
      if (str1[i] == 'B') vb1.push_back(i), b1++;
      if (str1[i] == 'R') vr1.push_back(i), r1++;
      if (str1[i] == 'G') vg1.push_back(i), g1++;
    }
    sort(vr1.begin(), vr1.end());
    sort(vb1.begin(), vb1.end());
    sort(vg1.begin(), vg1.end());
    for (int i = 1; i < vr1.size(); i++) {
      if (vr1[i] - vr1[i - 1] == 1)
        continue;
      else
        flag_ans1 = 1;
    }
    for (int i = 1; i < vb1.size(); i++) {
      if (vb1[i] - vb1[i - 1] == 1)
        continue;
      else
        flag_ans1 = 1;
    }
    for (int i = 1; i < vg1.size(); i++) {
      if (vg1[i] - vg1[i - 1] == 1)
        continue;
      else
        flag_ans1 = 1;
    }
    for (int i = 0; i < str2.size(); i++) {
      if (str2[i] == 'B') vb2.push_back(i), b2++;
      if (str2[i] == 'R') vr2.push_back(i), r2++;
      if (str2[i] == 'G') vg2.push_back(i), g2++;
    }
    sort(vr2.begin(), vr2.end());
    sort(vb2.begin(), vb2.end());
    sort(vg2.begin(), vg2.end());
    for (int i = 1; i < vr2.size(); i++) {
      if (vr2[i] - vr2[i - 1] == 1)
        continue;
      else
        flag_ans2 = 1;
    }
    for (int i = 1; i < vb2.size(); i++) {
      if (vb2[i] - vb2[i - 1] == 1)
        continue;
      else
        flag_ans2 = 1;
    }
    for (int i = 1; i < vg2.size(); i++) {
      if (vg2[i] - vg2[i - 1] == 1)
        continue;
      else
        flag_ans2 = 1;
    }
    set<int> num1, num2;
    num1.insert(r1);
    num1.insert(b1);
    num1.insert(g1);
    num2.insert(r2);
    num2.insert(b2);
    num2.insert(g2);
    if (num1.size() != 1 or flag_ans1 == 1)
      cout << "NO" << endl;
    else if (num2.size() != 1 or flag_ans2 == 1)
      cout << "NO" << endl;
    else
      cout << "YES" << endl;
  }
  return 0;
}
