#include <bits/stdc++.h>
using namespace std;
int n, m;
char mp[510][510];
int minln, maxln, minrw, maxrw, cnt;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%s", mp[i] + 1);
  minln = n + 1;
  maxln = 0;
  minrw = m + 1;
  maxrw = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (mp[i][j] == 'X') {
        minln = min(i, minln);
        minrw = min(j, minrw);
        maxln = max(i, maxln);
        maxrw = max(j, maxrw);
        cnt++;
      }
  if (minln > maxln || minrw > maxrw ||
      (maxln - minln + 1) * (maxrw - minrw + 1) != cnt)
    printf("NO\n");
  else
    printf("YES\n");
  return 0;
}
