#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m, Xl = 1e9, Yl = 1e9, Xr = 0, Yr = 0;
  cin >> n >> m;
  vector<string> A(n);
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++)
    for (int u = 0; u < m; u++)
      if (A[i][u] == 'X') {
        Xl = min(Xl, i), Yl = min(Yl, u);
        Xr = max(Xr, i), Yr = max(Yr, u);
      }
  for (int i = Xl; i <= Xr; i++)
    for (int u = Yl; u <= Yr; u++)
      if (A[i][u] == '.') {
        cout << "NO";
        return 0;
      }
  cout << "YES";
  return 0;
}
