#include <bits/stdc++.h>
using namespace std;
string S[503];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int u = 1, d = n;
  int l = 1, r = m;
  for (int i = 1; i <= n; i++) cin >> S[i];
  pair<int, int> lft = {n + 1, m + 1};
  pair<int, int> rgh;
  int cnt = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < m; j++) {
      if (S[i][j] == 'X') {
        lft = {min(lft.first, i), min(lft.second, j)};
        rgh = {max(rgh.first, i), max(rgh.second, j)};
        cnt++;
      }
    }
  }
  if (1LL * (rgh.first - lft.first + 1) * (rgh.second - lft.second + 1) ==
      cnt) {
    cout << "YES";
  } else {
    cout << "NO";
  }
  return 0;
}
