#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1000000000;
constexpr int MODULO = 1000000007;
constexpr int64_t dx[4] = {1, 0, -1, 0};
constexpr int64_t dy[4] = {0, 1, 0, -1};
template <typename STL>
inline void print_STL(STL c, string ab = "") {
  cout << ab << '\n';
  for (auto t : c) cout << t << ' ';
  cout << '\n';
}
template <typename VEC>
inline void import_VEC(VEC& c, int64_t n) {
  typename VEC::value_type tmp;
  for (int64_t i = 0; i < n; ++i) {
    cin >> tmp;
    c.push_back(tmp);
  }
}
template <class T>
using Matrix = vector<vector<T>>;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  Matrix<char> mat;
  int64_t n, m;
  cin >> n >> m;
  for (int64_t i = (0); i < (n); ++i) {
    mat.push_back({});
    import_VEC(mat.back(), m);
  }
  int64_t l = -1;
  int64_t r = -1;
  for (int64_t i = (0); i < (n); ++i) {
    int64_t nl = -1;
    int64_t nr = -1;
    int64_t j = 0;
    while (j < m && mat[i][j] != 'X') j++;
    nl = j;
    while (j < m && mat[i][j] == 'X') j++;
    nr = j;
    while (j < m && mat[i][j] != 'X') j++;
    if (j < m) {
      cout << "NO\n";
      return 0;
    }
    if (l == -1 && nl < nr) {
      l = nl;
      r = nr;
    } else if (nl < nr && (l != nl || r != nr)) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";
}
