#include<bits/stdc++.h>
using namespace std;
inline long long read(){
	long long x=0,f=1;char ch=getchar();
	while ((!isdigit(ch))&&(ch!='-')) ch=getchar();
	if (ch=='-') f=-1,ch=getchar();
	while (isdigit(ch)) x=(x<<1)+(x<<3)+ch-'0',ch=getchar();
	return x*f;
}
long long n,i,sum,opt,cas;
int main(){
	freopen("meow2.ans","r",stdin);
	n=read();
	for (i=1;i<=n;i++){
		opt=read();cas=read();
		if ((opt==1)) sum++;
		else {
			printf("%lld\n",sum);
			return 0;
		}
	}
	return 0;
}
