#include <bits/stdc++.h>
using namespace std;
inline void boost() {
  ios_base::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
}
const int INF = 1e9 + 5;
char q[505][505];
int n, m, cnt;
void calc() {
  pair<int, int> l, r;
  l = make_pair(INF, INF);
  r = make_pair(0, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (q[i][j] == 'X') {
        l.first = min(l.first, i);
        l.second = min(l.second, j);
        r.first = max(r.first, i);
        r.second = max(r.second, j);
      }
    }
  }
  for (int i = l.first; i <= r.first; i++) {
    for (int j = l.second; j <= r.second; j++) {
      if (q[i][j] != 'X') {
        cout << "NO";
        return;
      }
    }
  }
  cout << "YES";
}
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) cin >> q[i][j];
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++)
      if (q[i][j] == 'X') cnt++;
  calc();
  return 0;
}
