#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 10;
char c[N][N];
long long xl, yl, xf, yf;
long long q;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  xf = 10000;
  yf = 10000;
  long long n, m;
  cin >> n >> m;
  for (long long i = 1; i <= n; i++) {
    for (long long j = 1; j <= m; j++) {
      cin >> c[i][j];
      if (c[i][j] == 'X') {
        xf = min(xf, i);
        xl = max(xl, i);
        yf = min(yf, j);
        yl = max(yl, j);
      }
    }
  }
  for (int i = xf; i <= xl; i++) {
    for (int j = yf; j <= yl; j++) {
      if (c[i][j] == '.') {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
