/**
 * Given a matrix of integers and a target value, returns the number of occurrences of the target in the matrix.
 *
 * @param matrix A 2D list of integers representing the matrix.
 * @param target An integer representing the value to be counted.
 * @return An integer representing the number of occurrences of the target value in the matrix.
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {

    // Initialize the count variable
    var count = 0

    // Iterate over each row in the matrix
    for (row in matrix) {
        // Iterate over each element in the row
        for (num in row) {
            // Check if the current element of the row equals the target value
            if (num == target) {
                // Increment the count variable if the condition is true
                count++
            }
        }
    }

    // Return the final count value
    return count
}
/**
 * Given a matrix of integers and a target value, returns the number of occurrences of the target in the matrix.
 *
 * @param matrix A 2D list of integers representing the matrix.
 * @param target An integer representing the value to be counted.
 * @return An integer representing the number of occurrences of the target value in the matrix.
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {
/**
 * Given a matrix of integers and a target value, returns the number of occurrences of the target in the matrix.
 *
 * @param matrix A 2D list of integers representing the matrix.
 * @param target An integer representing the value to be counted.
 * @return An integer representing the number of occurrences of the target value in the matrix.
 */
fun countOccurrences(matrix: List<List<Int>>, target: Int): Int {

    // Initialize the count variable
    var count = 0

    // Iterate over each row in the matrix
    for (row in matrix) {
        // Iterate over each element in the row
        for (num in row) {
            // Check if the current element of the row equals the target value
            if (num == target) {
                // Increment the count variable if the condition is true
                count++
            }
        }
    }

    // Return the final count value
    return count
}