#include <bits/stdc++.h>
using namespace std;
inline int sci() {
  int a;
  scanf("%d", &a);
  return a;
}
int main() {
  string a, b;
  cin >> a >> b;
  int diff = 0;
  if (a.length() != b.length()) {
    cout << "NO";
    return 0;
  }
  int n = a.length();
  if (n < 2) {
    cout << "NO";
    return 0;
  }
  vector<int> pos;
  for (int i = 0; i < n; ++i)
    if (a[i] != b[i]) pos.push_back(i);
  if (pos.size() != 0 && pos.size() != 2) {
    cout << "NO";
    return 0;
  }
  if (pos.size() == 0) {
    cout << "YES";
    return 0;
  }
  string a1, b1;
  for (int i = 0; i < pos.size(); ++i) {
    a1 += a[pos[i]];
    b1 += b[pos[i]];
  }
  sort(a1.begin(), a1.end());
  sort(b1.begin(), b1.end());
  if (a1 == b1) {
    cout << "YES";
  } else
    cout << "NO";
  return 0;
}
