#include <bits/stdc++.h>
using namespace std;
char board[110][110];
int n, m;
bool chkv() {
  char prec = -1;
  int R = 0, B = 0, G = 0;
  bool vR = 0, vB = 0, vG = 0;
  for (int i = (1); i <= (m); ++i) {
    char fc = board[1][i];
    for (int j = (2); j <= (n); ++j)
      if (board[j][i] != fc) return false;
    switch (fc) {
      case 'R':
        if (vR) return false;
        ++R;
        break;
      case 'B':
        if (vB) return false;
        ++B;
        break;
      case 'G':
        if (vG) return false;
        ++G;
        break;
    }
    if (prec == -1)
      prec = fc;
    else if (prec != fc) {
      switch (prec) {
        case 'R':
          vR = 1;
          break;
        case 'B':
          vB = 1;
          break;
        case 'G':
          vG = 1;
          break;
      }
      prec = fc;
    }
  }
  if (R != B || B != G) return false;
  return true;
}
bool chkh() {
  char prec = -1;
  int R = 0, B = 0, G = 0;
  bool vR = 0, vB = 0, vG = 0;
  for (int i = (1); i <= (n); ++i) {
    char fc = board[i][1];
    for (int j = (2); j <= (m); ++j)
      if (board[i][j] != fc) return false;
    switch (fc) {
      case 'R':
        if (vR) return false;
        ++R;
        break;
      case 'B':
        if (vB) return false;
        ++B;
        break;
      case 'G':
        if (vG) return false;
        ++G;
        break;
    }
    if (prec == -1)
      prec = fc;
    else if (prec != fc) {
      switch (prec) {
        case 'R':
          vR = 1;
          break;
        case 'B':
          vB = 1;
          break;
        case 'G':
          vG = 1;
          break;
      }
      prec = fc;
    }
  }
  if (R != B || B != G) return false;
  return true;
}
int main() {
  while (~scanf("%d%d", &n, &m)) {
    for (int i = (1); i <= (n); ++i) scanf("%s", board[i] + 1);
    if (chkv() || chkh())
      printf("YES\n");
    else
      printf("NO\n");
  }
  return 0;
}
