#include <bits/stdc++.h>
using namespace std;
int n, m;
char tab[505][505];
vector<pair<int, int> > pos;
int ile;
int px, py;
int kx, ky;
int wyn;
int main() {
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= (n); ++i) {
    for (int p = 1; p <= (m); ++p) {
      scanf(" %c", &tab[i][p]);
      if (px == 0 && tab[i][p] == 'X') {
        px = i;
        py = p;
      }
      if (tab[i][p] == 'X') {
        kx = i;
        ky = p;
      }
      ile += (tab[i][p] == 'X');
    }
  }
  int puste = 0;
  for (int i = px; i <= (kx); ++i) {
    for (int p = py; p <= (ky); ++p) {
      if (tab[i][p] == 'X')
        wyn++;
      else
        puste++;
    }
  }
  if ((wyn == ile) && (puste == 0)) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
