#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0;
  bool f = false;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = true;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ '0');
    c = getchar();
  }
  return f ? -x : x;
}
inline void write(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) write(x / 10);
  putchar(x % 10 + '0');
}
long long n, m, cnt, b = 2147483647, c = 2147483647, d, e;
char a[501][501];
signed main() {
  n = read();
  m = read();
  for (register long long i = 1; i <= n; ++i)
    for (register long long j = 1; j <= m; ++j)
      scanf(" %c", &a[i][j]),
          a[i][j] == 'X' && (++cnt, b = min(b, i), c = min(c, j), d = max(d, i),
                             e = max(e, j));
  cout << ((d - b + 1) * (e - c + 1) == cnt ? "YES" : "NO");
  return 0;
}
