#include <bits/stdc++.h>
int size(char *&p) {
  int i = 0;
  while (p[i++] != '\0')
    ;
  return i;
}
bool nnedd(char *&arg1, char *&arg2) {
  int len = size(arg1);
  int len2 = size(arg2);
  if (len != len2) return false;
  int count = 0;
  char p[4];
  for (int i = 0; i < 4; i++) p[i] = '\0';
  for (int i = 0; i < len; i++)
    if (arg1[i] != arg2[i]) {
      p[2 * count] = arg1[i];
      p[2 * count + 1] = arg2[i];
      if (++count > 2) return false;
    }
  if (p[0] != p[1] && p[0] != p[3]) return false;
  if (p[2] != p[1] && p[2] != p[3]) return false;
  return true;
}
int main() {
  char *p = new char[100001];
  char *d = new char[100001];
  scanf("%s", p);
  scanf("%s", d);
  if (nnedd(p, d) == true)
    printf("%s", "YES\n");
  else
    printf("%s", "NO\n");
  delete[] p;
  delete[] d;
  return 0;
}
