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