#include <bits/stdc++.h>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  char grid[n][m];
  int lx = 8000, ly = 8000, rx = 0, ry = 0;
  for (int i = 0; i < (int)(n); ++i) {
    for (int j = 0; j < (int)(m); ++j) {
      cin >> grid[i][j];
      if (grid[i][j] == 'X') {
        lx = min(lx, i);
        ly = min(ly, j);
        rx = max(rx, i);
        ry = max(ry, j);
      }
    }
  }
  for (int i = (int)(lx); i <= (int)(rx); ++i) {
    for (int j = (int)(ly); j <= (int)(ry); ++j) {
      if (grid[i][j] == '.') {
        puts("NO");
        return 0;
      }
    }
  }
  puts("YES");
  return 0;
}
