#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:10240000")
using namespace std;
const int MAXN = 1010;
int a[MAXN][MAXN];
char str[MAXN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  memset(a, 0, sizeof(a));
  int rmin = MAXN, rmax = 0;
  int cmin = MAXN, cmax = 0;
  for (int i = 1; i <= n; i++) {
    scanf("%s", &str);
    for (int j = 0; j < m; j++) {
      if (str[j] == 'X') {
        a[i][j + 1] = 1;
        if (i < rmin) {
          rmin = i;
        }
        if (i > rmax) {
          rmax = i;
        }
        if (j + 1 < cmin) {
          cmin = j + 1;
        }
        if (j + 1 > cmax) {
          cmax = j + 1;
        }
      }
    }
  }
  bool flag = true;
  for (int i = rmin; i <= rmax; i++) {
    for (int j = cmin; j <= cmax; j++) {
      if (!a[i][j]) {
        flag = false;
        break;
      }
    }
    if (!flag) {
      break;
    }
  }
  if (!flag) {
    printf("NO\n");
  } else {
    printf("YES\n");
  }
  return 0;
}
