#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  int x = 0;
  bool f = 0;
  char a, b, c, d;
  cin >> s1 >> s2;
  if (s1.size() != s2.size()) {
    cout << "NO\n";
    return 0;
  }
  for (int i = 0; i < s1.size(); ++i) {
    if (s1[i] != s2[i]) {
      if (x == 0) {
        a = s1[i];
        b = s2[i];
      } else {
        c = s1[i];
        d = s2[i];
      }
      ++x;
    }
  }
  if (x == 2) {
    if (a == d && c == b)
      cout << "YES\n";
    else
      f = 1;
  } else
    f = 1;
  if (f) cout << "NO\n";
  return 0;
}
