#include <bits/stdc++.h>
using namespace std;
inline void read(int &n) {
  n = 0;
  register bool neg = false;
  register char c = getchar_unlocked();
  if (c == EOF) {
    n = -1;
    return;
  }
  while (!('0' <= c && c <= '9')) {
    if (c == '-') neg = true;
    c = getchar_unlocked();
  }
  while ('0' <= c && c <= '9') {
    n = n * 10 + c - '0';
    c = getchar_unlocked();
  }
  n = (neg ? (-n) : (n));
}
inline void writeInt(int n) {
  register int idx = 20;
  if (n < 0) putchar_unlocked('-');
  n = abs(n);
  char out[21];
  out[20] = ' ';
  do {
    idx--;
    out[idx] = n % 10 + '0';
    n /= 10;
  } while (n);
  do {
    putchar_unlocked(out[idx++]);
  } while (out[idx] != ' ');
}
char mat[505][505];
int main() {
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  int lox = 1e9, hix = -1;
  int loy = 1e9, hiy = -1;
  bool ok = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> mat[i][j];
      if (mat[i][j] == 'X') {
        lox = min(lox, i);
        hix = max(hix, i);
        loy = min(loy, j);
        hiy = max(hiy, j);
        ok = true;
      }
    }
  }
  for (int i = lox; i <= hix; i++) {
    for (int j = loy; j <= hiy; j++) {
      if (mat[i][j] == '.') {
        cout << "NO\n";
        return 0;
      }
    }
  }
  if (ok)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
