#include<stdio.h>
int main() {
	int a[5], wait, temp, max;
	for (int i=0;i<5;i++){
      scanf("%d", &a[i]);
    }
	max = 0;
	wait = 0;
	for (int i=0;i<5;i++){
		temp = a[i]%10;
		if (temp != 0){
          temp = 10-temp;
		if (max < temp){
          max = temp;
        }
		wait += a[i]+temp;
	}
	printf("%d", wait-max);
	return 0;
}