// Problem: A - Rock-paper-scissors
// Contest: AtCoder - AtCoder Beginner Contest 204
// URL: https://atcoder.jp/contests/abc204/tasks/abc204_a
// Memory Limit: 1024 MB
// Time Limit: 2000 ms

//code by: Ravi Khatri 
#include<bits/stdc++.h>
#define ll long long
#define vi vector<int>
#define vll vector<ll>
#define F first
#define S second
#define pb push_back
#define f(i,s,n) for(int i=(int)s;i<=(int)n;++i)
#define fr(i,n,s) for(int i=(int)n;i>=s;--i)
#define all(v) v.begin(),v.end()
#define sz(v) (int)v.size()
#define Fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
#define mod 1000000007

void solve()
{
	int n;cin>>n;
	int ans=0;
	f(i,1,n){
		int x;cin>>x;
		if(x>10){
			ans+=x-10;
		}
	}
	cout<<ans<<"\n";
}
int main()
{	Fast;
	// int t;cin>>t;
	// while(t--)
	solve();
}
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=(int)(x);i<(int)(y);i++)
#define print(A,x,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i]x;}cout<<endl;
#define pprint(A,y,m,n) rep(j,0,m){print(A[j],y,n);}
const long mod=1e9+7;
const int siz=3e5;
const int inf=1e9;
int main(){
	int N,M; cin>>N>>M;
	int x,y;
	pair<int,int> vp[M+1]; vp[0] = {0, N};
	map<pair<int,int>,bool> mp; mp[vp[0]] = true;
	map<int,vector<int>> record; record[N].push_back(0);
	rep(i,0,M){
		cin>>x>>y;
		vp[i+1] = {x, y};
		record[y].push_back(x);
	}
	sort(vp,vp+M+1);
	for(auto it = record.begin(); it != record.end(); it++){
		sort((it->second).begin(), (it->second).end());
      	//print((it->second),,(it->second).size());
	}
	rep(i,1,M+1){
		pair<int,int> p = vp[i];
		mp[p] = false;
		if(p.second > 0 && !record[p.second-1].empty()){
			auto it = lower_bound(record[p.second-1].begin(), record[p.second-1].end(), p.first);
			if(it != record[p.second-1].begin()){
				mp[p] |= mp[{*(it-1), p.second-1}];
			}
		}
		if(p.second < 2*N && !record[p.second+1].empty()){
			auto it = lower_bound(record[p.second+1].begin(), record[p.second+1].end(), p.first);
			if(it != record[p.second+1].begin()){
				mp[p] |= mp[{*(it-1), p.second+1}];
			}
		}//cout<<p.first<<" "<<p.second<<" "<<mp[p]<<endl;
	}
	int ans = 0;
	for(pair<int,vector<int>> pv:record){
      	if(!pv.second.empty()) ans += mp[{pv.second.back(), pv.first}];
	}
	cout<<ans<<endl;
}