#include <bits/stdc++.h>
using namespace std;
int n, m;
const int MAXN = 505;
char grid[MAXN][MAXN];
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) cin >> grid[i][j];
  int x1 = 0, y1 = 0, x2 = 0, y2 = 0;
  bool done = false;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++)
      if (grid[i][j] == 'X') {
        x1 = i;
        y1 = j;
        done = true;
        break;
      }
    if (done) break;
  }
  done = false;
  for (int i = n - 1; i >= 0; i--) {
    for (int j = m - 1; j >= 0; j--)
      if (grid[i][j] == 'X') {
        x2 = i;
        y2 = j;
        done = true;
        break;
      }
    if (done) break;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (i >= x1 && i <= x2 && j >= y1 && j <= y2) {
        if (grid[i][j] != 'X') {
          cout << "NO\n";
          return 0;
        }
      } else {
        if (grid[i][j] == 'X') {
          cout << "NO\n";
          return 0;
        }
      }
    }
  cout << "YES\n";
  return 0;
}
