#include <bits/stdc++.h>
using namespace std;
const int MAXN = 600;
char in[MAXN][MAXN];
int main(int argc, char const *argv[]) {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> in[i];
  int imax = -1, jmax = -1;
  int imin = MAXN, jmin = MAXN;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (in[i][j] == 'X') {
        imax = max(imax, i);
        jmax = max(jmax, j);
        imin = min(imin, i);
        jmin = min(jmin, j);
      }
    }
  }
  bool yes = true;
  for (int i = imin; i <= imax; i++) {
    for (int j = jmin; j <= jmax; j++) {
      if (in[i][j] == '.') yes = false;
    }
  }
  if (yes)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
