#include <bits/stdc++.h>
using namespace std;
int n, m, x = -1, y, xx, yy, k;
bool a[510][510];
char h;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> h;
      if (h == 'X') {
        a[i][j] = true;
        if (x == -1) {
          x = i;
          y = j;
        }
        xx = i;
        yy = j;
        k++;
      }
    }
  }
  for (int i = x; i <= xx; i++) {
    for (int j = y; j <= yy; j++) {
      if (!a[i][j]) {
        cout << "NO";
        return 0;
      }
      k--;
    }
  }
  if (k > 0)
    cout << "NO";
  else
    cout << "YES";
  return 0;
}
