#include <bits/stdc++.h>
int main() {
  char a[580][580];
  int m, n;
  scanf("%d%d", &n, &m);
  int minx = 600, miny = 600, maxx = -1, maxy = -1, flag = 0;
  for (int i = 0; i < n; i++) {
    scanf("%s", a[i]);
    for (int j = 0; j < m; j++)
      if (a[i][j] == 'X') {
        flag++;
        if (i < minx) minx = i;
        if (i > maxx) maxx = i;
        if (j < miny) miny = j;
        if (j > maxy) maxy = j;
      }
  }
  if ((maxx - minx + 1) * (maxy - miny + 1) == flag)
    printf("YES\n");
  else
    printf("NO\n");
}
