#include <bits/stdc++.h>
int main(int argc, char const *argv[]) {
  int row = 0, column = 0;
  scanf("%d %d", &row, &column);
  if ((row % 3 != 0 && column % 3 != 0) || (row == 0 || column == 0)) {
    printf("NO");
    return 0;
  }
  int flag[row][column];
  int y = 0, x = 0;
  while (y < row) {
    x = 0;
    while (x < column) {
      char c = getchar();
      if (c == '\n') {
        c = getchar();
      }
      if (c == 'R') {
        flag[y][x] = 0;
      } else if (c == 'G') {
        flag[y][x] = 1;
      } else if (c == 'B') {
        flag[y][x] = 2;
      }
      x++;
    }
    y++;
  }
  x = 0;
  int test = flag[0][0];
  char orientation = 'h';
  while (x < column) {
    if (flag[0][x] != test) {
      orientation = 'v';
    }
    x++;
  }
  if (orientation == 'h') {
    if (row % 3 != 0) {
      printf("NO");
      return 0;
    }
    x = 0, y = 0;
    while (x < column) {
      y = 0;
      while (y < row) {
        if (y < row / 3) {
          if (flag[y][x] != flag[0][0]) {
            printf("NO");
            return 0;
          }
        } else if (row / 3 <= y && y < 2 * row / 3) {
          if (flag[y][x] != flag[row / 3][0]) {
            printf("NO");
            return 0;
          }
        } else {
          if (flag[y][x] != flag[2 * row / 3][0]) {
            printf("NO");
            return 0;
          }
        }
        if (flag[0][0] == flag[row / 3][0] ||
            flag[0][0] == flag[2 * row / 3][0] ||
            flag[row / 3][0] == flag[2 * row / 3][0]) {
          printf("NO");
          return 0;
        }
        y++;
      }
      x++;
    }
  } else if (orientation == 'v') {
    if (column % 3 != 0) {
      printf("NO");
      return 0;
    }
    x = 0, y = 0;
    while (y < row) {
      x = 0;
      while (x < column) {
        if (x < column / 3) {
          if (flag[y][x] != flag[0][0]) {
            printf("NO");
            return 0;
          }
        } else if (column / 3 <= x && x < 2 * column / 3) {
          if (flag[y][x] != flag[0][column / 3]) {
            printf("NO");
            return 0;
          }
        } else {
          if (flag[y][x] != flag[0][2 * column / 3]) {
            printf("NO");
            return 0;
          }
        }
        if (flag[0][0] == flag[0][column / 3] ||
            flag[0][0] == flag[0][2 * column / 3] ||
            flag[0][column / 3] == flag[0][2 * column / 3]) {
          printf("NO");
          return 0;
        }
        x++;
      }
      y++;
    }
  }
  printf("YES");
  return 0;
}
