#include<bits/stdc++.h>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int m;
  cin >> m;
  ll res = 0;
  ll sum = 0;
  rep(i,m){
    ll c,d;cin >> d >> c;
    sum += c*d;
    res += c;
  }
  res--;
  res += sum/9;
  if(sum%9 == 0)res--;
  cout << res << endl;
  
  
  


  return 0;
}

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

#define int long long

int n,tot,sum;

signed main(){
	read(n);
	for(int i=1,x,y;i<=n;i++){
		read(x,y);
		tot+=y;sum+=x*y;
	}
	write(tot-1+(sum-1)/9);
}