#include <bits/stdc++.h>
int n, m;
int arr[510][510];
int main() {
  int i, j;
  char tmp[510];
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; ++i) {
    scanf("%s", tmp + 1);
    for (j = 1; j <= m; ++j) {
      if (tmp[j] == 'X') arr[i][j] = 1;
    }
  }
  int c = 0;
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      if (arr[i][j]) break;
    }
    if (j <= m) break;
  }
  int x, y;
  x = i;
  y = j;
  for (i = n; i >= 1; --i) {
    for (j = m; j >= 1; --j)
      if (arr[i][j]) break;
    if (j >= 1) break;
  }
  int z, w;
  z = i;
  w = j;
  if (x > z || y > w) {
    printf("NO");
    return 0;
  }
  for (i = 1; i <= n; ++i) {
    for (j = 1; j <= m; ++j) {
      if (x <= i && i <= z && y <= j && j <= w) {
        if (arr[i][j] == 0) {
          printf("NO");
          return 0;
        }
      } else {
        if (arr[i][j] == 1) {
          printf("NO");
          return 0;
        }
      }
    }
  }
  printf("YES");
}
