#include <bits/stdc++.h>
using namespace std;
int main() {
  int x1 = 600;
  int x2 = -1;
  int y1 = 600;
  int y2 = -1;
  int x, y;
  char P[505][505];
  cin >> x >> y;
  int br = 0;
  for (int i = 0; i < x; i++)
    for (int j = 0; j < y; j++) {
      cin >> P[i][j];
      if (P[i][j] == 'X') {
        x1 = min(i, x1);
        x2 = max(i, x2);
        y1 = min(j, y1);
        y2 = max(j, y2);
      }
    }
  for (int i = x1; i <= x2; i++)
    for (int j = y1; j <= y2; j++)
      if (P[i][j] != 'X') {
        cout << "NO";
        return 0;
      }
  cout << "YES";
  return 0;
}
