#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;
  char grid[n][m];
  int x1 = 1e9, y1 = 1e9, x2 = 0, y2 = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> grid[i][j];
      if (grid[i][j] == 'X')
        x1 = min(x1, i), y1 = min(y1, j), x2 = max(x2, i), y2 = max(y2, j);
    }
  bool ok = true;
  for (int i = x1; i <= x2; i++)
    for (int j = y1; j <= y2; j++)
      if (grid[i][j] != 'X') ok = false;
  if (ok)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
