#include <bits/stdc++.h>
using namespace std;
const int MIN = 1e3 + 2;
const int MXN = 1e6 + 3;
const int INF = 1e9 + 7;
const double EPS = 1e-9;
const long long LINF = 1e18 + 15;
int n, m, rmin = INF, cmin = INF, rmax, cmax;
char a[MIN][MIN];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'X') {
        if (i < rmin) rmin = i;
        if (j < cmin) cmin = j;
        if (i > rmax) rmax = i;
        if (j > cmax) cmax = j;
      }
    }
  }
  for (int i = rmin; i <= rmax; i++) {
    for (int j = cmin; j <= cmax; j++) {
      if (a[i][j] != 'X') {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
