#include <bits/stdc++.h>
using namespace std;
template <class T>
T modpower(T a, T b, T MOD) {
  T ans = 1;
  while (b != 0) {
    if (b % 2 == 1) ans = (ans * a) % MOD;
    a = (a * a) % MOD;
    b /= 2;
  }
  return ans;
}
void init() {
  int n, m, i, j, fg = 0, fg1 = 0, r1, r2, c1, c2;
  cin >> n >> m;
  string s[n];
  for (i = 0; i < n; i++) cin >> s[i];
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (s[i][j] == 'X') {
        r1 = i;
        c1 = j;
        fg1 = 1;
        break;
      }
    }
    if (fg1 == 1) break;
  }
  fg1 = 0;
  for (i = n - 1; i >= 0; i--) {
    for (j = m - 1; j >= 0; j--) {
      if (s[i][j] == 'X') {
        r2 = i;
        c2 = j;
        fg1 = 1;
        break;
      }
    }
    if (fg1 == 1) break;
  }
  for (i = r1; i <= r2; i++) {
    for (j = c1; j <= c2; j++) {
      if (s[i][j] == 'X')
        s[i][j] = '.';
      else {
        fg = 1;
        break;
      }
    }
  }
  for (i = 0; i < n; i++) {
    for (j = 0; j < m; j++) {
      if (s[i][j] == 'X') {
        fg = 1;
        break;
      }
    }
    if (fg == 1) break;
  }
  if (fg == 0)
    cout << "YES\n";
  else
    cout << "NO\n";
}
int main() {
  clock_t time1 = clock();
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  init();
  clock_t time2 = clock();
  cerr << "Time: " << (double)(time2 - time1) / CLOCKS_PER_SEC * 100000
       << " seconds" << endl;
  return 0;
}
