#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, s;
  cin >> a >> s;
  int p = 0, q = 0;
  int x = a.length();
  int y = s.length();
  int k[2];
  int j = 0;
  if (x == y) {
    for (int i = 0; i < x; i++) {
      if (s[i] != a[i]) {
        k[j] = i;
        j++;
        if (j > 2) {
          cout << "NO";
          return 0;
        }
      }
    }
    if (a[k[0]] == s[k[1]] && a[k[1]] == s[k[0]])
      cout << "YES";
    else
      cout << "NO";
  } else
    cout << "NO";
}
