#include <bits/stdc++.h>
using namespace std;
char mp[505][505];
int r[505] = {0};
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int xb = -1, xs = n, yb = -1, ys = m;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mp[i][j];
      if (mp[i][j] == 'X') {
        if (i > xb) xb = i;
        if (i < xs) xs = i;
        if (j > yb) yb = j;
        if (j < ys) ys = j;
        sum++;
      }
    }
  }
  if ((xb - xs + 1) * (yb - ys + 1) == sum) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}
