#include <bits/stdc++.h>
using namespace std;
int main() {
  string s1, s2;
  cin >> s1;
  cin >> s2;
  int i, c = 0;
  map<char, int> m1;
  map<char, int>::iterator it;
  map<char, int> m2;
  if (s1.length() == s2.length()) {
    for (i = 0; i < s1.length(); i++) {
      m1[s1[i]]++;
      m2[s1[i]]++;
    }
    int flag = -1;
    for (i = 0; i < s1.length(); i++) {
      if (m1[s1[i]] != m2[s1[i]]) {
        flag = 1;
        break;
      }
    }
    for (i = 0; i < s1.length(); i++) {
      if (s1[i] != s2[i]) c++;
    }
    sort(s1.begin(), s1.end());
    sort(s2.begin(), s2.end());
    if (s2 == s1 && c / 2 == 1 && flag != 1)
      cout << "YES"
           << "\n";
    else
      cout << "NO"
           << "\n";
  } else
    cout << "NO"
         << "\n";
  return 0;
}
