#include <bits/stdc++.h>
using namespace std;
char str[510][510];
int n, m, maxx, minx, maxy, miny;
bool flag;
int main() {
  cin >> n >> m;
  for (int i = 0; i < n; ++i) scanf("%s", str[i]);
  minx = miny = 0x3f3f3f3f;
  maxx = maxy = -0x3f3f3f3f;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < m; ++j)
      if (str[i][j] == 'X') {
        minx = min(minx, j);
        maxx = max(maxx, j);
        miny = min(miny, i);
        maxy = max(maxy, i);
      }
  flag = true;
  for (int i = miny; i <= maxy; ++i)
    for (int j = minx; j <= maxx; ++j)
      if (str[i][j] != 'X') {
        flag = false;
        break;
      }
  if (flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}
