#include <bits/stdc++.h>
using namespace std;
char g[1024][1024];
int n, m;
set<string> ss;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  int mx = -1, my = -1, nx = 600, ny = 600;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      cin >> g[i][j];
      if (g[i][j] == 'X') {
        my = i;
        mx = max(mx, j);
        nx = min(nx, j);
        ny = min(ny, i);
      }
    }
  }
  for (int j = ny; j <= my; j++)
    for (int i = nx; i <= mx; i++)
      if (g[j][i] != 'X') {
        cout << "NO" << endl;
        return 0;
      }
  cout << "YES" << endl;
  return 0;
}
