#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
int i, j, k, l, m, n, p, ans, mxx, mxy, mnx, mny;
string ss;
int main() {
  cin >> m >> n;
  mnx = mny = 505;
  mxx = mxy = -1;
  for (i = 0; i < m; i++) {
    cin >> ss;
    for (j = 0; j < n; j++) {
      if (ss[j] == 'X') {
        p++;
        mnx = min(mnx, i);
        mny = min(mny, j);
        mxx = max(mxx, i);
        mxy = max(mxy, j);
      }
    }
  }
  if ((mxx - mnx + 1) * (mxy - mny + 1) == p)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
