.symmetric_difference()
  
The .symmetric_difference() operator returns a set with all the elements that are in the set and the iterable but not both.

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

The set is immutable to the .symmetric_difference() operation (or ^ operation).

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

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

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

>>> print s.symmetric_difference(enumerate(['R', 'a', 'n', 'k']))
set(['a', 'c', 'e', 'H', (0, 'R'), 'r', (2, 'n'), 'k', (1, 'a'), (3, 'k')])

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

>>> s ^ set("Rank")
set(['c', 'e', 'H', 'n', 'R', 'r'])

Task
  
Students of District College have subscriptions to English and French newspapers. Some students have subscribed to English only, some have subscribed to French only, 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 either the English or the French newspaper but not both.

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 total number of students who have subscriptions to the English or the French newspaper but not both.

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

Sample Output
8

Explanation

The roll numbers of students who have subscriptions to English or French newspapers but not both are:

$4,5,7,9,10,11,21$ and $55$.

Hence, the total is $8$ students.

Source: hackerrank | Difficulty: EASY
Tags: Data structures


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


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


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


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


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


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


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


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


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


_ = input()
s = set(input().split())
_ = input()
t = set(input().split())
resA = s.union(t).difference(s.intersection(t))
resB = s.symmetric_difference(t)
if resA == resB:
	print(len(resA))


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


n1 = int(input())
s1 = set(input().split())
n2 = int(input())
s2 = set(input().split())
print(len(s1.union(s2)) - len(s1.intersection(s2)))


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


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


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


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


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


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


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


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.symmetric_difference(fra)
print(len(total))


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


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


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


input()
e = set(input().split())
input()
f = set(input().split())
print(len(e.symmetric_difference(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))


E = int(input())
English = set(input().split())
F = int(input())
French = set(input().split())
print(len(English ^ French))


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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.symmetric_difference(bb)))


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


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


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.symmetric_difference(s2)))


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


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


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


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


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


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


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


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


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


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


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


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


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


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


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.symmetric_difference(french)))


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


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


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


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


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


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.symmetric_difference(setB))
print(total)


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


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


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


def read_int():
	return int(input())

def read_int_words():
	return map(int, input().split())
_ = input()
englishS = set(read_int_words())
_ = input()
frenchS = set(read_int_words())
out = englishS.symmetric_difference(frenchS)
print(len(out))


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


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


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


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


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


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


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))


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


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


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


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.symmetric_difference(french)))
__starting_point()


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


input()
a = {int(i) for i in input().split()}
input()
b = {int(i) for i in input().split()}
c = a ^ b
print(len(c))


EN = input()
ES = set(input().split())
FN = input()
FS = set(input().split())
print(len(ES ^ FS))


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


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


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


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


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


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


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


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


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


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


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.symmetric_difference(list_fra)))


import difflib
a = int(input())
ans = []
ans1 = []
s = input()
s = s.split()
b = int(input())
s1 = input()
s1 = s1.split()
ans = set(s) - set(s1)
ans1 = set(s1) - set(s)
print(len(ans) + len(ans1), end='')