#include <bits/stdc++.h>
using namespace std;
string s[1000];
int main() {
  int n, m, a, b, c, d;
  c = d = 0;
  a = b = 1000;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'X') {
        if (i < a) a = i;
        if (i > c) c = i;
        if (j < b) b = j;
        if (j > d) d = j;
      }
    }
  }
  int f = 1;
  for (int i = a; i <= c; i++) {
    for (int j = b; j <= d; j++) {
      if (s[i][j] == '.') f = 0;
    }
  }
  if (f)
    printf("YES");
  else
    printf("NO");
}
