#include <bits/stdc++.h>
using namespace std;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
void dout(string name, T arg) {
  cerr << arg << endl;
}
template <typename T1, typename... T2>
void dout(string names, T1 arg, T2... args) {
  cerr << arg << " | ";
  dout(names.substr(names.find(',') + 2), args...);
}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
const int mx = 1e6 + 5;
const int INF = 1000000007;
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % 1000000007;
    y >>= 1;
    x = (x * x) % 1000000007;
  }
  return (res % 1000000007);
}
void solve() {
  long long n, m;
  cin >> n >> m;
  char arr[n][m];
  long long firstX = -1, firstY = -1, secondX = -1, secondY = -1;
  long long count = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == 'X') {
        count++;
        if (firstX == -1) {
          firstX = i, firstY = j;
        }
        if (secondX == -1) {
          secondX = i, secondY = j;
        }
        firstX = min(firstX, (long long)i);
        firstY = min(firstY, (long long)j);
        secondX = max(secondX, (long long)i);
        secondY = max(secondY, (long long)j);
      }
    }
  }
  long long currCount =
      (abs(firstX - secondX) + 1) * (abs(firstY - secondY) + 1);
  if (count == currCount) {
    cout << "YES\n";
  } else {
    cout << "NO\n";
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
