#include <bits/stdc++.h>
long long dx[4] = {-1, 0, 1, 0};
long long dy[4] = {0, -1, 0, 1};
long long mod = 1e9 + 7;
long long inf = INT_MAX;
bool vis[100000];
using namespace std;
bool isPrime(long long n) {
  long long j;
  for (j = 2; j <= sqrt(n); j++) {
    if (n % j == 0) {
      break;
    }
  }
  if (j > sqrt(n)) {
    return 1;
  } else {
    return 0;
  }
}
long long modexpo(long long a, long long b) {
  long long ans = 1;
  a = a % mod;
  while (b > 0) {
    if ((b & 1) == 1) {
      ans = ((ans % mod) * (a % mod)) % mod;
    }
    b = b >> 1;
    a = ((a % mod) * (a % mod)) % mod;
  }
  return ans;
}
long long invmod(long long n) { return modexpo(n, mod - 2); }
long long comb(long long n, long long r) {
  if (r == 0) {
    return 1;
  }
  long long fact[n + 1];
  fact[0] = 1;
  for (long long i = 1; i <= n; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  return (fact[n] * invmod(fact[r]) % mod * invmod(fact[n - r]) % mod) % mod;
}
long long gcd(long long a, long long b) {
  if (a == 0) {
    return b;
  }
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) {
  return ((a / gcd(a, b)) * (b / gcd(a, b))) * gcd(a, b);
}
bool sortbysecdesc(const pair<long long, long long> &a,
                   const pair<long long, long long> &b) {
  return a.second > b.second;
}
bool prime[1000005];
void sieve(int n) {
  memset(prime, true, sizeof(prime));
  for (int p = 2; p * p <= n; p++) {
    if (prime[p] == true) {
      for (int i = p * p; i <= n; i += p) prime[i] = false;
    }
  }
}
void dfs(long long i, vector<long long> adj[], bool visited[]) {
  visited[i] = 1;
  for (auto j : adj[i]) {
    if (visited[j] == 0) {
      dfs(j, adj, visited);
    }
  }
}
void solve(long long k) {
  string a;
  string b;
  cin >> a;
  cin >> b;
  if (a.size() != b.size()) {
    cout << "NO"
         << "\n";
    return;
  }
  long long c = 0, d, e;
  for (long long i = 0; i < a.size(); i++) {
    if (a[i] != b[i]) {
      c++;
      if (c > 1) {
        e = i;
      } else {
        d = i;
      }
    }
  }
  if (c != 2) {
    cout << "NO"
         << "\n";
    return;
  }
  if (a[d] != b[e] || a[e] != b[d]) {
    cout << "NO"
         << "\n";
    return;
  }
  cout << "YES"
       << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t = 1;
  long long k = 1;
  while (k <= t) {
    solve(k);
    k++;
  }
  return 0;
}
