#include <bits/stdc++.h>
using namespace std;
bool mat[1000][1000];
int main() {
  int m, n;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < m; j++) {
      if (s[j] == '.') {
        mat[i][j] = 0;
      } else if (s[j] == 'X') {
        mat[i][j] = 1;
      }
    }
  }
  int r = m - 1, l = 0, t = 0, b = n - 1;
  bool cl = 1, cr = 1, ct = 1, cb = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[t + i][j] == 1 && ct) {
        t = t + i;
        ct = 0;
      }
      if (mat[b - i][j] == 1 && cb) {
        b = b - i;
        cb = 0;
      }
    }
  }
  for (int i = 0; i < m; i++) {
    for (int j = 0; j < n; j++) {
      if (mat[j][l + i] == 1 && cl) {
        l = l + i;
        cl = 0;
      }
      if (mat[j][r - i] == 1 && cr) {
        r = r - i;
        cr = 0;
      }
    }
  }
  for (int i = t; i <= b; i++) {
    for (int j = l; j <= r; j++) {
      if (!mat[i][j]) {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
