#include <bits/stdc++.h>
using namespace std;
void solve() {
  string x, y;
  cin >> x >> y;
  if (x.size() != y.size()) {
    {
      cout << "NO" << endl;
      return;
    }
  }
  int count = 0;
  map<char, int> m;
  pair<int, int> index;
  for (int i = 0; i < x.size(); ++i) {
    if (x[i] != y[i]) {
      ++count;
      if (count == 1) index.first = i;
      if (count == 2) index.second = i;
    }
    m[x[i]]++;
  }
  if (count == 0) {
    for (map<char, int>::iterator it = m.begin(); it != m.end(); ++it) {
      if (it->second > 1) {
        {
          cout << "YES" << endl;
          return;
        }
      }
    }
    {
      cout << "NO" << endl;
      return;
    }
  }
  if (count == 2) {
    int i1 = index.first;
    int i2 = index.second;
    if (x[i1] == y[i2] and x[i2] == y[i1]) {
      {
        cout << "YES" << endl;
        return;
      }
    }
  }
  {
    cout << "NO" << endl;
    return;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  for (int i = 0; i < t; ++i) {
    solve();
  }
  return 0;
}
