#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, r, g, b, i, j;
  char s[105][105];
  while (~scanf("%d%d", &n, &m)) {
    for (i = 0; i < n; i++) {
      scanf("%s", s[i]);
    }
    int flag = 0;
    if (n % 3 == 0) {
      char ch1 = s[0][0];
      char ch2 = s[n / 3][0];
      char ch3 = s[2 * n / 3][0];
      if (ch1 != ch2 && ch2 != ch3 && ch1 != ch3) {
        r = g = b = 1;
        for (i = 0; i < n / 3; i++) {
          for (j = 0; j < m; j++) {
            if (s[i][j] != ch1) {
              r = 0;
              break;
            }
          }
        }
        for (i = n / 3; i < 2 * n / 3; i++) {
          for (j = 0; j < m; j++) {
            if (s[i][j] != ch2) {
              g = 0;
              break;
            }
          }
        }
        for (i = 2 * n / 3; i < n; i++) {
          for (j = 0; j < m; j++) {
            if (s[i][j] != ch3) {
              b = 0;
              break;
            }
          }
        }
        if (r && g && b) {
          flag = 1;
        }
      }
    }
    if (!flag && (m % 3 == 0)) {
      char ch1 = s[0][0];
      char ch2 = s[0][m / 3];
      char ch3 = s[0][2 * m / 3];
      if (ch1 != ch2 && ch2 != ch3 && ch1 != ch3) {
        r = g = b = 1;
        for (j = 0; j < m / 3; j++) {
          for (i = 0; i < n; i++) {
            if (s[i][j] != ch1) {
              r = 0;
              break;
            }
          }
        }
        for (j = m / 3; j < 2 * m / 3; j++) {
          for (i = 0; i < n; i++) {
            if (s[i][j] != ch2) {
              g = 0;
              break;
            }
          }
        }
        for (j = 2 * m / 3; j < m; j++) {
          for (i = 0; i < n; i++) {
            if (s[i][j] != ch3) {
              b = 0;
              break;
            }
          }
        }
        if (r && g && b) {
          flag = 1;
        }
      }
    }
    if (flag) {
      puts("YES");
    } else {
      puts("NO");
    }
  }
  return 0;
}
