#include <bits/stdc++.h>
using namespace std;
int n, m, cnt;
char a[505][505];
int main() {
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      cin >> a[i][j];
    }
  }
  int mini = 99999, minj = 99999;
  int maxi = 0, maxj = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (a[i][j] == 'X') {
        mini = min(mini, i);
        maxi = max(maxi, i);
        minj = min(minj, j);
        maxj = max(maxj, j);
        cnt++;
      }
    }
  }
  if ((maxi - mini + 1) * (maxj - minj + 1) == cnt)
    cout << "YES";
  else
    cout << "NO";
}
