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