import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int a_10 = (10-a%10)%10;
		int b_10 = (10-b%10)%10;
		int c_10 = (10-c%10)%10;
		int d_10 = (10-d%10)%10;
		int e_10 = (10-e%10)%10;
		int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10;
		int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10;
		int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10;
		int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10;
		int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e;
		int answer = count_a;
		if(answer>count_b)
			answer=count_b;
		if(answer>count_c)
			answer=count_c;
		if(answer>count_d)
			answer=count_d;
		if(answer>count_e)
			answer=count_e;
		System.out.println(answer);

	}
}
 import java.util.Scanner; Scanner java.util public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int a_10 = (10-a%10)%10;
		int b_10 = (10-b%10)%10;
		int c_10 = (10-c%10)%10;
		int d_10 = (10-d%10)%10;
		int e_10 = (10-e%10)%10;
		int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10;
		int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10;
		int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10;
		int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10;
		int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e;
		int answer = count_a;
		if(answer>count_b)
			answer=count_b;
		if(answer>count_c)
			answer=count_c;
		if(answer>count_d)
			answer=count_d;
		if(answer>count_e)
			answer=count_e;
		System.out.println(answer);

	}
} Main public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int a_10 = (10-a%10)%10;
		int b_10 = (10-b%10)%10;
		int c_10 = (10-c%10)%10;
		int d_10 = (10-d%10)%10;
		int e_10 = (10-e%10)%10;
		int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10;
		int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10;
		int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10;
		int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10;
		int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e;
		int answer = count_a;
		if(answer>count_b)
			answer=count_b;
		if(answer>count_c)
			answer=count_c;
		if(answer>count_d)
			answer=count_d;
		if(answer>count_e)
			answer=count_e;
		System.out.println(answer);

	} main {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int a_10 = (10-a%10)%10;
		int b_10 = (10-b%10)%10;
		int c_10 = (10-c%10)%10;
		int d_10 = (10-d%10)%10;
		int e_10 = (10-e%10)%10;
		int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10;
		int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10;
		int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10;
		int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10;
		int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e;
		int answer = count_a;
		if(answer>count_b)
			answer=count_b;
		if(answer>count_c)
			answer=count_c;
		if(answer>count_d)
			answer=count_d;
		if(answer>count_e)
			answer=count_e;
		System.out.println(answer);

	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a = sc.nextInt(); a sc.nextInt() sc.nextInt sc int b = sc.nextInt(); b sc.nextInt() sc.nextInt sc int c = sc.nextInt(); c sc.nextInt() sc.nextInt sc int d = sc.nextInt(); d sc.nextInt() sc.nextInt sc int e = sc.nextInt(); e sc.nextInt() sc.nextInt sc int a_10 = (10-a%10)%10; a_10 (10-a%10)%10 (10-a%10) 10 a%10 a 10 10 int b_10 = (10-b%10)%10; b_10 (10-b%10)%10 (10-b%10) 10 b%10 b 10 10 int c_10 = (10-c%10)%10; c_10 (10-c%10)%10 (10-c%10) 10 c%10 c 10 10 int d_10 = (10-d%10)%10; d_10 (10-d%10)%10 (10-d%10) 10 d%10 d 10 10 int e_10 = (10-e%10)%10; e_10 (10-e%10)%10 (10-e%10) 10 e%10 e 10 10 int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10; count_a a+b+b_10+c+c_10+d+d_10+e+e_10 e d_10 d c_10 c b_10 a+b+b_10+c+c_10+d+d_10+e+e_10 a b b_10 c c_10 d d_10 e e_10 int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10; count_b a+a_10+b+c+c_10+d+d_10+e+e_10 e d_10 d c_10 c b a+a_10+b+c+c_10+d+d_10+e+e_10 a a_10 b c c_10 d d_10 e e_10 int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10; count_c a+a_10+b+b_10+c+d+d_10+e+e_10 e d_10 d c b_10 b a+a_10+b+b_10+c+d+d_10+e+e_10 a a_10 b b_10 c d d_10 e e_10 int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10; count_d a+a_10+b+b_10+c+c_10+d+e+e_10 e d c_10 c b_10 b a+a_10+b+b_10+c+c_10+d+e+e_10 a a_10 b b_10 c c_10 d e e_10 int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e; count_e a+a_10+b+b_10+c+c_10+d+d_10+e d_10 d c_10 c b_10 b a+a_10+b+b_10+c+c_10+d+d_10+e a a_10 b b_10 c c_10 d d_10 e int answer = count_a; answer count_a if(answer>count_b)
			answer=count_b; answer>count_b answer count_b answer=count_b answer count_b if(answer>count_c)
			answer=count_c; answer>count_c answer count_c answer=count_c answer count_c if(answer>count_d)
			answer=count_d; answer>count_d answer count_d answer=count_d answer count_d if(answer>count_e)
			answer=count_e; answer>count_e answer count_e answer=count_e answer count_e System.out.println(answer) System.out.println System.out System System.out answer String[] args args public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int a_10 = (10-a%10)%10;
		int b_10 = (10-b%10)%10;
		int c_10 = (10-c%10)%10;
		int d_10 = (10-d%10)%10;
		int e_10 = (10-e%10)%10;
		int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10;
		int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10;
		int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10;
		int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10;
		int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e;
		int answer = count_a;
		if(answer>count_b)
			answer=count_b;
		if(answer>count_c)
			answer=count_c;
		if(answer>count_d)
			answer=count_d;
		if(answer>count_e)
			answer=count_e;
		System.out.println(answer);

	}
} public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int a_10 = (10-a%10)%10;
		int b_10 = (10-b%10)%10;
		int c_10 = (10-c%10)%10;
		int d_10 = (10-d%10)%10;
		int e_10 = (10-e%10)%10;
		int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10;
		int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10;
		int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10;
		int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10;
		int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e;
		int answer = count_a;
		if(answer>count_b)
			answer=count_b;
		if(answer>count_c)
			answer=count_c;
		if(answer>count_d)
			answer=count_d;
		if(answer>count_e)
			answer=count_e;
		System.out.println(answer);

	}
} Main
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//List<String> list= new ArrayList<String>(Arrays.asList(s.split("")));
		//List<Integer> list=new ArrayList<Integer>();
		//Integer[] Republican = new Integer[m];
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int a_10 = (10-a%10)%10;
		int b_10 = (10-b%10)%10;
		int c_10 = (10-c%10)%10;
		int d_10 = (10-d%10)%10;
		int e_10 = (10-e%10)%10;
		int count_a=a+b+b_10+c+c_10+d+d_10+e+e_10;
		int count_b=a+a_10+b+c+c_10+d+d_10+e+e_10;
		int count_c=a+a_10+b+b_10+c+d+d_10+e+e_10;
		int count_d=a+a_10+b+b_10+c+c_10+d+e+e_10;
		int count_e=a+a_10+b+b_10+c+c_10+d+d_10+e;
		int answer = count_a;
		if(answer>count_b)
			answer=count_b;
		if(answer>count_c)
			answer=count_c;
		if(answer>count_d)
			answer=count_d;
		if(answer>count_e)
			answer=count_e;
		System.out.println(answer);

	}
}

