#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  if (b == 0) {
    return a;
  }
  return gcd(b, a % b);
}
bool isPrime(long long int n) {
  if (n == 1) return false;
  for (long long int i = 2; i * i < n; ++i) {
    if (n % i == 0) return false;
  }
  return true;
}
void solve() {
  string a, b;
  long long int ar[4], i, c = 0, k = 0;
  cin >> a;
  cin >> b;
  if (a.size() != b.size()) {
    cout << "NO" << endl;
    return;
  }
  for (i = 0; i < a.size(); i++) {
    if (a[i] != b[i]) {
      c++;
      if (c > 2) {
        cout << "NO" << endl;
        return;
      }
      ar[k++] = a[i];
      ar[k++] = b[i];
    }
  }
  if (ar[0] == ar[3] && ar[1] == ar[2]) {
    cout << "YES" << endl;
  } else
    cout << "NO" << endl;
}
int main() {
  long long int t = 1;
  while (t--) {
    solve();
    cout << endl;
  }
}
