#include <bits/stdc++.h>
using namespace std;
const int N = 100000 + 10;
const int M = 1000000007;
const double PI = atan(1) * 4;
const int oo = 2100000000;
int n, m;
vector<string> v;
int main() {
  cin >> n >> m;
  v.resize(n);
  for (int i = 0; i < n; ++i) cin >> v[i];
  int U = 600, D = -1, R = -1, L = 600;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (v[i][j] == 'X') {
        U = min(U, i);
        D = max(D, i);
        R = max(R, j);
        L = min(L, j);
      }
  for (int i = U; i <= D; ++i)
    for (int j = L; j <= R; ++j)
      if (v[i][j] != 'X') {
        cout << "NO";
        return 0;
      }
  cout << "YES";
}
