#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  cin >> a >> b;
  long long int s = -1, t = -1;
  if (a.length() == b.length()) {
    for (long long int i = 0; i < a.length(); i++) {
      if (s == -1 && a[i] != b[i])
        s = i;
      else if (t == -1 && a[i] != b[i]) {
        t = i;
        break;
      }
    }
    char temp = a[s];
    a[s] = a[t];
    a[t] = temp;
    if (a == b)
      cout << "YES";
    else
      cout << "NO";
  } else
    cout << "NO";
}
