#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int count = 0;
  string a, b;
  cin >> a >> b;
  if (a.length() != b.length()) {
    cout << "NO";
    exit(0);
  }
  string c = a;
  string d = b;
  sort(c.begin(), c.end());
  sort(d.begin(), d.end());
  if (c != d) {
    cout << "NO";
    return 0;
  }
  for (long long int i = 0; i < a.length(); i++) {
    if (a[i] != b[i]) {
      count++;
    }
  }
  if (count == 2) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
