Input Format
The first line contains , the number of students who have subscribed to the English newspaper.
The second line contains  space separated roll numbers of those students.
The third line contains , the number of students who have subscribed to the French newspaper.
The fourth line contains  space separated roll numbers of those students.
Constraints
Output Format
Output the total number of students who have subscriptions to both English and French newspapers.

hackerrank set intersection operation problem solution in python programming

Problem solution in Python 3 programming language.

E = int(input())
English = set(input().split())

F = int(input())
French = set(input().split())

print(len(English & French))

Second solution

# Enter your code here. Read input from STDIN. Print output to STDOUT
num1, st1, num2, st2 = (set(input().split()) for i in range(4))
print(len(st1.intersection(st2)))

Problem solution in Python 2 programming language.

E = int(raw_input())
English = set(raw_input().split())

F = int(raw_input())
French = set(raw_input().split())

print len(English & French)