#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  cin >> n >> m;
  string s[n];
  for (int i = 0; i < n; i++) cin >> s[i];
  int c = 0, si = 0, tj = 0, totx = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'X' && c == 0) {
        si = i;
        tj = j;
        c = 1;
      }
      if (s[i][j] == 'X') totx++;
    }
  }
  int height = 0;
  for (int k = si; k <= n; k++) {
    if (s[k][tj] == 'X')
      height++;
    else
      break;
  }
  int mm = tj + 1, width = 1;
  while (mm < m && s[si][mm] == 'X') {
    width++;
    for (int k = si; k < si + height; k++) {
      if (s[k][mm] != 'X') {
        cout << "NO\n";
        return 0;
      }
    }
    mm++;
  }
  if (height * width == totx)
    cout << "YES\n";
  else
    cout << "NO\n";
}
