#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int M;
  cin >> M;
  int ans = 0;
  int sum = 0;

  while (M--) {
    int c, d; cin >> d >> c;
    ans += c;
    sum += d*c;
  }

  ans -= 1;
  ans += (sum - 1)/9;

  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll M;
deque<ll> d;
deque<ll> c;
deque<ll> e;

int main(){
    cin >> M;
    for(int i=0;i<M;i++){
        ll a,b;
        cin >> a >> b;
        d.push_back(a);
        c.push_back(b);
    }
    ll count = 0;
    while(d.size() > 0){
        if(c[0] == 1){
            e.push_back(d[0]);
            c.pop_front();
            d.pop_front();
            continue;
        }
        ll dd = d[0];
        ll cc = c[0];
        c.pop_front();
        d.pop_front();
        if(dd < 5){
            if(cc % 2 == 1){
                c.push_front(1);
                d.push_front(dd);
            }
            c.push_front(cc/2);
            d.push_front(dd*2);
            count += cc/2;
            continue;            
        }
        if(cc % 2 == 1){
            c.push_front(1);
            d.push_front(dd);
        }
        dd = (dd*2)/10 + (dd*2)%10;
        c.push_front(cc/2);
        d.push_front(dd);
        count += cc/2 * 2;
    }
    while(e.size() > 1){
        ll a = e[0];
        ll b = e[1];
        e.pop_front();
        e.pop_front();
        if(a+b < 10){
            count++;
            e.push_front(a+b);
        }else{
            count += 2;
            e.push_front((a+b)/10 + (a+b)%10);
        }
    }
    cout << count << endl;
    return 0;
}