#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, i, j, x1 = 501, x2 = 1, y1 = 501, y2 = 1;
  char a[501][501];
  cin >> n >> m;
  for (i = 1; i <= n; i++) {
    for (j = 1; j <= m; j++) {
      cin >> a[i][j];
      if (a[i][j] == 'X') {
        x1 = min(x1, i);
        x2 = max(x2, i);
        y1 = min(y1, j);
        y2 = max(y2, j);
      }
    }
  }
  for (i = x1; i <= x2; i++) {
    for (j = y1; j <= y2; j++) {
      if (a[i][j] != 'X') {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
