#include <bits/stdc++.h>
using namespace std;
int n, m;
int main() {
  cin >> n >> m;
  char arr[n][m];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
    }
  }
  int i0 = 0, j0 = 0, i00 = 0, j00 = 0, ch0 = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 'X') {
        ch0 = i;
        break;
      }
    }
    if (ch0 != -1) break;
  }
  for (int j = 0; j < m; j++) {
    if (arr[ch0][j] == 'X') {
      i0 = ch0, j0 = j;
      break;
    }
  }
  for (int j = 0; j < m; j++) {
    if (arr[ch0][j] == 'X') {
      i00 = ch0, j00 = j;
    }
  }
  int i1 = 0, j1 = 0, i11 = 0, j11 = 0, ch1 = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (arr[i][j] == 'X') {
        ch1 = i;
      }
    }
  }
  for (int j = 0; j < m; j++) {
    if (arr[ch1][j] == 'X') {
      i1 = ch1, j1 = j;
      break;
    }
  }
  for (int j = 0; j < m; j++) {
    if (arr[ch1][j] == 'X') {
      i11 = ch1, j11 = j;
    }
  }
  if (j0 != j1 || j00 != j11) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = i0; i <= i1; i++) {
    for (int j = j0; j <= j00; j++) {
      if (arr[i][j] != 'X') {
        cout << "NO" << endl;
        return 0;
      }
    }
  }
  cout << "YES" << endl;
  return 0;
}
