Problem:
Score : 300 points

Problem Statement

You are playing the following game with Joisino.

Initially, you have a blank sheet of paper.

Joisino announces a number. If that number is written on the sheet, erase the number from the sheet; if not, write the number on the sheet. This process is repeated N times.

Then, you are asked a question: How many numbers are written on the sheet now?

The numbers announced by Joisino are given as A_1, ... ,A_N in the order she announces them. How many numbers will be written on the sheet at the end of the game?

Constraints

1≤N≤100000

1≤A_i≤1000000000(=10^9)

All input values are integers.

Input

Input is given from Standard Input in the following format:

N
A_1
:
A_N

Output

Print how many numbers will be written on the sheet at the end of the game.

Sample Input 1

3
6
2
6

Sample Output 1

1

The game proceeds as follows:

6 is not written on the sheet, so write 6.

2 is not written on the sheet, so write 2.

6 is written on the sheet, so erase 6.

Thus, the sheet contains only 2 in the end. The answer is 1.

Sample Input 2

4
2
5
5
2

Sample Output 2

0

It is possible that no number is written on the sheet in the end.

Sample Input 3

6
12
22
16
22
18
12

Sample Output 3

2

Solution in C (GCC 5.4.1) (judge verdict: Memory Limit Exceeded)

#include <stdio.h>
#include <stdlib.h>
#define datatype int

typedef enum {
	false,
	true
}Boolean;

typedef struct node_sub node;

typedef struct {
	datatype (*update_function)(node *r, datatype arg);
	datatype arg;
}lazy_function;

struct node_sub{
	int N;
	datatype val;
	Boolean is_lazy;
	lazy_function lazy;
	struct node_sub *left;
	struct node_sub *right;
};

typedef struct {
	node *root;
	datatype e;
	datatype (*f)(datatype x, datatype y);
	lazy_function ilf; //idantity lazy function
}segment_tree;

segment_tree *make_segment_tree(datatype e, datatype (*f)(datatype x, datatype y), lazy_function ilf){
	segment_tree *t = (segment_tree *)malloc(sizeof(segment_tree));
	t->root = NULL;
	t->e = e;
	t->f = f;
	t->ilf = ilf;
	return t;
}

datatype sum(datatype a, datatype b){
	return a + b;
}

//代入
datatype substitute(node *r, datatype arg){
	return arg * r->N;
}

//値を足す
datatype add(node *r, datatype arg){
	return r->val + arg * r->N;
}

lazy_function combine_lazy_function(lazy_function a, lazy_function b){
	lazy_function ans;
	if(a.update_function == &substitute){
		ans.update_function = &substitute;
		ans.arg = a.arg;
	}
	else if(a.update_function == &add && b.update_function == &substitute){
		ans.update_function = &substitute;
		ans.arg = a.arg + b.arg;
	}
	else if(a.update_function == &add && b.update_function == &add){
		ans.update_function = &add;
		ans.arg = a.arg + b.arg;
	}
	return ans;
}

node *make_node(int N, segment_tree *t){
	node *r = (node *)malloc(sizeof(node));
	r->N = N;
	r->val = t->e;
	r->is_lazy = false;
	r->lazy = t->ilf;
	r->left = NULL;
	r->right = NULL;
	return r;
}

void out_node(node *r){
	printf("N = %d\n", r->N);
	printf("val = %d\n", r->val);
	if(r->is_lazy == true){
		printf("is_lazy\n");
	}
	else{
		printf("is_not_lazy\n");
	}
	if((r->lazy).update_function == &substitute){
		printf("substitute(%d)\n", (r->lazy).arg);
	}
	if((r->lazy).update_function == &add){
		printf("add(%d)\n", (r->lazy).arg);
	}
	if(r->left == NULL && r->right == NULL){
		printf("no_children\n");
	}
	else{
		printf("have_children\n");
	}
}

//伝播
void propagate(node *r, segment_tree *t){
	if(r->N > 1){
		if(r->left == NULL && r->right == NULL){
			r->left = make_node(r->N / 2, t);
			r->right = make_node(r->N / 2, t);
		}
		if(r->is_lazy == true){
			r->left->is_lazy = true;
			r->left->lazy = combine_lazy_function(r->lazy, r->left->lazy);
			r->right->is_lazy = true;
			r->right->lazy = combine_lazy_function(r->lazy, r->right->lazy);
		}
	}
	if(r->is_lazy == true){
		r->val = ((r->lazy).update_function)(r, (r->lazy).arg);
		r->is_lazy = false;
		r->lazy = t->ilf;
	}
}

//nを越える最小の2冪を返す
int next_exponent_of_2(int n){
	n |= (n >> 1);
	n |= (n >> 2);
	n |= (n >> 4);
	n |= (n >> 8);
	n |= (n >> 16);
//	n |= (n >> 32);
	return (n << 1) ^ n - 1;
}

void update_sub(int a, int b, lazy_function lazy, node *r, segment_tree *t){
	propagate(r, t);
	if(r->N <= a || b <= 0){
		return;
	}
	else if(a <= 0 && r->N <= b){
		r->is_lazy = true;
		r->lazy = lazy;
		propagate(r, t);
	}
	else{
		update_sub(a, b, lazy, r->left, t);
		update_sub(a - r->N / 2, b - r->N / 2, lazy, r->right, t);
		r->val = (t->f)(r->left->val, r->right->val);
	}
}

void update(int a, int b, lazy_function lazy, segment_tree *t){
	if(t->root == NULL){
		t->root = make_node(next_exponent_of_2(b - 1), t);
	}
	else if(t->root->N < b){
		node *r = make_node(2 * t->root->N, t);
		r->val = t->root->val;
		r->left = t->root;
		r->right = make_node(r->left->N, t);
		t->root = r;
		update(a, b, lazy, t);
		return;
	}
	update_sub(a, b, lazy, t->root, t);
}

datatype query_sub(int a, int b, node *r, segment_tree *t){
	propagate(r, t);
	if(r->N <= a || b <= 0){
		return t->e;
	}
	else if(a <= 0 && r->N <= b){
		return r->val;
	}
	else{
		return (t->f)(query_sub(a, b, r->left, t), query_sub(a - r->N / 2, b - r->N / 2, r->right, t));
	}
}

datatype query(int a, int b, segment_tree *t){
	if(t->root == NULL){
		return t->e;
	}
	else{
		return query_sub(a, b, t->root, t);
	}
}

int main(){
	int N, A, i;
	scanf("%d", &N);
	lazy_function ilf, lazy;
	ilf.update_function = &add;
	ilf.arg = 0;
	segment_tree *t = make_segment_tree(0, &sum, ilf);
	for(i = 0; i < N; i++){
		scanf("%d", &A);
		lazy.update_function = &substitute;
		if(query(A, A + 1, t) == 0){
			lazy.arg = 1;
		}
		else{
			lazy.arg = 0;
		}
		update(A, A + 1, lazy, t);
	}
	printf("%d\n", query(0, 1000000007, t));
	return 0;
}