#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, m;
  cin >> n >> m;
  vector<string> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  int mnx = -1, mny = -1, mxx = -1, mxy = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (a[i][j] == 'X') {
        mnx = i, mny = j;
        break;
      }
    }
    if (mnx != -1) break;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (a[i][j] == 'X') {
        mxx = i, mxy = j;
        break;
      }
    }
    if (mxx != -1) break;
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (i <= mxx && i >= mnx && j <= mxy && j >= mny) {
        if (a[i][j] != 'X') {
          cout << "NO\n";
          return 0;
        }
      } else if (a[i][j] == 'X') {
        cout << "NO\n";
        return 0;
      }
    }
  }
  cout << "YES\n";
  return 0;
}
