#include <bits/stdc++.h>
using namespace std;
char s1[1000000], s2[1000000];
int wa[1000000];
int main() {
  scanf("%s", s1);
  scanf("%s", s2);
  int ok = false, l;
  if ((l = strlen(s1)) == strlen(s2)) {
    int cnt = 0;
    for (int i = 0; i < l; i++)
      if (s1[i] != s2[i]) {
        wa[++cnt] = i;
      }
    if (cnt == 2) {
      if (s1[wa[1]] == s2[wa[2]] && s1[wa[2]] == s2[wa[1]])
        ok = true;
      else
        ok = false;
    } else
      ok = false;
  } else
    ok = false;
  if (ok)
    printf("YES\n");
  else
    printf("NO\n");
}
