#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int main(void) {
  char arr1[N] = {0};
  char arr2[N] = {0};
  char str1[2] = {0}, str2[2] = {0};
  scanf("%[^\n]s", arr1);
  scanf(" %[^\n]s", arr2);
  if (strlen(arr1) != strlen(arr2)) {
    cout << "NO\n";
    return 0;
  }
  int a = 0;
  for (int i = 0, j = 0, k = 0; i < strlen(arr1); i++) {
    if (arr1[i] != arr2[i]) {
      a++;
      if (a <= 2) {
        str1[j++] = arr1[i];
        str2[k++] = arr2[i];
      }
    }
  }
  if (a == 2) {
    if ((str1[1] == str2[0]) && (str1[0] == str2[1]))
      cout << "YES\n";
    else
      cout << "NO\n";
  } else
    cout << "NO\n";
  return 0;
}
