import sys


def main():
    answer = 0

    for line in sys.stdin:
        signal_patterns_str, output_digits_str = line.split(" | ")

        answer += sum(
            len(output_digits) in [2, 4, 3, 7]
            for output_digits in output_digits_str.split()
        )

    print(answer)


if __name__ == "__main__":
    main()
