#include <bits/stdc++.h>
using namespace std;
string vs[1005];
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> vs[i];
  pair<int, int> a = {-1, -1}, b = {-1, -1};
  int cnt = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++)
      if (vs[i][j] == 'X') {
        if (a == pair<int, int>(-1, -1)) a = {i, j};
        b = {i, j};
        cnt++;
      }
  if ((b.first - a.first + 1) * (b.second - a.second + 1) != cnt) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = a.first; i <= b.first; i++)
    for (int j = a.second; j <= b.second; j++)
      if (vs[i][j] != 'X') {
        cout << "NO" << endl;
        return 0;
      }
  cout << "YES" << endl;
  return 0;
}
