#include <bits/stdc++.h>
using namespace std;
char s[505][505];
int main() {
  ios::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  int vth1 = 1000000000, vtc1 = 1000000000, vth2 = 0, vtc2 = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      cin >> s[i][j];
      if (s[i][j] == 'X') {
        vth1 = min(vth1, i);
        vth2 = max(vth2, i);
        vtc1 = min(vtc1, j);
        vtc2 = max(vtc2, j);
      }
    }
  for (int i = vth1; i <= vth2; i++)
    for (int j = vtc1; j <= vtc2; j++)
      if (s[i][j] != 'X') {
        cout << "NO";
        exit(0);
      }
  cout << "YES";
}
