.difference()
  
The tool .difference() returns a set with all the elements from the set that are not in an iterable.

Sometimes the - operator is used in place of the .difference() tool, but it only operates on the set of elements in set.

Set is immutable to the .difference() operation (or the - operation).

>>> s = set("Hacker")
>>> print s.difference("Rank")
set(['c', 'r', 'e', 'H'])

>>> print s.difference(set(['R', 'a', 'n', 'k']))
set(['c', 'r', 'e', 'H'])

>>> print s.difference(['R', 'a', 'n', 'k'])
set(['c', 'r', 'e', 'H'])

>>> print s.difference(enumerate(['R', 'a', 'n', 'k']))
set(['a', 'c', 'r', 'e', 'H', 'k'])

>>> print s.difference({"Rank":1})
set(['a', 'c', 'e', 'H', 'k', 'r'])

>>> s - set("Rank")
set(['H', 'c', 'r', 'e'])

Task
  
Students of District College have a subscription to English and French newspapers. Some students have subscribed to only the English newspaper, some have subscribed to only the French newspaper, and some have subscribed to both newspapers.

You are given two sets of student roll numbers. One set has subscribed to the English newspaper, and one set has subscribed to the French newspaper. Your task is to find the total number of students who have subscribed to only English newspapers.

Input Format

The first line contains the number of students who have subscribed to the English newspaper. 

The second line contains the space separated list of student roll numbers who have subscribed to the English newspaper.

The third line contains the number of students who have subscribed to the French newspaper. 

The fourth line contains the space separated list of student roll numbers who have subscribed to the French newspaper.

Constraints

$0<\textit{Total number of students in college}<1000$

Output Format

Output the total number of students who are subscribed to the English newspaper only. 

Sample Input
9
1 2 3 4 5 6 7 8 9
9
10 1 2 3 11 21 55 6 8

Sample Output
4

Explanation

The roll numbers of students who only have English newspaper subscriptions are:

$4,5,7$ and $\mbox{9}$.

Hence, the total is $\begin{array}{c}4\end{array}$ students.

Source: hackerrank | Difficulty: EASY
Tags: Data structures


Solutions:
EN = input()
ES = set(input().split())
FN = input()
FS = set(input().split())
print(len(ES - FS))


(_, s, _) = (input(), set(input().split()), input())
print(len(s - set(input().split())))


a = int(input(''))
b = input('')
A = set(b.split())
c = int(input(''))
d = input('')
B = set(d.split())
C = A.difference(B)
print(len(C))


a = int(input())
aset = set(input().split())
b = int(input())
bset = set(input().split())
print(len(aset.difference(bset)))


input()
english_subscribers = set((n for n in input().split()))
input()
french_subscribers = set((n for n in input().split()))
print(len(english_subscribers.difference(french_subscribers)))


n = input()
setA = set(map(int, input().split()))
m = input()
setB = set(map(int, input().split()))
print(len(setA.difference(setB)))


input()
e = set(input().split())
input()
f = set(input().split())
print(len(e.difference(f)))


n = int(input().strip())
s1 = set(map(int, input().strip().split()))
m = int(input().strip())
s2 = set(map(int, input().strip().split()))
print(len(s1.difference(s2)))


E = int(input())
ES = set(map(int, input().split()))
F = int(input())
FS = set(map(int, input().split()))
print(len(ES - FS))


english_total = int(input())
english_newspaper = set(str(input()).split())
french_total = int(input())
french_newspaper = set(str(input()).split())
print(len(english_newspaper.difference(french_newspaper)))


input()
English = set(map(int, input().split()))
input()
French = set(map(int, input().split()))
print(len(English - French))


input()
a = set(input().split())
input()
b = set(input().split())
print(len(a.difference(b)))


input()
s1 = set(input().split())
input()
s2 = set(input().split())
print(len(s1.difference(s2)))


n1 = int(input())
s1 = set(map(int, input().split()))
n2 = int(input())
s2 = set(map(int, input().split()))
print(len(s1.difference(s2)))


