#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  int minX = (int)1e9, maxX = 0, minY = (int)1e9, maxY = 0, no = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      char temp;
      cin >> temp;
      if (temp == 'X') {
        no++;
        minX = min(minX, i);
        minY = min(minY, j);
        maxX = max(maxX, i);
        maxY = max(maxY, j);
      }
    }
  }
  if (((maxX - minX + 1) * (maxY - minY + 1)) == no)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
