#include <bits/stdc++.h>
using namespace std;
int arr1[27];
int arr2[27];
int main() {
  char str1[100001];
  char str2[100001];
  scanf("%s %s", str1, str2);
  int len1 = strlen(str1);
  int len2 = strlen(str2);
  if (len1 != len2) {
    cout << "NO" << endl;
    return 0;
  }
  int diff = 0;
  for (int i = 0; i < len1; i++) {
    if (str1[i] != str2[i]) diff++;
    arr1[str1[i] - 'a']++;
    arr2[str2[i] - 'a']++;
  }
  for (int i = 0; i < 27; i++)
    if (arr1[i] != arr2[i]) {
      cout << "NO" << endl;
      return 0;
    }
  if (diff == 1)
    cout << "NO" << endl;
  else if (diff == 2)
    cout << "YES" << endl;
  else if (diff == 0) {
    for (int i = 0; i < 27; i++)
      if (arr1[i] > 1) {
        cout << "YES" << endl;
        return 0;
      }
    cout << "NO" << endl;
  } else
    cout << "NO" << endl;
}
