#include <bits/stdc++.h>
void sf(int &x) { scanf("%d", &x); }
void sf(char &x) { scanf("%c", &x); }
void sf(double &x) { scanf("%lf", &x); }
void sf(char *x) { scanf("%s", x); }
void sf(long long &x) { scanf("%I64d", &x); }
void pf(int x) { printf("%d", x); }
void pf(char x) { printf("%c", x); }
void pf(double x) { printf("%f", x); }
void pf(char *x) { printf("%s", x); }
void pf(long long x) { printf("%I64d", x); }
void pf() { printf("\n"); }
const long long mod = 1e9 + 7;
const int maxn = 100010;
const int INF = 0x7ffffff;
const long long LINF = 0x7fffffffffffffff;
using namespace std;
long long q_pow(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % mod;
    y >>= 1;
    x = (x * x) % mod;
  }
  return res;
}
long long inv(long long x) { return q_pow(x, mod - 2); }
int Read() {
  int x = 0, F = 1;
  char C = getchar();
  while (C < '0' || C > '9') {
    if (C == '-') F = -F;
    C = getchar();
  }
  while (C >= '0' && C <= '9') {
    x = x * 10 - '0' + C, C = getchar();
  }
  return x * F;
}
int Trans() {
  char c;
  sf(c);
  int res;
  res = c - '0';
  return res;
}
int MAXNUM;
char maze[105][105];
int color[3];
int main() {
  int col, row;
  cin >> row >> col;
  int cnt = 0;
  char cur = 0;
  int flag = 1;
  for (int i = 0; i < row; i++) {
    cin >> maze[i];
  }
  for (int i = 0; i < row; i++) {
    if (i == 0) {
      cur = maze[0][0];
      if (cur == 'R') {
        color[0]++;
      }
      if (cur == 'B') {
        color[1]++;
      }
      if (cur == 'G') {
        color[2]++;
      }
    } else {
      cur = maze[i][0];
      char pre = maze[i - 1][0];
      if (cur != pre) {
        if (cur == 'R') {
          if (color[0]) {
            printf("NO\n");
            return 0;
          }
        }
        if (cur == 'B') {
          if (color[1]) {
            printf("NO\n");
            return 0;
          }
        }
        if (cur == 'G') {
          if (color[2]) {
            printf("NO\n");
            return 0;
          }
        }
      }
      if (cur == 'R') {
        color[0]++;
      }
      if (cur == 'B') {
        color[1]++;
      }
      if (cur == 'G') {
        color[2]++;
      }
    }
    for (int j = 0; j < col; j++) {
      if (maze[i][j] != maze[i][0]) {
        flag = 0;
        break;
      }
    }
    if (flag == 0) break;
  }
  if (flag == 1) {
    int x = color[0];
    for (int i = 1; i < 3; i++) {
      if (color[i] != x) {
        flag = 0;
      }
    }
  }
  if (flag) {
    printf("YES\n");
    return 0;
  } else {
    flag = 1;
    memset(color, 0, sizeof(color));
    for (int i = 0; i < col; i++) {
      if (i == 0) {
        cur = maze[0][0];
        if (cur == 'R') {
          color[0]++;
        }
        if (cur == 'B') {
          color[1]++;
        }
        if (cur == 'G') {
          color[2]++;
        }
      } else {
        cur = maze[0][i];
        char pre = maze[0][i - 1];
        if (cur != pre) {
          if (cur == 'R') {
            if (color[0]) {
              printf("NO\n");
              return 0;
            }
          }
          if (cur == 'B') {
            if (color[1]) {
              printf("NO\n");
              return 0;
            }
          }
          if (cur == 'G') {
            if (color[2]) {
              printf("NO\n");
              return 0;
            }
          }
        }
        if (cur == 'R') {
          color[0]++;
        }
        if (cur == 'B') {
          color[1]++;
        }
        if (cur == 'G') {
          color[2]++;
        }
      }
      for (int j = 0; j < row; j++) {
        if (maze[j][i] != maze[0][i]) {
          flag = 0;
          break;
        }
      }
      if (flag == 0) break;
    }
    if (flag == 1) {
      int x = color[0];
      for (int i = 1; i < 3; i++) {
        if (color[i] != x) {
          flag = 0;
        }
      }
    }
    if (flag) {
      printf("YES\n");
      return 0;
    } else
      printf("NO\n");
  }
  return 0;
}
