#include <bits/stdc++.h>
using namespace std;
string a, b;
int rs, p;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> b;
  if (a.size() != b.size()) return cout << "NO", 0;
  for (int i = 0; i < a.size(); i++)
    if (a[i] != b[i]) rs++, p = i;
  if (rs != 2) return cout << "NO", 0;
  for (int i = 0; i < a.size(); i++)
    if (a[i] != b[i] && a[i] == b[p] && a[p] == b[i])
      return cout << "YES", 0;
    else if (a[i] != b[i])
      return cout << "NO", 0;
}
