#include <bits/stdc++.h>
using namespace std;
unsigned long long int counter = 0;
vector<char> v;
void sortMe(int arr[], int size) {
  while (size--) {
    for (int i = 0; i < size; i++) {
      if (arr[i] > arr[i + 1]) {
        int temp = arr[i];
        arr[i] = arr[i + 1];
        arr[i + 1] = temp;
      }
    }
  }
}
int getMax(int arr[], int size) {
  int maxim = 0;
  for (int i = 0; i < size; i++) {
    if (arr[i] > maxim) maxim = arr[i];
  }
  return maxim;
}
bool prime(int x) {
  for (int i = 2; i <= sqrt(x); i++) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
int power(int n, int k) {
  if (n == 0)
    return 1;
  else if (n == 1)
    return 1;
  else
    return n * power(n, k - 1);
}
struct ship {
  string c, b;
};
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  int arr[27] = {0};
  int arr2[27] = {0};
  if (s1.size() != s2.size()) {
    cout << "NO" << endl;
    return 0;
  } else {
    bool p = true;
    for (int i = 0; i < s1.size(); i++) {
      if (s1[i] != s2[i]) counter++;
    }
    for (int i = 0; i < s1.size(); i++) {
      int index = s1[i] - 97;
      arr[index]++;
      index = s2[i] - 97;
      arr2[index]++;
    }
    for (int i = 0; i < 26; i++) {
      if (arr[i] != arr2[i]) {
        p = false;
        ;
      }
    }
    if (!p || counter != 2) {
      cout << "NO" << endl;
      return 0;
    }
    cout << "YES" << endl;
  }
}
