#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
const int S = 8;
int r, g, b;
int lr, lg, lb;
char str[200][200];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  bool flag = true;
  int f = 1;
  for (int i = 1; i <= n; i++) {
    scanf("%s", str[i] + 1);
    for (int j = 2; j <= m; j++) {
      if (str[i][j] != str[i][j - 1]) {
        f = 0;
        break;
      }
    }
    if (f) {
      if (str[i][1] == 'R') {
        r++;
        if (lr == 0)
          lr = i;
        else if (lr != i - 1)
          flag = false;
        else
          lr = i;
      } else if (str[i][1] == 'G') {
        g++;
        if (lg == 0)
          lg = i;
        else if (lg != i - 1)
          flag = false;
        else
          lg = i;
      } else {
        b++;
        if (lb == 0)
          lb = i;
        else if (lb != i - 1)
          flag = false;
        else
          lb = i;
      }
    }
  }
  if (f) {
    if (!(r == g && g == b)) flag = false;
  } else {
    f = 1;
    r = g = b = 0;
    lr = lg = lb = 0;
    for (int i = 1; i <= m; i++) {
      for (int j = 2; j <= n; j++) {
        if (str[j][i] != str[j - 1][i]) f = 0;
      }
      if (f) {
        if (str[1][i] == 'R') {
          r++;
          if (lr == 0)
            lr = i;
          else if (lr != i - 1)
            flag = false;
          else
            lr = i;
        } else if (str[1][i] == 'G') {
          g++;
          if (lg == 0)
            lg = i;
          else if (lg != i - 1)
            flag = false;
          else
            lg = i;
        } else {
          b++;
          if (lb == 0)
            lb = i;
          else if (lb != i - 1)
            flag = false;
          else
            lb = i;
        }
      } else
        break;
    }
    if (f) {
      if (!(r == g && g == b)) flag = false;
    } else
      flag = false;
  }
  if (flag)
    printf("YES\n");
  else
    printf("NO\n");
  return 0;
}
