#include <bits/stdc++.h>
using namespace std;
const int maxN = 505, maxM = 505;
char board[maxN][maxM];
int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> board[i][j];
    }
  }
  int up = -1, down = -1, left = -1, right = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (board[i][j] == 'X') {
        up = i;
        break;
      }
    }
    if (up != -1) break;
  }
  for (int j = 0; j < m; j++) {
    for (int i = 0; i < n; i++) {
      if (board[i][j] == 'X') {
        left = j;
        break;
      }
    }
    if (left != -1) break;
  }
  for (int i = n - 1; i >= 0; i--) {
    for (int j = 0; j < m; j++) {
      if (board[i][j] == 'X') {
        down = i;
        break;
      }
    }
    if (down != -1) break;
  }
  for (int j = m - 1; j >= 0; j--) {
    for (int i = 0; i < n; i++) {
      if (board[i][j] == 'X') {
        right = j;
        break;
      }
    }
    if (right != -1) break;
  }
  for (int i = up; i <= down; i++) {
    for (int j = left; j <= right; j++) {
      if (board[i][j] != 'X') {
        cout << "NO" << '\n';
        return 0;
      }
    }
  }
  cout << "YES" << '\n';
  return 0;
}
