#include <bits/stdc++.h>
using namespace std;
void IOS() {}
int n, k;
int fr[102];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  IOS();
  cin >> n >> k;
  int sol = 0;
  for (int i = 1; i <= n; ++i) {
    int nr;
    cin >> nr;
    fr[nr]++;
  }
  while (k > 0) {
    bool modd = 0;
    for (int i = 9; i >= 0; --i) {
      int st = 90 + i;
      for (int j = st; j >= 0; j -= 10) {
        if (fr[j] && k >= (10 - i) * fr[j]) {
          k -= (10 - i) * fr[j];
          fr[j + (10 - i)] += fr[j];
          fr[j] = 0;
          modd = 1;
        } else if (fr[j]) {
          int val = k / (10 - i);
          if (val > 0) modd = 1;
          fr[j + (10 - i)] += val;
          fr[j] -= val;
          k -= val * (10 - i);
        }
      }
    }
    if (!modd) break;
  }
  for (int i = 0; i <= 100; ++i) {
    sol = sol + fr[i] * (i / 10);
  }
  cout << sol;
  return 0;
}
