#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6 + 10;
const int INF = 0x3f3f3f3f;
char str[520][520];
int main() {
  int n, m, s1, s2;
  scanf("%d%d", &n, &m);
  for (int i = 0; i < n; i++) scanf("%s", str[i]);
  int c = n, l = m;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < m; j++) {
      if (str[i][j] == 'X') {
        s1 = i, s2 = j;
        for (int k = i; k <= n; k++) {
          if (str[k][j] != 'X') {
            c = k;
            break;
          }
        }
        for (int k = j; k <= m; k++) {
          if (str[i][k] != 'X') {
            l = k;
            break;
          }
        }
        for (int i = s1; i < c; i++)
          for (int j = s2; j < l; j++)
            if (str[i][j] != 'X') {
              puts("NO");
              return 0;
            } else
              str[i][j] = '.';
        for (int i = 0; i < n; i++)
          for (int j = 0; j < m; j++)
            if (str[i][j] == 'X') {
              puts("NO");
              return 0;
            }
        puts("YES");
        return 0;
      }
    }
  return 0;
}
