#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 10;
char a[maxn][maxn];
bool vis[maxn][maxn];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf("%s", a[i]);
  }
  int sum = 0, minx = maxn, mxx = 0, miny = maxn, mxy = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'X') {
        sum++;
        minx = min(i, minx);
        mxx = max(i, mxx);
        miny = min(j, miny);
        mxy = max(j, mxy);
      }
    }
  }
  if (sum == 0) {
    puts("NO");
  }
  printf("%s\n", (mxx - minx + 1) * (mxy - miny + 1) == sum ? "YES" : "NO");
  return 0;
}
