#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int leftmost = m + 5;
  int rightmost = 0;
  vector<vector<int> > g(n, vector<int>(m, 0));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      char c;
      cin >> c;
      if (c == 'X') {
        g[i][j] = 1;
        leftmost = min(leftmost, j);
        rightmost = max(rightmost, j);
      }
    }
  bool b = true;
  int hep = rightmost - leftmost + 1;
  for (int i = 0; i < n; i++) {
    int sum = 0;
    for (int j = leftmost; j <= rightmost; j++) {
      sum += g[i][j];
    }
    if (sum != 0 && sum != hep) b = false;
  }
  cout << (b == true ? "YES" : "NO");
  return 0;
}
