/**
 * Given two sets, count the number of elements that are present in both sets.
 *
 * @param set1 the first set
 * @param set2 the second set
 * @return the number of common elements
 *
 * Example:
 * countCommonElements(setOf(1, 2, 3), setOf(2, 3, 4)) => 2
 * countCommonElements(setOf("apple", "banana", "pear"), setOf("banana", "orange", "grape")) => 1
 */
fun countCommonElements(set1: Set<Any>, set2: Set<Any>): Int {

    var count = 0
    for (element1 in set1) {
        for (element2 in set2) {
            if (element1 == element2) {
                count++
            }
        }
    }
    return count
}
/**
 * Given two sets, count the number of elements that are present in both sets.
 *
 * @param set1 the first set
 * @param set2 the second set
 * @return the number of common elements
 *
 * Example:
 * countCommonElements(setOf(1, 2, 3), setOf(2, 3, 4)) => 2
 * countCommonElements(setOf("apple", "banana", "pear"), setOf("banana", "orange", "grape")) => 1
 */
fun countCommonElements(set1: Set<Any>, set2: Set<Any>): Int {
/**
 * Given two sets, count the number of elements that are present in both sets.
 *
 * @param set1 the first set
 * @param set2 the second set
 * @return the number of common elements
 *
 * Example:
 * countCommonElements(setOf(1, 2, 3), setOf(2, 3, 4)) => 2
 * countCommonElements(setOf("apple", "banana", "pear"), setOf("banana", "orange", "grape")) => 1
 */
fun countCommonElements(set1: Set<Any>, set2: Set<Any>): Int {

    var count = 0
    for (element1 in set1) {
        for (element2 in set2) {
            if (element1 == element2) {
                count++
            }
        }
    }
    return count
}