#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const long long INF64 = 1e18;
const double EPS = 1e-9;
const double PI = acos(-1);
const long long MD = 1551513443;
const long long T = 25923;
const int N = 200010;
const int M = 5001;
const bool DEBUG = 1;
int n, m;
pair<int, int> xx, yy;
string a[N];
int main() {
  cin >> n >> m;
  xx = make_pair(INF, -INF);
  yy = make_pair(INF, -INF);
  for (int i = 0; i < int(n); i++) {
    cin >> a[i];
    for (int j = 0; j < int(m); j++)
      if (a[i][j] == 'X') {
        xx.first = min(xx.first, i);
        xx.second = max(xx.second, i);
        yy.first = min(yy.first, j);
        yy.second = max(yy.second, j);
      }
  }
  for (int i = 0; i < int(n); i++)
    for (int j = 0; j < int(m); j++)
      if (a[i][j] != 'X' && i >= xx.first && i <= xx.second && j >= yy.first &&
          j <= yy.second) {
        cout << "NO";
        return 0;
      }
  cout << "YES";
  return 0;
}
