#include <bits/stdc++.h>
using namespace std;
char a[505][505];
int n, i, j, k, mnx, mny, mxx, mxy, m, o;
int main() {
  cin >> n >> m;
  mnx = 1000;
  mxx = 0;
  mny = 1000;
  mxy = 0;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      cin >> a[i][j];
      if (a[i][j] == '.') continue;
      mnx = min(mnx, i);
      mxx = max(mxx, i);
      mny = min(mny, j);
      mxy = max(mxy, j);
    }
  }
  o = 0;
  for (i = mnx; i <= mxx; ++i) {
    for (j = mny; j <= mxy; ++j) {
      if (a[i][j] == '.') o = 1;
      a[i][j] = '.';
    }
  }
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j)
      if (a[i][j] == 'X') o = 1;
  }
  if (o == 1)
    cout << "NO";
  else
    cout << "YES";
}
