#include <bits/stdc++.h>
using namespace std;
long long int n, m;
char grid[507][507];
int main() {
  cin >> n >> m;
  long long int maxx = 0, minx = INT_MAX, miny = INT_MAX, maxy = 0;
  for (long long int i = 0; i < n; ++i) {
    for (long long int j = 0; j < m; ++j) {
      cin >> grid[i][j];
      if (grid[i][j] == 'X') {
        maxx = max(maxx, i);
        minx = min(minx, i);
        miny = min(miny, j);
        maxy = max(maxy, j);
      }
    }
  }
  for (long long int i = minx; i <= maxx; ++i) {
    for (long long int j = miny; j <= maxy; ++j) {
      if (grid[i][j] == '.') {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
