#include <bits/stdc++.h>
using namespace std;
map<char, int> mymap;
int main() {
  ios_base::sync_with_stdio(0);
  int n, m;
  string s[105];
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  mymap['R'] = 0;
  mymap['G'] = 0;
  mymap['B'] = 0;
  int ans = 0;
  if (n % 3 == 0) {
    int tmp = n / 3;
    if (tmp != 1) {
      for (int i = 0; i < n; i += tmp) {
        int yes = 1;
        for (int j = 0; j < m; j++) {
          for (int z = i + 1; z < i + tmp; z++) {
            if (s[z][j] != s[z - 1][j] || s[z][j] != s[i][0] ||
                s[z - 1][j] != s[i][0]) {
              yes = 0;
              break;
            }
          }
          if (yes == 0) {
            break;
          }
        }
        if (yes == 1) {
          mymap[s[i][0]]++;
        } else {
          break;
        }
      }
      if (mymap['R'] == 1 && mymap['G'] == 1 && mymap['B'] == 1) {
        ans = 1;
      }
    } else {
      for (int i = 0; i < n; i++) {
        int yes = 1;
        for (int j = 1; j < m; j++) {
          if (s[i][j] != s[i][j - 1]) {
            yes = 0;
            break;
          }
        }
        if (yes == 1) {
          mymap[s[i][0]]++;
        } else {
          break;
        }
      }
      if (mymap['R'] == 1 && mymap['G'] == 1 && mymap['B'] == 1) {
        ans = 1;
      }
    }
  }
  mymap['R'] = 0;
  mymap['G'] = 0;
  mymap['B'] = 0;
  if (m % 3 == 0) {
    int tmp = m / 3;
    if (tmp != 1) {
      for (int j = 0; j < m; j += tmp) {
        int yes = 1;
        for (int i = 0; i < n; i++) {
          for (int z = j + 1; z < j + tmp; z++) {
            if (s[i][z] != s[i][z - 1] || s[i][z] != s[0][j] ||
                s[i][z - 1] != s[0][j]) {
              yes = 0;
              break;
            }
          }
          if (yes == 0) {
            break;
          }
        }
        if (yes == 1) {
          mymap[s[0][j]]++;
        } else {
          break;
        }
      }
      if (mymap['R'] == 1 && mymap['G'] == 1 && mymap['B'] == 1) {
        ans = 1;
      }
    } else {
      for (int j = 0; j < m; j++) {
        int yes = 1;
        for (int i = 1; i < n; i++) {
          if (s[i][j] != s[i - 1][j]) {
            yes = 0;
            break;
          }
        }
        if (yes == 1) {
          mymap[s[0][j]]++;
        } else {
          break;
        }
      }
      if (mymap['R'] == 1 && mymap['G'] == 1 && mymap['B'] == 1) {
        ans = 1;
      }
    }
  }
  if (!ans) {
    cout << "NO";
  } else {
    cout << "YES";
  }
}
