#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  string s[500];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
  }
  int left = 500, right = 0, up = 500, down = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (s[i][j] == 'X') {
        left = min(left, j);
        right = max(right, j);
        up = min(up, i);
        down = max(down, i);
      }
    }
  }
  for (int i = up; i <= down; i++) {
    for (int j = left; j <= right; j++) {
      if (s[i][j] == '.') {
        cout << "NO";
        return 0;
      }
    }
  }
  cout << "YES";
  return 0;
}
