#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> m >> n;
  int a[m][n];
  int lc = INT_MAX, rc = INT_MIN, tr = INT_MAX, br = INT_MIN, count = 0;
  for (int i = 0; i < m; ++i) {
    for (int j = 0; j < n; ++j) {
      char c;
      cin >> c;
      if (c == 'X') {
        ++count;
        lc = min(j, lc);
        rc = max(j, rc);
        tr = min(i, tr);
        br = max(br, i);
      }
    }
  }
  int expected = (br - tr + 1) * (rc - lc + 1);
  if (expected == count)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
