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