#include <bits/stdc++.h>
using namespace std;
int a, s, d, f, g, h, j, k, l, i, n, m;
string z, x;
char c[4][4];
int main() {
  cin >> z >> x;
  a = z.size();
  s = x.size();
  if (a != s) {
    cout << "NO";
    return 0;
  }
  for (i = 0; i < a; i++) {
    if (z[i] != x[i]) {
      c[l][0] = z[i];
      c[l][1] = x[i];
      l++;
      if (l == 3) {
        cout << "NO";
        return 0;
      }
    }
  }
  if (c[0][0] == c[1][1] && c[0][1] == c[1][0]) {
    cout << "YES";
  } else {
    cout << "NO";
  }
}
