#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
int main() {
  string s1, s2;
  cin >> s1 >> s2;
  ll ar[200] = {0};
  if (s1.size() != s2.size()) {
    cout << "NO\n";
    return 0;
  }
  pair<char, char> fst = {0, 0};
  auto dob = false;
  ll cnt[200] = {0};
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] == s2[i]) {
      cnt[s1[i]]++;
      if (cnt[s1[i]] > 1) dob = true;
      continue;
    }
    if (fst.first == 0 and fst.second == 0) {
      fst = {s1[i], s2[i]};
    } else {
      if (s1[i] == fst.second and s2[i] == fst.first) {
        fst = {-1, -1};
      } else {
        cout << "NO\n";
        return 0;
      }
    }
  }
  if (fst.first == 0 and fst.second == 0) {
    if (dob)
      cout << "YES\n";
    else
      cout << "NO\n";
  } else if (fst.first == -1 and fst.second == -1)
    cout << "YES\n";
  else
    cout << "NO\n";
  return 0;
  return 0;
}
