#include <bits/stdc++.h>
using namespace std;
char s[505][505];
int main() {
  int n, m, i, j, minx = INT_MAX, miny = INT_MAX, maxx = 0, maxy = 0, noOfx = 0;
  scanf("%d%d", &n, &m);
  for (i = 0; i < n; i++) {
    scanf("%s", s[i]);
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (s[i][j] == 'X') {
        noOfx++;
        if (miny > i) {
          miny = i;
        }
        if (minx > j) minx = j;
        if (maxy < i) maxy = i;
        if (maxx < j) maxx = j;
      }
    }
  }
  int a = 0;
  for (j = minx; j <= maxx; j++) {
    for (i = miny; i <= maxy; i++) {
      if (s[i][j] != 'X') {
        a = 1;
      }
    }
  }
  if (a == 0)
    printf("YES");
  else
    printf("NO");
  return 0;
}
