#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n, m;
  cin >> n >> m;
  char a[n][m];
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      cin >> a[i][j];
    }
  }
  long long int minx = LONG_LONG_MAX;
  long long int miny = LONG_LONG_MAX;
  long long int maxx = LONG_LONG_MIN;
  long long int maxy = LONG_LONG_MIN;
  long long int count = 0;
  for (long long int i = 0; i < n; i++) {
    for (long long int j = 0; j < m; j++) {
      if (a[i][j] == 'X') {
        minx = min(minx, i);
        miny = min(miny, j);
        maxx = max(maxx, i);
        maxy = max(maxy, j);
        count++;
      }
    }
  }
  if ((maxx - minx + 1) * (maxy - miny + 1) == count) {
    cout << "YES"
         << "\n";
  } else {
    cout << "NO"
         << "\n";
  }
}
