#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, m, ans = 0, mnx = 1e9, mny = 1e9, mxx = -1, mxy = -1;
  char c[555][555];
  bool t = 1;
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'X') {
        mnx = min(mnx, i);
        mny = min(mny, j);
        mxx = max(mxx, i);
        mxy = max(mxy, j);
      }
    }
  for (int i = mnx; i <= mxx; i++)
    for (int j = mny; j <= mxy; j++) {
      if (c[i][j] != 'X') t = 0;
    }
  cout << (!t ? "NO" : "YES");
}
int main() {
  int test = 1;
  while (test--) {
    solve();
  }
  return 0;
}
