#include <bits/stdc++.h>
using namespace std;
char p[505][505];
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int i, j, min1c = 1001, min1r = 1001, max1c = -1, max1r = -1;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> p[i][j];
      if (p[i][j] == 'X') {
        if (j < min1c) {
          min1c = j;
          min1r = i;
        }
        if (j >= max1c) {
          max1c = j;
          max1r = i;
        }
      }
    }
  }
  for (i = min1r; i <= max1r; i++) {
    for (j = min1c; j <= max1c; j++) {
      if (p[i][j] != 'X') {
        cout << "NO" << '\n';
        return 0;
      }
      p[i][j] = '.';
    }
  }
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) {
      if (p[i][j] != '.') {
        cout << "NO" << '\n';
        return 0;
      }
    }
  cout << "YES" << '\n';
  return 0;
}
