#include <bits/stdc++.h>
#define mp make_pair
#define eb emplace_back
#define fi first
#define se second
using namespace std;
using cd = complex <double>;

typedef pair <int, int> pii;
const int N = 3e3 + 5;
const long long INF = 1e18;
const int mod = 998244353;//786433;//998244353;
const double Pi = acos(-1);

 
void Fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

int n, m;
queue <pair <int, int> > BFS;
int Dist[1005][1005];
char a[1005][1005];
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			Dist[i][j] = 1000000;
			cin >> a[i][j];
			if(a[i][j] == '#')
			{
				Dist[i][j] = 0;
				BFS.push(mp(i, j));
			}
		}
	}
	while(BFS.empty() == false)
	{
		int x = BFS.front().fi, y = BFS.front().se;
		BFS.pop();
		for(int i = 0; i < 4; i++)
		{
			if(Dist[x + dx[i]][y + dy[i]] > Dist[x][y] + 1)
			{
				Dist[x + dx[i]][y + dy[i]] = Dist[x][y] + 1;
				BFS.push(mp(x + dx[i], y + dy[i]));
			}
		}
	}
	int t = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= m; j++)
		{
			t = max(t, Dist[i][j]);
		}
	}
	cout << t;
}
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

  int main(){
      lint n,g;
      cin>>n>>g;
      lint p[n];
      lint c[n];
      rep(i,n)cin>>p[i]>>c[i];
      lint ans=INF;
      rep(bit,1<<n){
          bool x[n];
          fill(x,x+n,false);
          rep(i,n)if(bit&(1<<i))x[i]=true;
          lint cost=0;
          lint comp=0;
          rep(i,n){
              if(x[i]){
                cost+=p[i]*(i+1)*100+c[i];
                comp+=p[i];
              }
          }
        for(lint i=n;i>=0;i--){
            if(x[i])continue;
            rep(j,p[i]){
                if(cost>=g)break;
                cost+=(i+1)*100;
                comp++;
            }
        }


          ans=min(ans,comp);
      }
      cout<<ans<<endl;
  }
      