#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  if (a.size() != b.size())
    cout << "NO" << endl;
  else {
    int cnt = 0;
    for (int i = 0; a[i] != '\0'; i++) {
      if (a[i] != b[i]) cnt++;
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if (a == b && cnt == 2)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
