import 'dart:io';

void main() {
  String s = stdin.readLineSync();
  String t = stdin.readLineSync();

  List ss = s.split("");
  List sortS = ss..sort();
  String stringS = sortS.join();
  List tt = t.split("");
  List sortT = tt..sort((b, a) => a.compareTo(b));

  String stringT = sortT.join();
  List before = [stringS, stringT];
  String before1 = stringS;
  String after1 = (before..sort())[0];
  String before2 = stringT;
  String after2 = (before..sort())[1];
  if (before1 == after1 && before2 == after2) {
    print("No");
  } else if (before1 != after1) {
    print("No");
    return;
  } else if (before1 == after1) {
    print("Yes");
    return;
  }
}
