#include <bits/stdc++.h>
using namespace std;
char str1[100005], str2[100005];
int main() {
  cin >> str1 >> str2;
  int a, b, c, d, e = 0;
  a = strlen(str1);
  b = strlen(str2);
  if (a != b) cout << "NO" << endl;
  if (a == b) {
    for (int i = 0; i < a; i++) {
      if (str1[i] != str2[i]) {
        e++;
        if (e == 1) c = i;
        if (e == 2) d = i;
        if (e > 2) break;
      }
    }
    if (e != 2) cout << "NO" << endl;
    if (e == 2) {
      if (str1[c] == str2[d] && str1[d] == str2[c])
        cout << "YES" << endl;
      else
        cout << "NO" << endl;
    }
  }
  return 0;
}
