#include <bits/stdc++.h>
using namespace std;
int n, m, a[105][105], row[105], col[105];
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  if (n % 3 != 0 && m % 3 != 0) {
    cout << "NO";
    exit(0);
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == 'R')
        a[i][j] = 1;
      else if (c == 'G')
        a[i][j] = 2;
    }
  }
  bool row1 = false, col1 = false;
  for (int i = 1; i <= n; i++) {
    bool kt = true;
    for (int j = 2; j <= m; j++)
      if (a[i][j] != a[i][j - 1]) {
        row[i] = -1;
        kt = false;
        break;
      }
    if (kt)
      row[i] = a[i][1];
    else
      row1 = true;
  }
  for (int i = 1; i <= m; i++) {
    bool kt = true;
    for (int j = 2; j <= n; j++)
      if (a[j][i] != a[j - 1][i]) {
        col[i] = -1;
        kt = false;
        break;
      }
    if (kt)
      col[i] = a[1][i];
    else
      col1 = true;
  }
  if (col1 && row1) {
    cout << "NO";
    exit(0);
  }
  int c0 = 1, c1 = 1, c2 = 1;
  if (row1) {
    if (m % 3 != 0) {
      cout << "NO";
      exit(0);
    }
    if (!a[1][1])
      c0 = 0;
    else if (a[1][1] == 1)
      c1 = 0;
    else
      c2 = 0;
    for (int i = 2; i <= m / 3; i++)
      if (col[i] != col[i - 1]) {
        cout << "NO";
        exit(0);
      }
    if (!a[1][m / 3 + 1])
      c0 = 0;
    else if (a[1][m / 3 + 1] == 1)
      c1 = 0;
    else if (a[1][m / 3 + 1] == 2)
      c2 = 0;
    for (int i = m / 3 + 2; i <= 2 * m / 3; i++)
      if (col[i] != col[i - 1]) {
        cout << "NO";
        exit(0);
      }
    if (!a[1][2 * m / 3 + 1])
      c0 = 0;
    else if (a[1][2 * m / 3 + 1] == 1)
      c1 = 0;
    else if (a[1][2 * m / 3 + 1] == 2)
      c2 = 0;
    for (int i = 2 * m / 3 + 2; i <= m; i++)
      if (col[i] != col[i - 1]) {
        cout << "NO";
        exit(0);
      }
    if (c0 || c2 || c1) {
      cout << "NO";
      exit(0);
    }
    cout << "YES";
  } else {
    if (n % 3 != 0) {
      cout << "NO";
      exit(0);
    }
    if (!a[1][1])
      c0 = 0;
    else if (a[1][1] == 1)
      c1 = 0;
    else
      c2 = 0;
    for (int i = 2; i <= n / 3; i++)
      if (row[i] != row[i - 1]) {
        cout << "NO";
        exit(0);
      }
    if (!a[n / 3 + 1][1])
      c0 = 0;
    else if (a[n / 3 + 1][1] == 1)
      c1 = 0;
    else if (a[n / 3 + 1][1] == 2)
      c2 = 0;
    for (int i = n / 3 + 2; i <= 2 * n / 3; i++)
      if (row[i] != row[i - 1]) {
        cout << "NO";
        exit(0);
      }
    if (!a[2 * n / 3 + 1][1])
      c0 = 0;
    else if (a[2 * n / 3 + 1][1] == 1)
      c1 = 0;
    else if (a[2 * n / 3 + 1][1] == 2)
      c2 = 0;
    for (int i = 2 * n / 3 + 2; i <= n; i++)
      if (row[i] != row[i - 1]) {
        cout << "NO";
        exit(0);
      }
    if (c1 || c2 || c0) {
      cout << "NO";
      exit(0);
    }
    cout << "YES";
  }
}