en = int(input())
el = list(map(int, input().split()))
fn = int(input())
fl = list(map(int, input().split()))
print('%d' % len(set(el).difference(set(fl))))


an = int(input())
ast = set(map(int, input().split()))
bn = int(input())
bst = set(map(int, input().split()))
st = ast.difference(bst)
print(len(st))


m = input()
a = set(map(int, input().split()))
n = input()
b = set(map(int, input().split()))
print(len(a.difference(b)))


c1 = input()
english = set(map(int, input().split()))
c2 = input()
french = set(map(int, input().split()))
dif = english.difference(french)
print(len(dif))


a = int(input())
aa = {int(i) for i in input().split()}
b = int(input())
bb = {int(i) for i in input().split()}
print(len(aa.difference(bb)))


num_eng = int(input())
list_eng = set(map(int, input().split()))
num_fra = int(input())
list_fra = set(map(int, input().split()))
print(len(list_eng.difference(list_fra)))


n = int(input())
set_a = set(input().strip().split())
m = int(input())
set_b = set(input().strip().split())
print(len(set_a - set_b))


E = int(input())
e = set([int(x) for x in input().split()])
F = int(input())
f = set([int(x) for x in input().split()])
OnlyE = e.difference(f)
print(len(OnlyE))


N = int(input())
a = set(map(int, input().split(' ')))
M = int(input())
b = set(map(int, input().split(' ')))
print(len(a.difference(b)))


a = int(input())
ans = []
s = input()
s = s.split()
b = int(input())
s1 = input()
s1 = s1.split()
cnt = 0
for i in range(0, len(s)):
	flag = 0
	for j in range(0, len(s1)):
		if s[i] == s1[j]:
			flag = 1
			break
	if flag == 0:
		cnt += 1
print(cnt, end='')


n1 = int(input())
a = set(map(int, input().split()))
n2 = int(input())
b = set(map(int, input().split()))
print(len(a - b))


n = int(input())
s1 = set(input().split())
m = int(input())
s2 = set(input().split())
print(len(s1 - s2))


_ = input()
s1 = set(map(int, input().split()))
_ = input()
s2 = set(map(int, input().split()))
print(len(s1 - s2))


ne = int(input())
eng = set(map(int, input().split()))
nf = int(input())
fren = set(map(int, input().split()))
print(len(eng - fren))


N = int(input())
english = set(map(int, input().split(' ')[0:N]))
M = int(input())
french = set(map(int, input().split(' ')[0:M]))
print(len(english.difference(french)))


__author__ = 'namii'
input()
English = set(map(int, input().split()))
input()
French = set(map(int, input().split()))
print(len(English.difference(French)))


numen = int(input())
subs = set(map(int, input().split()[:numen]))
numfr = int(input())
subs = subs.difference(map(int, input().split()[:numfr]))
print(len(subs))


input()
s = set(map(int, input().split()))
input()
t = set(map(int, input().split()))
print(len(s.difference(t)))


k = input()
kset = set(map(int, input().split()))
l = input()
lset = set(map(int, input().split()))
print(len(kset.difference(lset)))


_ = input()
english = set(input().split())
_ = input()
french = set(input().split())
print(len(english - french))


n = input()
english = set(input().split())
n = input()
french = set(input().split())
print(len(english.difference(french)))


input()
s1 = set(map(int, input().split()))
input()
s2 = set(map(int, input().split()))
print(len(s1.difference(s2)))


n = int(input())
e = set(map(int, input().split(' ')))
l = int(input())
f = set(map(int, input().split(' ')))
x = e.difference(f)
print(len(x))


l1 = input()
l1 = set([int(i) for i in input().split(' ')])
l2 = input()
l2 = set([int(i) for i in input().split(' ')])
l1 = l1.difference(l2)
print(len(l1))


n = int(input())
s1 = set(map(int, input().split()))
m = int(input())
s2 = set(map(int, input().split()))
print(len(s1.difference(s2)))


import sys
n = int(input())
setA = set(map(int, sys.stdin.readline().split()))
m = int(input())
setB = set(map(int, sys.stdin.readline().split()))
total = len(setA.difference(setB))
print(total)


