#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  char arr[n + 1][m + 1];
  int cnt = 0;
  int sx = n + 1, lx = -1, sy = m + 1, ly = -1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> arr[i][j];
      if (arr[i][j] == 'X') {
        cnt++;
        sx = min(sx, i);
        sy = min(sy, j);
        lx = max(lx, i);
        ly = max(ly, j);
      }
    }
  }
  if (((lx - sx + 1) * (ly - sy + 1)) == cnt)
    cout << "YES";
  else
    cout << "NO";
}
