import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int dish = 0;
    	int dish_min = 0;
    	int dish_nokori= 0;
    	int sum = 0;

    	for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	}

		if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		}

    	// 出力
    	System.out.println(sum);
    }
} import java.util.Scanner; Scanner java.util public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int dish = 0;
    	int dish_min = 0;
    	int dish_nokori= 0;
    	int sum = 0;

    	for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	}

		if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		}

    	// 出力
    	System.out.println(sum);
    }
} Main public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int dish = 0;
    	int dish_min = 0;
    	int dish_nokori= 0;
    	int sum = 0;

    	for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	}

		if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		}

    	// 出力
    	System.out.println(sum);
    } main {
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int dish = 0;
    	int dish_min = 0;
    	int dish_nokori= 0;
    	int sum = 0;

    	for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	}

		if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		}

    	// 出力
    	System.out.println(sum);
    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int dish = 0; dish 0 int dish_min = 0; dish_min 0 int dish_nokori= 0; dish_nokori 0 int sum = 0; sum 0 for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	} int i=0; int i=0; i 0 i< 5 i 5 i++ i++ i {
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	} {
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	} dish = sc.nextInt() dish sc.nextInt() sc.nextInt sc sum += dish sum dish dish_nokori = 0 dish_nokori 0 if(dish / 100 != 0){
    			dish = dish % 100;
    		} dish / 100 != 0 dish / 100 dish 100 0 {
    			dish = dish % 100;
    		} dish = dish % 100 dish dish % 100 dish 100 if(dish / 10 != 0){
    			dish = dish % 10;
    		} dish / 10 != 0 dish / 10 dish 10 0 {
    			dish = dish % 10;
    		} dish = dish % 10 dish dish % 10 dish 10 if (dish != 0){
    			dish_nokori = 10 - dish;
    		} dish != 0 dish 0 {
    			dish_nokori = 10 - dish;
    		} dish_nokori = 10 - dish dish_nokori 10 - dish 10 dish if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		} i == 0 && dish != 0 i == 0 i 0 dish != 0 dish 0 {
    			dish_min = dish;
    		} dish_min = dish dish_min dish if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		} dish < dish_min && dish != 0 dish < dish_min dish dish_min dish != 0 dish 0 {
    			dish_min = dish;
    		} dish_min = dish dish_min dish sum += dish_nokori sum dish_nokori if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		} dish_min != 0 dish_min 0 {
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		} dish_nokori = 10 - dish_min dish_nokori 10 - dish_min 10 dish_min sum -= dish_nokori sum dish_nokori System.out.println(sum) System.out.println System.out System System.out sum String[] args args public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int dish = 0;
    	int dish_min = 0;
    	int dish_nokori= 0;
    	int sum = 0;

    	for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	}

		if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		}

    	// 出力
    	System.out.println(sum);
    }
} public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int dish = 0;
    	int dish_min = 0;
    	int dish_nokori= 0;
    	int sum = 0;

    	for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	}

		if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		}

    	// 出力
    	System.out.println(sum);
    }
} Main
import java.util.Scanner;
public class Main {

    public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
    	// 入力
    	int dish = 0;
    	int dish_min = 0;
    	int dish_nokori= 0;
    	int sum = 0;

    	for(int i=0; i< 5; i++){
    		dish = sc.nextInt();
    		sum += dish;
    		dish_nokori = 0;

    		if(dish / 100 != 0){
    			dish = dish % 100;
    		}

    		if(dish / 10 != 0){
    			dish = dish % 10;
    		}

    		if (dish != 0){
    			dish_nokori = 10 - dish;
    		}


    		if(i == 0 && dish != 0){
    			dish_min = dish;
    		} else if (dish < dish_min && dish != 0){
    			dish_min = dish;
    		}

    		sum += dish_nokori;

    	}

		if (dish_min != 0){
			dish_nokori = 10 - dish_min;
	    	sum -= dish_nokori;
		}

    	// 出力
    	System.out.println(sum);
    }
}