i = int(input())
s = set(input().split())
i2 = int(input())
s1 = set(input().split())
s2 = s - s1
print(len(s2))


input()
E = set(map(int, input().split()))
input()
F = set(map(int, input().split()))
print(len(E - F))


nA = int(input())
A = set(map(int, input().split()))
nB = int(input())
B = set(map(int, input().split()))
result = A - B
print(len(result))


m = int(input())
english = set(input().split())
n = int(input())
french = set(input().split())
print(len(english - french))


ne = int(input())
ern = input().split()
nf = int(input())
nfn = input().split()
ern = set(ern)
nfn = set(nfn)
both = ern.difference(nfn)
d = len(both)
print(d)


a = input()
eng = set(map(int, input().split()))
b = input()
fr = set(map(int, input().split()))
print(len(eng.difference(fr)))


n = int(input())
eng = set(list(map(int, input().split())))
m = int(input())
frn = set(list(map(int, input().split())))
print(len(eng - frn))


e = int(input())
es = set(map(int, input().split()))
f = int(input())
fs = set(map(int, input().split()))
ans = es.difference(es.intersection(fs))
print(len(ans))


n = input()
eng = set(input().split())
m = input()
fre = set(input().split())
print(len(eng - fre))


_ = input()
s = set(input().split())
_ = input()
t = set(input().split())
res = len(s.difference(s.intersection(t)))
print(res)


input()
s = set(input().split())
input()
print(len(s.difference(set(input().split()))))


eng = int(input())
engs = set(map(int, input().split()))
fre = int(input())
fres = set(map(int, input().split()))
print(len(engs - fres))


n = int(input())
s = set(map(int, input().split()))
m = int(input())
t = set(map(int, input().split()))
print(len(s - t))


english = int(input())
eng = input().split(' ')
eng = set(eng)
french = int(input())
frn = input().split(' ')
frn = set(frn)
difference = len(eng.difference(frn))
print(difference)


n = int(input())
s = set(input().split())
m = int(input())
p = set(input().split())
l = list(s.difference(p))
print(len(l))


input()
english = set(map(int, input().split()))
input()
french = set(map(int, input().split()))
print(len(english.difference(french)))


n = int(input())
students_n = set(map(int, input().split()))
m = int(input())
students_m = set(map(int, input().split()))
print(len(students_n.difference(students_m)))


input()
english = set([x for x in input().split()])
input()
french = set([x for x in input().split()])
print(len(english.difference(french)))


__author__ = 'bishal'
a = int(input())
b = set(map(int, input().split(' ')))
c = input()
d = set(map(int, input().split(' ')))
print(len(b - d))


e = int(input())
eng = set(map(int, input().split()))
f = int(input())
fre = set(map(int, input().split()))
print(len(eng - fre))


ne = int(input())
se = set(input().split())
nf = int(input())
sf = set(input().split())
se = se - sf
print(len(se))


input()
Eng = set(input().split())
input()
Fr = set(input().split())
print(len(Eng - Fr))


input()
s1 = set(input().split())
input()
print(len(s1.difference(set(input().split()))))


_ = input()
englishS = set(map(int, input().split()))
_ = input()
frenchS = set(map(int, input().split()))
out = englishS.difference(frenchS)
print(len(out))


input()
e = set(map(int, input().split()))
input()
f = set(map(int, input().split()))
print(len(e - f))


input()
st_one = set(input().split())
input()
st_two = set(input().split())
st_out = st_one.difference(st_two)
print(len(st_out))


input()
a = set(input().split())
input()
b = set(input().split())
print(len(a - b))


m = int(input())
n = set(input().split())
q = int(input())
w = set(input().split())
print(len(n - w))


eng_num = int(input())
eng_set = set(input().split())
fre_num = int(input())
fre_set = set(input().split())
print(len(eng_set - fre_set))


e = int(input())
english = set(input().split())
f = int(input())
french = set(input().split())
print(len(english - french))


