#include <bits/stdc++.h>
using namespace std;
int f[505][505];
string a[505];
int n, m;
int main() {
  ios::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 0; i < n; i++) cin >> a[i];
  pair<int, int> x(-1, -1), y(-1, -1);
  int cnt = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) {
      f[i][j] = f[i - 1][j] + f[i][j - 1] - f[i - 1][j - 1];
      if (a[i - 1][j - 1] == 'X') {
        f[i][j]++;
        if (x.first == -1) x = pair<int, int>(i, j);
        y = pair<int, int>(i, j);
        cnt++;
      }
    }
  int s = f[y.first][y.second] - f[x.first - 1][y.second] -
          f[y.first][x.second - 1] + f[x.first - 1][x.second - 1];
  if (cnt == (y.second - x.second + 1) * (y.first - x.first + 1) && s == cnt)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
}
