import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static boolean ta[];

	public static int solve(int a[], int cur) {
		int ans = 130 * 5 + 1, tmp = 0, tmpa = 0;
		if (cur == 5)
			return 0;
		for (int i = 0; i < a.length; ++i) {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		ta = new boolean[5];
		for (int i = 0; i < 5; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans = 0;
		ans = solve(a, 0);
		System.out.println(ans);
	}

} import java.util.Arrays; Arrays java.util import java.util.Scanner; Scanner java.util public class Main {

	static boolean ta[];

	public static int solve(int a[], int cur) {
		int ans = 130 * 5 + 1, tmp = 0, tmpa = 0;
		if (cur == 5)
			return 0;
		for (int i = 0; i < a.length; ++i) {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		ta = new boolean[5];
		for (int i = 0; i < 5; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans = 0;
		ans = solve(a, 0);
		System.out.println(ans);
	}

} Main static boolean ta[]; ta public static int solve(int a[], int cur) {
		int ans = 130 * 5 + 1, tmp = 0, tmpa = 0;
		if (cur == 5)
			return 0;
		for (int i = 0; i < a.length; ++i) {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		}
		return ans;
	} solve {
		int ans = 130 * 5 + 1, tmp = 0, tmpa = 0;
		if (cur == 5)
			return 0;
		for (int i = 0; i < a.length; ++i) {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		}
		return ans;
	} int ans = 130 * 5 + 1 ans 130 * 5 + 1 130 * 5 130 5 1 tmp = 0 tmp 0 tmpa = 0; tmpa 0 if (cur == 5)
			return 0; cur == 5 cur 5 return 0; 0 for (int i = 0; i < a.length; ++i) {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		} int i = 0; int i = 0; i 0 i < a.length i a.length a a.length ++i ++i i {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		} {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		} if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			} !ta[i] ta[i] ta i {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			} ta[i] = true ta[i] ta i true tmpa = a[i] tmpa a[i] a i if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10); a[i] % 10 != 0 && cur < 4 a[i] % 10 != 0 a[i] % 10 a[i] a i 10 0 cur < 4 cur 4 tmpa += (10 - a[i] % 10) tmpa (10 - a[i] % 10) 10 a[i] % 10 a[i] a i 10 tmp = tmpa + solve(a, cur + 1) tmp tmpa + solve(a, cur + 1) tmpa solve(a, cur + 1) solve a cur + 1 cur 1 ans = Math.min(ans, tmp) ans Math.min(ans, tmp) Math.min Math ans tmp ta[i] = false ta[i] ta i false return ans; ans int a[] a int cur cur public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		ta = new boolean[5];
		for (int i = 0; i < 5; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans = 0;
		ans = solve(a, 0);
		System.out.println(ans);
	} main {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		ta = new boolean[5];
		for (int i = 0; i < 5; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans = 0;
		ans = solve(a, 0);
		System.out.println(ans);
	} Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int a[] = new int[5]; a new int[5] 5 ta = new boolean[5] ta new boolean[5] 5 for (int i = 0; i < 5; ++i)
			a[i] = sc.nextInt(); int i = 0; int i = 0; i 0 i < 5 i 5 ++i ++i i a[i] = sc.nextInt(); a[i] = sc.nextInt() a[i] a i sc.nextInt() sc.nextInt sc sc.close() sc.close sc int ans = 0; ans 0 ans = solve(a, 0) ans solve(a, 0) solve a 0 System.out.println(ans) System.out.println System.out System System.out ans String[] args args public class Main {

	static boolean ta[];

	public static int solve(int a[], int cur) {
		int ans = 130 * 5 + 1, tmp = 0, tmpa = 0;
		if (cur == 5)
			return 0;
		for (int i = 0; i < a.length; ++i) {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		ta = new boolean[5];
		for (int i = 0; i < 5; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans = 0;
		ans = solve(a, 0);
		System.out.println(ans);
	}

} public class Main {

	static boolean ta[];

	public static int solve(int a[], int cur) {
		int ans = 130 * 5 + 1, tmp = 0, tmpa = 0;
		if (cur == 5)
			return 0;
		for (int i = 0; i < a.length; ++i) {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		ta = new boolean[5];
		for (int i = 0; i < 5; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans = 0;
		ans = solve(a, 0);
		System.out.println(ans);
	}

} Main
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static boolean ta[];

	public static int solve(int a[], int cur) {
		int ans = 130 * 5 + 1, tmp = 0, tmpa = 0;
		if (cur == 5)
			return 0;
		for (int i = 0; i < a.length; ++i) {
			if (!ta[i]) {
				ta[i] = true;
				tmpa = a[i];
				if(a[i] % 10 != 0 && cur < 4)
					tmpa += (10 - a[i] % 10);
				tmp = tmpa + solve(a, cur + 1);
				ans = Math.min(ans, tmp);
				ta[i] = false;
			}

		}
		return ans;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[5];
		ta = new boolean[5];
		for (int i = 0; i < 5; ++i)
			a[i] = sc.nextInt();
		sc.close();
		int ans = 0;
		ans = solve(a, 0);
		System.out.println(ans);
	}

}
