n = 5;
a = [int(input()) for i in range(n)];
last = 9;
time = 0;

for i in a:
	if last % 10  > i % 10 > 1:
		time += last  // 10 * 10 + 10;
		last = i;

	elif i % 10 == 0:
		time += i;

 	else:
		time += i  // 10 * 10 + 10;
	
print(time + last - 10);