#include <bits/stdc++.h>
int main() {
  char string1[110000];
  char string2[110000];
  int i;
  scanf("%s %s", string1, string2);
  if (strlen(string1) != strlen(string2)) {
    printf("NO");
    return 0;
  }
  int count1[26] = {0};
  int flag = 0;
  int count2[26] = {0};
  for (i = 0; i < strlen(string1); i++) {
    count1[string1[i] - 'a']++;
    count2[string2[i] - 'a']++;
  }
  for (i = 0; i < 26; i++) {
    if (count1[i] != count2[i]) {
      printf("NO");
      return 0;
    }
  }
  for (i = 0; i < strlen(string1); i++) {
    if (string1[i] != string2[i]) flag++;
  }
  if (flag > 2)
    printf("NO");
  else
    printf("YES");
}
