#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  int minx = n, miny = m, maxx = 0, maxy = 0, t = 0;
  char x[502][502];
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      cin >> x[i][j];
      if (x[i][j] == 'X')
        minx = min(minx, i), miny = min(miny, j), maxx = max(maxx, i),
        maxy = max(maxy, j);
    }
  for (int i = minx; i <= maxx; i++)
    for (int j = miny; j <= maxy; j++)
      if (x[i][j] != 'X') t = 1;
  if (!t)
    cout << "YES";
  else
    cout << "NO";
  return 0;
}
