#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
char s1[N], s2[N];
int main() {
  scanf(" %s %s", s1, s2);
  int len1 = strlen(s1);
  int len2 = strlen(s2);
  if (len1 == len2) {
    if (len1 == 1) {
      puts(s1[0] == s2[0] ? "YES" : "NO");
    } else {
      int p1 = -1, p2 = -1;
      for (int i = 0; i < len1; i++) {
        if (s1[i] != s2[i]) {
          if (p1 == -1) {
            p1 = i;
          } else if (p2 == -1) {
            p2 = i;
          } else {
            p1 = p2 = -1;
            break;
          }
        }
      }
      if (p1 != -1 && p2 != -1 && s1[p1] == s2[p2] && s1[p2] == s2[p1])
        puts("YES");
      else
        puts("NO");
    }
  } else {
    puts("NO");
  }
  return 0;
}
