import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);

         //A,B,C格納用配列
         int[] numList = new int[3];

         //入力値を配列に格納
         for (int i = 0; i < numList.length; i++) {
             numList[i] = sc.nextInt();
         }
         //取り出すカードの枚数: K
         int K = sc.nextInt();
         sc.close();

         //取り出したカードの総和
         int count = 0;
         //カードの数
         int cardNum = 1;

         for (int num : numList) {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         }
         System.out.println(count);

    }

} import java.util.Scanner; Scanner java.util public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);

         //A,B,C格納用配列
         int[] numList = new int[3];

         //入力値を配列に格納
         for (int i = 0; i < numList.length; i++) {
             numList[i] = sc.nextInt();
         }
         //取り出すカードの枚数: K
         int K = sc.nextInt();
         sc.close();

         //取り出したカードの総和
         int count = 0;
         //カードの数
         int cardNum = 1;

         for (int num : numList) {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         }
         System.out.println(count);

    }

} Main public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);

         //A,B,C格納用配列
         int[] numList = new int[3];

         //入力値を配列に格納
         for (int i = 0; i < numList.length; i++) {
             numList[i] = sc.nextInt();
         }
         //取り出すカードの枚数: K
         int K = sc.nextInt();
         sc.close();

         //取り出したカードの総和
         int count = 0;
         //カードの数
         int cardNum = 1;

         for (int num : numList) {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         }
         System.out.println(count);

    } main {
         Scanner sc = new Scanner(System.in);

         //A,B,C格納用配列
         int[] numList = new int[3];

         //入力値を配列に格納
         for (int i = 0; i < numList.length; i++) {
             numList[i] = sc.nextInt();
         }
         //取り出すカードの枚数: K
         int K = sc.nextInt();
         sc.close();

         //取り出したカードの総和
         int count = 0;
         //カードの数
         int cardNum = 1;

         for (int num : numList) {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         }
         System.out.println(count);

    } Scanner sc = new Scanner(System.in); sc new Scanner(System.in) int[] numList = new int[3]; numList new int[3] 3 for (int i = 0; i < numList.length; i++) {
             numList[i] = sc.nextInt();
         } int i = 0; int i = 0; i 0 i < numList.length i numList.length numList numList.length i++ i++ i {
             numList[i] = sc.nextInt();
         } {
             numList[i] = sc.nextInt();
         } numList[i] = sc.nextInt() numList[i] numList i sc.nextInt() sc.nextInt sc int K = sc.nextInt(); K sc.nextInt() sc.nextInt sc sc.close() sc.close sc int count = 0; count 0 int cardNum = 1; cardNum 1 for (int num : numList) {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         } int num numList {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         } {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         } if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             } num > 0 num 0 {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             } if (num > K) {
                     num = K;
                 } num > K num K {
                     num = K;
                 } num = K num K count += (cardNum * num) count (cardNum * num) cardNum num K -= num K num if (K == 0) {
                     break;
                 } K == 0 K 0 {
                     break;
                 } break; cardNum-- cardNum System.out.println(count) System.out.println System.out System System.out count String[] args args public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);

         //A,B,C格納用配列
         int[] numList = new int[3];

         //入力値を配列に格納
         for (int i = 0; i < numList.length; i++) {
             numList[i] = sc.nextInt();
         }
         //取り出すカードの枚数: K
         int K = sc.nextInt();
         sc.close();

         //取り出したカードの総和
         int count = 0;
         //カードの数
         int cardNum = 1;

         for (int num : numList) {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         }
         System.out.println(count);

    }

} public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);

         //A,B,C格納用配列
         int[] numList = new int[3];

         //入力値を配列に格納
         for (int i = 0; i < numList.length; i++) {
             numList[i] = sc.nextInt();
         }
         //取り出すカードの枚数: K
         int K = sc.nextInt();
         sc.close();

         //取り出したカードの総和
         int count = 0;
         //カードの数
         int cardNum = 1;

         for (int num : numList) {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         }
         System.out.println(count);

    }

} Main
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
         Scanner sc = new Scanner(System.in);

         //A,B,C格納用配列
         int[] numList = new int[3];

         //入力値を配列に格納
         for (int i = 0; i < numList.length; i++) {
             numList[i] = sc.nextInt();
         }
         //取り出すカードの枚数: K
         int K = sc.nextInt();
         sc.close();

         //取り出したカードの総和
         int count = 0;
         //カードの数
         int cardNum = 1;

         for (int num : numList) {
             if (num > 0) {
                 if (num > K) {
                     num = K;
                 }
                 count += (cardNum * num);
                 K -= num;
                 if (K == 0) {
                     break;
                 }
             }
             cardNum--;
         }
         System.out.println(count);

    }

}
