#include <bits/stdc++.h>
using namespace std;
char a[100010], b[100010];
int c[10];
int main() {
  scanf("%s%s", a, b);
  memset(c, 0, sizeof(c));
  int len1 = strlen(a), flag = 0;
  int len2 = strlen(b);
  if (len1 != len2) {
    printf("NO\n");
    return 0;
  }
  int k = 0;
  for (int i = 0; i < len1; i++) {
    if (a[i] != b[i]) {
      c[k++] = i;
      if (k > 2) {
        flag = 1;
        break;
      }
    }
  }
  if (a[c[0]] != b[c[1]] || a[c[1]] != b[c[0]]) flag = 1;
  if (flag == 1)
    printf("NO\n");
  else
    printf("YES\n");
}
