#include <bits/stdc++.h>
using namespace std;
int main() {
  int m, n;
  cin >> n >> m;
  char array[n][m];
  int leftx, lefty, rightx, righty;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> array[i][j];
    };
  };
  bool found = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (array[i][j] == 'X') {
        leftx = i;
        lefty = j;
        found = true;
        break;
      }
    };
    if (found) break;
  };
  found = false;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--) {
      if (array[i][j] == 'X') {
        rightx = i;
        righty = j;
        found = true;
        break;
      };
    };
    if (found) break;
  };
  bool poss = true;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (array[i][j] == '.' && i <= rightx && i >= leftx && j <= righty &&
          j >= lefty) {
        poss = false;
        break;
      };
      if (array[i][j] == 'X' &&
          (i < leftx || i > rightx || j < lefty || j > righty)) {
        poss = false;
        break;
      }
    };
    if (poss == false) break;
  };
  if (poss)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}