a = input()
b = input().split()
c = set([int(i) for i in b])
d = input()
e = input().split()
f = set([int(i) for i in e])
print(len(c.difference(f)))


x1 = int(input())
x1v = set(map(int, input().split()))
x2 = int(input())
x2v = set(map(int, input().split()))
sindifference = x1v.difference(x2v)
print(len(sindifference))


input()
a = set(map(int, input().split()))
input()
b = set(map(int, input().split()))
print(len(a.difference(b)))


N = int(input())
english = set(input().split())
n2 = int(input())
french = set(input().split())
print(len(english.difference(french)))


input()
a = set(input().split(' '))
input()
b = set(input().split(' '))
print(len(a.difference(b)))


t = input()
s1 = set(map(int, input().split()))
t = input()
s2 = set(map(int, input().split()))
print(len(s1.difference(s2)))


input()
a = set(input().split())
input()
print(len(a - set(input().split())))


n = int(input())
E = set()
F = set()
for x in input().split(' '):
	if len(E) < n:
		E.add(int(x))
m = int(input())
for x in input().split(' '):
	if len(F) < m:
		F.add(int(x))
print(len(E - F))


size_a = int(input())
set_a = set(map(int, input().split()))
size_b = int(input())
set_b = set(map(int, input().split()))
difference = set_a.difference(set_b)
print(len(difference))


_ = input()
A = set(map(int, input().split()))
_ = input()
B = set(map(int, input().split()))
print(len(A - B))


_ = input()
e = set((int(x) for x in input().split(' ')))
_ = input()
f = set((int(x) for x in input().split(' ')))
print(len(e - f))


input()
s = set([int(x) for x in input().split()])
input()
t = set([int(x) for x in input().split()])
print(len(s - t))


numEng = int(input())
eng = list(map(int, input().split()))
numfran = int(input())
fra = list(map(int, input().split()))
eng = set(eng)
fra = set(fra)
total = eng.difference(fra)
print(len(total))


input()
french = set([int(x) for x in input().split()])
input()
english = set([int(x) for x in input().split()])
print(len(french.difference(english)))


input()
a = set([int(x) for x in input().split(' ')])
input()
b = set([int(x) for x in input().split(' ')])
print(len(a.difference(b)))


nEnglish = int(input())
english = set(map(int, input().split()))
nFrench = int(input())
french = set(map(int, input().split()))
print(len(english.difference(french)))


n1 = int(input())
A = set(input().split())
n2 = int(input())
B = set(input().split())
print(len(A.difference(B)))


nume = int(input())
english = set(map(int, input().split()))
numf = int(input())
french = set(map(int, input().split()))
print(len(english.difference(french)))


ints = lambda s: set(map(int, s.split()))
n1 = int(input())
s1 = ints(input())
n2 = int(input())
s2 = ints(input())
print(len(s1 - s2))


n = input()
en = set(input().split())
m = input()
fr = set(input().split())
print(len(en.difference(fr)))


e = int(input())
e_subs = set(map(int, input().split()))
f = int(input())
f_subs = set(map(int, input().split()))
print(len(e_subs.difference(f_subs)))


input()
a = set(map(int, input().split()))
input()
b = set(map(int, input().split()))
print(len(a - b))


e = int(input())
english = set(map(int, input().split()))
f = int(input())
french = set(map(int, input().split()))
print(len(english.difference(french)))


def __starting_point():
	n = int(input().strip())
	english = set(map(int, input().strip().split(' ')))
	m = int(input().strip())
	french = set(map(int, input().strip().split(' ')))
	print(len(english.difference(french)))
__starting_point()


input()
english = {int(x) for x in input().split()}
input()
french = {int(x) for x in input().split()}
print(len(english - french))


n = int(input())
eng = set(map(int, input().split()))
m = int(input())
fre = set(map(int, input().split()))
print(len(eng - fre))


input()
A = set(map(int, input().split()))
input()
B = set(map(int, input().split()))
print(len(A - B))


num1 = int(input())
setA = set(map(int, input().split()))
num2 = int(input())
setB = set(map(int, input().split()))
print(len(setA.difference(setB)))