def count_failed_students(student_scores):
    """
    :param student_scores: list of integer student scores.
    :return: integer count of student scores at or below 40.
    """
    total = 0
    for score in student_scores:
        if score <= 40:
            total += 1
    return total