A new delivery of clothing has arrived today to the clothing store. This delivery consists of $$$a$$$ ties, $$$b$$$ scarves, $$$c$$$ vests and $$$d$$$ jackets.The store does not sell single clothing items — instead, it sells suits of two types:  a suit of the first type consists of one tie and one jacket;  a suit of the second type consists of one scarf, one vest and one jacket. Each suit of the first type costs $$$e$$$ coins, and each suit of the second type costs $$$f$$$ coins.Calculate the maximum possible cost of a set of suits that can be composed from the delivered clothing items. Note that one item cannot be used in more than one suit (though some items may be left unused).

The first line contains one integer $$$a$$$ $$$(1 \le a \le 100\,000)$$$ — the number of ties. The second line contains one integer $$$b$$$ $$$(1 \le b \le 100\,000)$$$ — the number of scarves. The third line contains one integer $$$c$$$ $$$(1 \le c \le 100\,000)$$$ — the number of vests. The fourth line contains one integer $$$d$$$ $$$(1 \le d \le 100\,000)$$$ — the number of jackets. The fifth line contains one integer $$$e$$$ $$$(1 \le e \le 1\,000)$$$ — the cost of one suit of the first type. The sixth line contains one integer $$$f$$$ $$$(1 \le f \le 1\,000)$$$ — the cost of one suit of the second type.

Print one integer — the maximum total cost of some set of suits that can be composed from the delivered items.

NoteIt is possible to compose three suits of the second type in the first example, and their total cost will be $$$6$$$. Since all jackets will be used, it's impossible to add anything to this set.The best course of action in the second example is to compose nine suits of the first type and eleven suits of the second type. The total cost is $$$9 \cdot 4 + 11 \cdot 6 = 102$$$.

#include<stdio.h>
int main()
{
    long long int arr[9],max=1000000000,j,sum,i,k;
    for(i=0; i<6; i++)
    {
        scanf("%lld",&arr[i]);
    }
    if(arr[4]<arr[5])
    {
        for(i=1; i<=3; i++)
        {
            if(max>arr[i])
            {
                max=arr[i];
            }
        }
        sum=max*arr[5];
        j=arr[3]-max;
        if(j>arr[0])
        {
            sum=sum+arr[0]*arr[4];
        }
        else
        {
            sum=sum+j*arr[4];
        }
    }
    else
    {
        if(arr[0]>arr[3])
        {
          sum=arr[3]*arr[4];
          k=arr[3];
        }
        else
        {
            sum=arr[0]*arr[4];
            k=arr[0];
        }
        arr[3]=arr[3]-k;
        for(i=1;i<=3;i++)
        {
            if(max>arr[i])
            {
                max=arr[i];
            }
        }
        sum=sum+max*arr[5];
    }
    printf("%lld\n",sum);
}

#include <stdio.h>
main()
{
    int a,b,c,d,e,f,cost;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
        if(d<=a)
        {
            cost=d*e;
        }
        else
        {
            if((d-a)<b&&(d-a)<c)

                cost=a*e+(d-a)*f;
            else if(c<b)
                cost=a*e+(c)*f;

            else
                cost=a*e+(b)*f;

        }
    }
    else
    {
        if(d<=b && d<=c)
        {
            cost=d*f;
        }
        else
        {
            if(b<=c && (d-b)<a)
                cost=b*f+(d-b)*e;
            else if(b<=c && (d-b)>a)
                cost=b*f+a*e;
            else if(c<=b && (d-c)<a)
                cost=c*f+(d-c)*e;
            else
                cost=c*f+a*e;
        }
    }

    printf("%d",cost);

}

#include<stdio.h>
int main()
{
    long long int sum1=0,sum2=0;
    int a,b,c,d,e,f,min=10000000;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    if(e<f)
    {
        if(b<min)
            min = b;
        if(c<min)
            min = c;
        if(d<min)
            min =d;
        sum2 = min*f;
        if(d>min)
        {
            d = d-min;
            if(a>d)
                sum1 = d*e;
            else
                sum1 = a*e;
        }
    }
    else
    {
        min=10000000;
        if(a>d) {
            sum1 = d*e;
            d = 0;
        }
        else {
            sum1 = a*e;
            d = d-a;
        }
        if(b<min)
            min = b;
        if(c<min)
            min = c;
        if(d<min)
            min =d;
        sum2 = min*f;
    }
    printf("%lld\n",sum1+sum2);

    return 0;
}

#include <stdio.h>

int main() {

	int i, index, index2, suit1Cost, suit2Cost, remainder, total=0;
	unsigned int clothes[4];
	unsigned int smallest = 100001;

	scanf("%d", &clothes[0]);
	scanf("%d", &clothes[1]);
	scanf("%d", &clothes[2]);
	scanf("%d", &clothes[3]);
	scanf("%d", &suit1Cost);
	scanf("%d", &suit2Cost);

	for (i = 0; i < 4; i++) {
		if (clothes[i] < smallest) {
			smallest = clothes[i];
			index = i;
		}
	}

	if (suit1Cost <= suit2Cost) {
		if (index == 0) {
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}
			if (index == 3) {
				total = clothes[index] * suit2Cost;
			}
			else {
				remainder = clothes[3] - smallest;
				if (remainder <= clothes[0]) {
					total = ((smallest)*suit2Cost) + (remainder * suit1Cost);
				}
				else {
					total = ((smallest)*suit2Cost) + (clothes[0] * suit1Cost);
				}
			}
		}
		else if (index == 3) {
			total = clothes[index] * suit2Cost;
		}
		else {
			remainder = clothes[3] - smallest;
			if (remainder > 0) {
				total = smallest * suit2Cost;
				if (remainder <= clothes[0]) {
					total += remainder * suit1Cost;
				}
				else {
					total += clothes[0] * suit1Cost;
				}
			}
			else {
				total = clothes[3] * suit2Cost;
			}
		}
	}
	else if (suit1Cost > suit2Cost) {
		remainder = clothes[3] - clothes[0];
		if (index == 0) {
			total = clothes[0] * suit1Cost;
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}

			if (remainder <= smallest) {
				total += remainder * suit2Cost;
			}
			else {
				total += smallest * suit2Cost;
			}
		}
		else if (index == 3) {
			total = clothes[3] * suit1Cost;
		}
		else {
			if (remainder > 0) {
				total = clothes[0] * suit1Cost;
				if (remainder <= smallest) {
					total += remainder * suit2Cost;
				}
				else {
					total += smallest * suit2Cost;
				}
			}
			else {
				total = clothes[3] * suit1Cost;
			}
		}
	}

	printf("%d", total);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>

#define NUM_INPUT 6

struct Quantity{
    int a;
    int b;
    int c;
    int d;
};

struct Value{
    int e;
    int f;
};

int get_most_valuable(struct Quantity *quant, struct Value *val){
    int result=0, least=0, least_x=0, least_y=0;

    least_x = quant->a < quant->d ? quant->a : quant->d;
    least_y = quant->b < quant->c ? quant->b : quant->c;
    least_y = least_y < quant->d ? least_y : quant->d;

    least = least_x < least_y ? least_x : least_y;
    if(least == quant->d)
        return val->e < val->f ?  val->f * quant->d : val->e * quant->d;
    else if(least_x + least_y <= quant->d)
        return (least_x * val->e) + (least_y * val->f);
    else{
        if(val->e > val->f){
            result = val->e * least_x;
            least_y = least_y < quant->d - least_x ? least_y : quant->d - least_x;
            result += least_y * val->f;
        }
        else if(val->e < val->f){
            result = least_y * val->f;
            least_x = least_x < quant->d - least_y ? least_x : quant->d - least_y;
            result += val->e * least_x;
        }
        else
            result = quant->d * val->e;

        return result;
    }
}

int main(void){
    int input[NUM_INPUT] = {0};
    struct Quantity *quant;
    struct Value *val;

    for(int i=0; i<NUM_INPUT; i++)
        scanf("%d", input+i);

    quant = (struct Quantity*) input;
    val = (struct Value*) (input + (sizeof(struct Quantity)/sizeof(int)));

    printf("%d\n", get_most_valuable(quant, val));

    return 0;
}

#include <stdio.h>
int smaller (int a,int b,int c)
{
    int temp=0;
    if(a<=b&&a<=c)
    temp=a;
    else if(b<=c&&b<=a )
        temp=b;
    else if(c<=a&&c<=b)
        temp=c;
        return temp;
};
int func1(int a,int b,int c,int d,int e,int f)
{
    int cost1,cost2;
    if(a<d)
    {cost1=a*e;
    d=d-a;}
    else
    {
        cost1=d*e;
        d=0;
        }
    cost2=(smaller(b,c,d))*f;
   // printf("%d  %d\n",cost1,cost2);

    return (cost1+cost2);

};
int func2(int a,int b, int c ,int d, int e,int f)
{
   int  t=smaller(b,c,d);
   int cost1,cost2=f*t;
   d=d-t;
   if(a<d)
   {
       cost1=a*e;
       }
   else
    cost1=d*e;

  int cost3=cost1+cost2;
  //printf("%d  %d \n",cost1,cost2);
  return cost3;

};
int main()
{
    int a,b,c,d,e,f,cost1,cost2;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    int t=func1(a,b,c,d,e,f);
    int s=func2(a,b,c,d,e,f);
    if(t<s)
    printf("%d",s);
    else
        printf("%d",t);
    return 0;

}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{   int a,b,c,d,e,f,min;
    long k=0;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&f);
    if(e>=f) {
        min=fmin(a,d);
        k=e*fmin(a,d);
        d=d-min;
        a=a-min;
        if(d>0){
            min=fmin(b,c);
            min=fmin(min,d);
            k=k+f*min;}
    }
    else {
        min=fmin(b,c);
        min=fmin(min,d);
        k=f*min;
        b=b-min;
        c=c-min;
        d=d-min;
        if(d>0)
            k=k+e*fmin(a,d);
    }
    printf("%ld",k);
    return 0;
}

#include<stdio.h>
#include<stdlib.h>
int main()
{
// int t;
 //scanf("%d", &t);
// while(t--)
 //{
    int a, b, c, d, e, f, cost=1;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    if(e<=f){
                  int min=1000000;
                  if(c<min) min=c;
                  if(b<min)min=b;
                  if(d<min)min=d; d-=min;
                  cost=f*min; min=1000000;
                  if(a<min)min=a;  if(d<min)min=d;
                  cost+=e*min; printf("%d", cost); }
     else if(e>f){
                  int min=1000000;
                   if(a<min)min=a;  if(d<min)min=d; d-=min;
                     cost=e*min; min=1000000;
                    if(c<min) min=c;
                  if(b<min)min=b;
                  if(d<min)min=d;
                  cost+=f*min;

                printf("%d", cost); }

 //}
  return 0;
}

//suits complete
//Bismillahir Rahmanir Rahim
#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,min,cost = 0,x=0;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    if(e<f)
    {
        if(b<=c && b<=d)
            min = b;
        else if(c<=b && c<=d)
            min = c;
        else if(d<=c && d<=b)
            min = d;

        cost+=(min*f);
        d=d-min;
        if(d>0)
        {
            if(d>=a)
            {
                cost+=(a*e);
            }
            else
                cost+=(d*e);
        }
    }

    else if(e>f)
    {
        if(a>=d)
        {
            cost+=(d*e);
        }

        else if(d>=a)
        {
            cost+=(a*e);
            d=d-a;

            if(b<=c && b<=d)
            min = b;
            else if(c<=b && c<=d)
                min = c;
                else if(d<=c && d<=b)
                    min = d;
                    cost+=(min*f);

        }
}
    else if(e==f)
        {

            if(b<=c && b<=d)
                min = b;
            else if(c<=b && c<=d)
                min = c;
            else if(d<=c && d<=b)
                min = d;

            x = min + a;
            if(x>=d)
                cost+=(e*d);
            else
                cost+=(e*x);
        }

    printf("%d\n",cost);

    return 0;
}
//  4 5 6 3 1 2
//  12 11 13 20 4 6
//  17 14 5 21 15 17
//  84205 15736 30259 79331 647 378

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

static int totalCost=0;

int getMin(int, ...);
void updateTotalCost(int,int);

int main()
{

        int tie,scarf,vest,jackets,costType1,costType2;
        int dF1,dF2, tempCost, remain;

        scanf("%d\n%d\n%d\n%d\n%d\n%d",&tie,&scarf,&vest,&jackets,&costType1,&costType2);

        int type = (costType1 > costType2)?0:1;

//      printf("Printing type %d\n ", type);
        switch(type)
        {
          case 0:
                  dF1 = getMin(2,tie,jackets);
                  tempCost=costType1;
                  break;

          case 1:
                  dF1 = getMin(3,scarf,vest,jackets);
                  tempCost=costType2;
                  break;
        }

//      printf("Decision Factor 1 %d\n TempCost %d\n",dF1, tempCost);
        updateTotalCost(dF1,tempCost);
        remain = abs(jackets-dF1);
        if(remain)
        {
                (type==0)? (dF2 = getMin(3,scarf,vest,remain) , tempCost = costType2)
                        : (dF2 = getMin(2,tie,remain), tempCost = costType1);

//              printf("Decision Factor 2 %d\n tempCost %d\n",dF2, tempCost);
                updateTotalCost(dF2,tempCost);
        }
        printf("%d\n",totalCost);

}
int getMin(int numOfargs, ...)
{
        int minRes, each;
        va_list ap;

        va_start(ap,numOfargs);

        minRes = va_arg(ap,int);

        for( int i=2; i<=numOfargs; i++)
        {
                if ( (each = va_arg(ap,int)) < minRes)
                {
                        minRes = each;
                }
        }

        va_end(ap);

        return minRes;
}

void updateTotalCost(int decisionFactor, int cost)
{

        totalCost = totalCost+(decisionFactor * cost);

}

#include <stdio.h>
int min(int a,int b){if(a<b)return a;else return b;}
int main(){
    int a,b,c,d,e,f,s=0;
        scanf("%i%i%i%i%i%i",&a,&b,&c,&d,&e,&f);
        if(e>f){
            s+= min(a,d)*e;
            d -= min(a,d);
            s+=min(min(b,c),d)*f;
        }
         else{
             s+=min(min(b,c),d)*f;
             d -= min(min(b,c),d);
             s+= min(a,d)*e;
         }
        printf("%i\n",s);
  return 0-0-0;
}

#include <stdio.h>
#define INPUT 6

void suitType1();
void suitType2();
int input[INPUT];
int price = 0;
int suits;

int main(){

    for(int i =0; i<INPUT; i++){

        scanf("%i", &input[i]);
    }
    suits = input[3];

    if(input[4]> input[5]){
        suitType1();
        suitType2();
    }
    else{
        suitType2();
        suitType1();
    }
    printf("%i\n", price);
}

void suitType1(){

    if(input[0]>0 && suits>0){

        if(input[0]> suits){

            price = price+(suits * input[4]);
            suits = 0;
        }
        else{
            price = price+(input[0]*input[4]);
            suits = suits - input[0];
        }
    }
}

void suitType2(){

    int max_type2=0;
    if(input[1]>0 && input[2]>0 && suits>0){
        if(input[1]>input[2]){
            max_type2 = input[2];
        }
        else if(input[1]<input[2]){

             max_type2 = input[1];
        }
        else{
            max_type2 = input[1];
        }

        if(max_type2> suits){
            price = price + suits * input[5];
            suits = 0;
        }
        else{
            price = price + max_type2 * input[5];
            suits = suits - max_type2;
        }
    }
}

#include <stdio.h>

int main(int argc, char **argv)
{
  unsigned long tie, scarf, vest, jacket;
  int suit_cost_jt, suit_cost_jsv, no_suit_jt = 0, no_suit_jsv = 0;
  // zero input protection or validation
  scanf("%lu\n%lu\n%lu\n%lu\n%d\n%d", &tie, &scarf, &vest, &jacket, &suit_cost_jt, &suit_cost_jsv);

  if ( jacket <= scarf && jacket <= vest ) {
        no_suit_jsv = jacket;
        jacket = 0;
  } else if ( scarf <= jacket && scarf <= vest) {
        no_suit_jsv = scarf;
        jacket -= scarf;
  } else {
        no_suit_jsv = vest;
        jacket -= vest;
  }

  if (tie > jacket) {
        no_suit_jt = jacket;
        tie -= jacket;
  } else {
        no_suit_jt = tie;
        tie = 0;
  }

  if (suit_cost_jt > suit_cost_jsv) {
        if (tie > no_suit_jsv)
          tie = no_suit_jsv % tie;
        no_suit_jsv -= tie;
        no_suit_jt  += tie;
  }

  printf("%d\n", no_suit_jt * suit_cost_jt + no_suit_jsv * suit_cost_jsv);
  return 0;
}

#include<stdio.h>
int min(int a,int b){
    if(a<b) return a;
    else return b;
}
int main(){
    int tie,scarf,vest,jacket,cost1,cost2;
    int total_cost,d,m,f;
    scanf("%d\n%d\n%d\n%d\n%d\n%d\n",&tie,&scarf,&vest,&jacket,&cost1,&cost2);
    if(cost2>cost1){
        d= min(jacket,min(scarf,vest));
        m = jacket-d;
        f = min(m,tie);
        total_cost = (d*cost2)+(f*cost1);
    }
    else{
        d = min(tie,jacket);
        m = jacket -d;
        f = min(scarf,min(m,vest));
        total_cost = (d*cost1)+(f*cost2);
    }
    printf("%d\n",total_cost);
    return 0;
}

#include <stdio.h>

int main()
{
    int a, b, c, d, e, f, min, res;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    if (e == f)
    {
        if (a >= d) res = d * e;
        else
        {
            res = a * e;
            d = d - a;
            if (b < c) min = b; else min = c;
            if (min > d) min = d;
            res = res + min * f;
        }
        printf ("%d", res);
    }
    if (e < f)
    {
         if (b < c) min = b; else min = c;
         if (min > d) min = d;
         res =  min * f;
         d = d - min;
         if (d < a) res = res + d*e; else res = res + e*a;
        printf ("%d", res);
    }
    if (e > f)
    {

         if (d < a) {res = d*e; d =0;} else {res = e*a; d = d-a;}
         if (b < c) min = b; else min = c;
         if (min > d) min = d;
         res =  res + min * f;
         printf ("%d", res);
    }

    return 0;
}

#include <stdio.h>
long a,b,c,d,e,f,maxf,maxe,n;
long min (long a, long b)
{
    if (a > b) return b; else return a;
}
int main()
{
    scanf("%ld", &a);
    scanf("%ld", &b);
    scanf("%ld", &c);
    scanf("%ld", &d);
    scanf("%ld", &e);
    scanf("%ld", &f);
    maxf = b;
    if (maxf > c) maxf = c;
    if (maxf > d) maxf = d;
    maxe = a;
    if (maxe > d) maxe = d;

    if (f > e) n = f *maxf + e * min (maxe, (d - maxf));
    else n = e *maxe + f * min((d - maxe), maxf);
    printf("%ld", n);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int min(int a,int b,int c){
    int min = a;
    if(min>b){
        min = b;
    }
    if(min > c){
        min = c;
    }
    return min;
}int max(int a,int b,int c){
    int min = a;
    if(min<b){
        min = b;
    }
    if(min < c){
        min = c;
    }
    return min;
}
int main()
{
    int a,b,c,d;
    int e,f;
    int sum1 = 0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int sum2= 0,sum3=0,sum4=0;
    int x;
    int maxaandd = a,minanda = d;
    if(a < d){
        maxaandd = d;
        minanda = a;
    }
    int k, o;
        x = min(d,b,c);
        sum1+=x*f;
        k = d-x;
        if(a<k){
            sum1+=a*e;
        }else{
            sum1+=k*e;
        }
        sum2+= minanda*e;
        sum3+= minanda*e;
        o = d - minanda;
        if(x>o){
            sum3+=o*f;
        }else{
            sum3+=x*f;
        }
        int z;
        printf("%d",max(sum1,sum2,sum3));
}

#include<stdio.h>
int max1(long int x,long int y)
{
    if(x>y)
    {
        return x ;

    }
    else
    {
         return y ;
    }

}
int min1(long int x,long int y)
{
    if(x<y)
    return x ;
    else
    {
        return y ;
    }

}
int min(long int x,long int y,long int z)
{
    if(x<=y && x<=z)
    return x ;
    else if(y<=z)
    return y ;
    else
    return z ;
}
int main()
{
    long int a,b,c,d,e,f,cost1,cost2 ;
    scanf("%ld %ld %ld %ld %ld %ld",&a,&b,&c,&d,&e,&f) ;

    cost1 = min1(a,d)*e + min(b,c,d - min1(a,d))*f ;
    cost2 = min1(a,d - min(b,c,d))*e + min(b,c,d)*f ;

    printf("%ld",max1(cost1,cost2)) ;

    return 0  ;

}

#include<stdio.h>
int main()
{
  int a,b,c,d,e,f,s=0,min,min1;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&f);
  if(e>f)
  {
    min=(a<d)?a:d;
    s=s+min*e;
    d=d-min;
    min1=(b<c)?((b<d)?b:d):((c<d)?c:d);
    s=s+min1*f;
  }
  else if(e<f)
  {
    min1=(b<c)?((b<d)?b:d):((c<d)?c:d);
    s=s+min1*f;
    d=d-min1;
    min=(a<d)?a:d;
    s=s+min*e;

  }
  else if(e==f)
  {
    min=(a<d)?a:d;
    s=s+min*e;
    d=d-min;
    min1=(b<c)?((b<d)?b:d):((c<d)?c:d);
    s=s+min1*f;
  }
  printf("%d\n",s);

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    long a,b,c,d,e,f,count=0;
    scanf("%li %li %li %li %li %li",&a,&b,&c,&d,&e,&f);

    if(f>e){
        while(b>0 && c>0 && d>0){
            b--;
            c--;
            d--;
            count+=f;
        }
        while(a>0 && d>0){
            a--;
            d--;
            count+=e;
        }
    }else{
        while(a>0 && d>0){
            a--;
            d--;
            count+=e;
        }
        while(b>0 && c>0 && d>0){
            b--;
            c--;
            d--;
            count+=f;
        }
    }
    printf("%li\n",count);
    return 0;
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
long long int min(long long int a,long long int b)
{
    if (a<b)
     return a;
    return b;
}
int main()
{
    long long int a,b,c,d,e,f,cost;
    scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
    if(f>e)
    {
    if(b<=d||c<=d)
    {
        cost=min(b,c)*f;
        d-=min(b,c);
        if(d!=0&&a!=0)
        cost+=min(a,d)*e;
    }
    else if(d<c||d<b)
    {
        cost=d*f;
    }
    }
    else
    {
        if(a<=d)
        {
          cost=a*e;
          d-=a;
          if(d!=0)
          {
              cost+=min(d,min(b,c))*f;
          }
        }
        else if(d<a)
        {
            cost=d*e;
        }
    }
    printf("%lld",cost);
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

int min(long long a,long long b)
{
    if(a>b)
    return b;
    else
    return a;
}
int main()
{
   long long a,b,c,d,e;
  long long f;
   scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
   if(e>f)
   {
      long long h=e*min(a,d);
     d-=min(a,d);
    long long j= min(b,min(c,d));
    long long g=  h + f*j;
     printf("%lld",g);
   }
   else
   {
        long long j=min(b,min(c,d));
         d-=j;
         long long g= e*min(a,d)+ f*j;
         printf("%lld",g);
   }
    return 0;
}

#include<stdio.h>

long long min(long long x,long long y,long long z){
	if(x<=y && x<=z)
		return x;
	else if(y<=x && y<=z)
		return y;
	else
		return z;
}
int main(){
	long long a,b,c,d,e,f,t1,t2;
	scanf("%lld %lld %lld %lld %lld %lld",&a,&b,&c,&d,&e,&f);
	if(f>e){
		t2=min(b,c,d);
		t1=min((d-t2),a,100005);
	}
	else{
		t1=min(a,d,100005);
		t2=min((d-t1),b,c);
	}
	printf("%lld\n",((t1*e)+t2*f));
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

#define MIN(a, b) ((a) < (b)) ? (a) : (b)
#define MINN(a, b, c) (MIN((a), (b))) < (c) ? (MIN((a), (b))) : (c)
#define MAX(a, b) ((a) > (b)) ? (a) : (b)

long a, b, c, d, e, f;
// costume type N:1 == a && d
// costume type N:2 == b && c && d
// e == price of costume N:1
// f == price of costume N:2

int maximum (int a, int b)
{
    if (a > b)
        return a;
    else
    return b;
}

int minimum (int a, int b)
{
    if (a < b)
        return a;
    else
        return b;
}

int main (void)
{
    long n;
    int maxf, maxe;
    //printf ("Enter your amount of stuff and prices: );
    scanf ("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    maxf = b;
    if (maxf > c) maxf = c;
    if (maxf > d) maxf = d;
    maxe = a;
    if (maxe > d) maxe = d;
    if (f > e)
        { n = f * maxf + e * minimum(maxe, (d - maxf)); }
    else
        { n = e * maxe + f * minimum((d - maxe), maxf); }
    printf ("%ld", n);
    exit (0);
}

#include<stdio.h>
#include<stdlib.h>
int min(int a,int b)
{
  if(a>b)
    return b;
  return a;
}
int main()
{
  int a,b,c,d,e,f,small=0,i,cost=0;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

  if(f>e) {
    small=min(min(b,c),d);
    cost = f * small;
    d = d-small;

    if(d>0) {
      small = min(a,d);
      cost = cost + (e*small);
    }
    printf("%d",cost);
  }
   else {
     small = min(a,d);
     cost = e * small;
     d = d-small;
     if(d>0) {
       small=min(min(b,c),d);
       cost = cost + (f*small);
     }
    printf("%d",cost);
   }
  }

#include <stdio.h>
#include <stdlib.h>

#define NUM_INPUT 6

struct Quantity{
    int a;
    int b;
    int c;
    int d;
};

struct Value{
    int e;
    int f;
};

int get_most_valuable(struct Quantity *quant, struct Value *val){
    int result=0, least=0, least_x=0, least_y=0;

    least_x = quant->a < quant->d ? quant->a : quant->d;
    least_y = quant->b < quant->c ? quant->b : quant->c;
    least_y = least_y < quant->d ? least_y : quant->d;

    least = least_x < least_y ? least_x : least_y;
    if(least == quant->d)
        return val->e < val->f ?  val->f * quant->d : val->e * quant->d;
    else if(least_x + least_y <= quant->d)
        return (least_x * val->e) + (least_y * val->f);
    else{
        if(val->e == val->f)
            result = quant->d * val->e;
        else if(val->e > val->f){
            result = val->e * least_x;
            least_y = least_y < quant->d - least_x ? least_y : quant->d - least_x;
            result += least_y * val->f;
        }
        else{
            result = least_y * val->f;
            least_x = least_x < quant->d - least_y ? least_x : quant->d - least_y;
            result += val->e * least_x;
        }
        return result;
    }
}

int main(void){
    int input[NUM_INPUT] = {0};
    struct Quantity *quant;
    struct Value *val;

    for(int i=0; i<NUM_INPUT; i++)
        scanf("%d", input+i);

    quant = (struct Quantity*) input;
    val = (struct Value*) (input + 4);

    printf("%d\n", get_most_valuable(quant, val));

    return 0;
}

#include<stdio.h>
int main()
{
    long long int a,b,c,d;
    long long int e,f;
    long long int cost1=0,cost2=0;
    scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    scanf("%lld %lld",&e,&f);
    int min=0;
    if(a>=d)
    {
        cost1=d*e;
        if(d<=b && d<=c)
            cost2=d*f;
        else
        {
            if(b<=c)
                cost2=b*f+(d-b)*e;
            else
                cost2=c*f+(d-c)*e;
        }
    }
    else
    {
        cost1=a*e;
        if((d-a)<=b && (d-a)<=c)
            cost1+=(d-a)*f;
        else
        {
            if(b<=c)
                cost1+=b*f;
            else
                cost1+=c*f;
        }
        if(d<=b && d<=c)
            cost2=d*f;
        else
        {
            if(b<=c)
            {
                cost2=b*f;
                if((d-b)<a)
                    cost2+=(d-b)*e;
                else
                    cost2+=a*e;
            }
            else
            {
                cost2=c*f;
                if((d-c)<a)
                    cost2+=(d-c)*e;
                else
                    cost2+=a*e;
            }
        }
    }
    if(cost1>cost2)
        printf("%lld\n",cost1);
    else
        printf("%lld\n",cost2);
    return 0;
}

#include<stdio.h>
int main()
{
	long long int a, b, c, d, e, f, p, q, m;
	p=0;
	q=0;
	scanf("%lld %lld %lld %lld %lld %lld", &a, &b, &c, &d, &e, &f);

	if(b<c){
		if(b<d){
			m=b;
		}
		else{
			m=d;
		}
	}
	else if(b<d){
		m=c;
	}
	else{
		if(c<d){
			m=c;
		}
		else{
			m=d;
		}
	}

	if(e>f)
	{
		if(a>=d)
		{
			p=d;
		}
		else
		{
			p=a;
			if((d-a)<=m)
			{
				q=d-a;
			}
			else
			{
				q=m;
			}
		}
	}
	else if(e<f)
	{
		if(d<=m)
		{
			q=d;
		}
		else
		{
			q=m;
			if((d-m)<=a)
			{
				p=d-m;
			}
			else
			{
				p=a;
			}
		}
	}
	else
	{
		if(m>=a)
		{
			if(m>=d)
			{
				q=d;
			}
			else
			{
				q=m;
				if((d-m)<=a)
				{
					p=d-m;
				}
				else
				{
					p=a;
				}
			}
		}
		else
		{
			if(a>=d)
			{
				p=d;
			}
			else
			{
				p=a;
				if((d-m)<=m)
				{
					q=d-m;
				}
				else
				{
					q=m;
				}
			}
		}
	}
	printf("%lld", (e*p)+(f*q));

	return 0;
}

#include <stdio.h>

#define MIN(x,y) ((x) < (y) ? (x) : (y))
#define MAX(x,y) ((x) > (y) ? (x) : (y))

int max_cost(int a, int b, int c, int d, int e, int f) {
    int e1 = 0, f1 = 0, e2 = 0, f2 = 0;
    int cost1 = 0, cost2 = 0;

    e1 = (d < a) ? d : a;
    f1 = (d < a) ? 0 : ((d - a) <= MIN(b,c) ? (d - a) : MIN(b,c));

    f2 = (d < MIN(b,c)) ? d : MIN(b,c);
    e2 = (d < MIN(b,c)) ? 0 : ( (d - MIN(b,c)) <= a ? (d - MIN(b,c)) : a);

    cost1 = (e1 * e) + (f1 * f);
    cost2 = (e2 * e) + (f2 * f);

    return MAX(cost1, cost2);
}

int main() {
    int a = 0;
    int b = 0;
    int c = 0;
    int d = 0;
    int e = 0;
    int f = 0;

    scanf("%d\n%d\n%d\n%d\n%d\n%d",
            &a, &b, &c, &d, &e, &f);

    printf("%d\n", max_cost(a, b, c, d, e, f));

    return 0;
}

#include<stdio.h>

int main()
{
     int a,b,c,d,e,f,r,s,cost=0;
     scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
     if(e<f)
     {
          if((b<c)&&(b<d))
               r=b;
          else if(c<d)
               r=c;
          else
               r=d;
          cost=(r*f);
          d-=r;
          if(d!=0)
          {
               if(a<d)
                    s=a;
               else
                    s=d;
               cost+=(s*e);
          }
     }
     else
     {
          if(a<d)
               r=a;
          else
               r=d;
          cost=r*e;
          d-=r;
          if(d!=0)
          {
               if((b<c)&&(b<d))
                    s=b;
               else if(c<d)
                    s=c;
               else
                    s=d;
               cost+=(s*f);
          }
     }

     printf("%d",cost);

     return 0;
}

#include <stdio.h>
long a,b,c,d,e,f,maxf,maxe,n;
long min (long a, long b)
{
    if (a > b) return b; else return a;
}
int main()
{
    scanf("%ld", &a);
    scanf("%ld", &b);
    scanf("%ld", &c);
    scanf("%ld", &d);
    scanf("%ld", &e);
    scanf("%ld", &f);
    maxf = b;
    if (maxf > c) maxf = c;
    if (maxf > d) maxf = d;
    maxe = a;
    if (maxe > d) maxe = d;

    if (f > e) n = f *maxf + e * min (maxe, (d - maxf));
    else n = e *maxe + f * min((d - maxe), maxf);
    printf("%ld", n);

    return 0;
}

#include<stdio.h>
int smallest(int a, int b, int c)
{
    if(a<=b && a<=c) return a;
    if(b<=a && b<=c) return b;
    else return c;
}
main()
{
    int a,b,c,d,e,f,k,r;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    if(f>e) {
    k=smallest(b,c,d);
    d=d-k;
    if(a>=d) printf("%d", e*d+f*k);
    else if(a<d) printf("%d", e*a+f*k);
    }
    else {
    if(a>=d) printf("%d", d*e);
    else {
        d=d-a;
        k=smallest(b,c,d);
        printf("%d", a*e+k*f);
    }
    }
}

#include<stdio.h>

int min(int a,int b)
{
	if(a > b)
		return b;
	else
		return a;

}
int max(int a,int b)
{
        if(a > b)
                return a;
        else
                return b;

}

int main()
{
	int a,b,c,d,e,f;

	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

	int p = min(a,d);
	int mn = min(b,c);
	int q = min(mn,d);

	mn = max(e*p,f*q);

	if( f > e)
	{
		if(p + q <= d)
		{
			mn = max(mn, e*p + f*q);

		}

		else
		{
			while( q > 0)
			{
				if( q < d && d < p + q)
				{
					p = d-q;
					mn = max(mn, e*p + f*q);

				}

				q--;

			}

		}

	}

	else
	{
	if(p + q <= d)
                {
                        mn = max(mn, e*p + f*q);

                }

                else
                {
                        while( p > 0)
                        {
                                if( p < d && d < p+q)
                                {
                                        q = d-p;
                                        mn = max(mn, e*p + f*q);

                                }

                                p--;

                        }

                }

	}
	printf("%d",mn);
	return 0;
}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    long a,b,c,d,e,f,count=0;
    scanf("%li %li %li %li %li %li",&a,&b,&c,&d,&e,&f);

    if(f>e){
        while(b>0 && c>0 && d>0){
            b--;
            c--;
            d--;
            count+=f;
        }
        while(a>0 && d>0){
            a--;
            d--;
            count+=e;
        }
    }else{
        while(a>0 && d>0){
            a--;
            d--;
            count+=e;
        }
        while(b>0 && c>0 && d>0){
            b--;
            c--;
            d--;
            count+=f;
        }
    }
    printf("%li\n",count);
    return 0;
}

#include<stdio.h>
unsigned int min(unsigned int a,unsigned int b) {
    if(a<b)
        return a;
    else
        return b;
}
int main() {
    unsigned int a,b,c,d,e,f,cost,m;
    scanf("%u %u %u %u %u %u",&a,&b,&c,&d,&e,&f);
    if ( f>e ) {
        m=min(min(b,c),d);
        cost=m*f+min(a,d-m)*e;
        printf("%u",cost);
    }
    else {
        m=min(a,d);
        cost=m*e+min(min(b,c),d-m)*f;
        printf("%u",cost);
    }
    return 0;
}

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
long long int min(long long int a,long long int b)
{
    if (a<b)
     return a;
    return b;
}
int main()
{
    long long int a,b,c,d,e,f,cost;
    scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
    if(f>e)
    {
    if(b<=d||c<=d)
    {
        cost=min(b,c)*f;
        d-=min(b,c);
        if(d!=0&&a!=0)
        cost+=min(a,d)*e;
    }
    else if(d<c||d<b)
    {
        cost=d*f;
    }
    }
    else
    {
        if(a<=d)
        {
          cost=a*e;
          d-=a;
          if(d!=0)
          {
              cost+=min(d,min(b,c))*f;
          }
        }
        else if(d<a)
        {
            cost=d*e;
        }
    }
    printf("%lld",cost);
}

#include<stdio.h>
long long min(long long a,long long b,long long c)
{
if(a<b)
{
if(a<c)
return a;
else
return c;
}
else
{
if(b<c)
return b;
else
return c;
}
}
int main()
{
    long long a, b, c, d, e, f,y;
    long long cost=0;
    scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
    if(a>=d)
    cost=d*e;
    else
    {
    cost=a*e;
    d-=a;

    y=min(b,c,d);
    cost+=y*f;
    }}
    else
    {
    y=min(b,c,d);
    cost=y*f;
    d-=y;
    if(d>=a)
    cost+=a*e;
    else
    cost+=d*e;
    }
    printf("%lld",cost);
    return 0;
}

#include<stdio.h>
int main()
{
  int a,b,c,d,e,f,s=0,min,min1;
  scanf("%d",&a);
  scanf("%d",&b);
  scanf("%d",&c);
  scanf("%d",&d);
  scanf("%d",&e);
  scanf("%d",&f);
  if(e>f)
  {
    min=(a<d)?a:d;
    s=s+min*e;
    d=d-min;
    min1=(b<c)?((b<d)?b:d):((c<d)?c:d);
    s=s+min1*f;
  }
  else if(e<f)
  {
    min1=(b<c)?((b<d)?b:d):((c<d)?c:d);
    s=s+min1*f;
    d=d-min1;
    min=(a<d)?a:d;
    s=s+min*e;

  }
  else if(e==f)
  {
    min=(a<d)?a:d;
    s=s+min*e;
    d=d-min;
    min1=(b<c)?((b<d)?b:d):((c<d)?c:d);
    s=s+min1*f;
  }
  printf("%d\n",s);

}

#include <stdio.h>

int main()
{
      int tie, scarve, vest, jacket, suit1, suit2, cost = 0;

      scanf("%d %d %d %d %d %d", &tie, &scarve, &vest, &jacket, &suit1, &suit2);

            if(suit1 >= suit2) {
                  if(jacket >= tie) {
                        jacket -= tie;
                        cost += tie * suit1;
                  }
                  else {
                        cost += jacket * suit1;
                        jacket = 0;
                  }
                  if(jacket != 0) {
                        if(jacket <= scarve && jacket <= vest) {
                              cost += jacket * suit2;
                        }
                        else if(scarve <= jacket && scarve <= vest) {
                              cost += scarve * suit2;
                        }
                        else {
                              cost += vest * suit2;
                        }
                  }
            }
            else if(suit1 < suit2){
                  if(jacket <= scarve && jacket <= vest) {
                        cost += jacket * suit2;
                        jacket = 0;
                  }
                  else if(scarve <= jacket && scarve <= vest) {
                        cost += scarve * suit2;
                        jacket -= scarve;
                  }
                  else {
                        cost += vest * suit2;
                        jacket -= vest;
                  }
                  if(jacket != 0 && tie != 0) {
                        if(jacket >= tie) {
                              cost += tie * suit1;
                        }
                        else {
                              cost += jacket * suit1;
                        }
                  }
            }
      printf("%d\n", cost);

      return 0;
}

#include<stdio.h>
int main()
{
	long long a,b,c,d,e,f,min2,min1;
	scanf("%lld %lld %lld %lld %lld %lld",&a,&b,&c,&d,&e,&f);
if(e < f)
{
	if(b <= c && b <= d)
	{
		min2 = b;
	}
	else if(c <= d && c <= b)
	{
		min2 = c;
	}
	else{
		min2 = d;
	}
	d -= min2;

	min1 = (a < d) ? a : d;
	if(min1 < 0)
	{
		min1 *= -1;
	}

	min2 *= f;
	min1 *= e;
	printf("%lld",min1+min2);
}
else{
	if(a <= d)
	{
		min1 = a;
	}
	else{
		min1 = d;
	}
	d -= min1;
	if(b <= c && b <= d)
	{
		min2 = b;
	}
	else if(c <= b && c <= d)
	{
		min2 = c;
	}
	else{
		min2 = d;
	}
	min1 *= e;
	min2 *= f;
	printf("%lld\n",min1+min2);
}
	return 0;

}

#include <stdio.h>

int main(int argc, char **argv)
{
  unsigned long tie, scarf, vest, jacket;
  unsigned int suit_cost_jt, suit_cost_jsv, no_suit_jt = 0, no_suit_jsv = 0;
  // zero input protection or validation
  scanf("%lu\n%lu\n%lu\n%lu\n%d\n%d", &tie, &scarf, &vest, &jacket, &suit_cost_jt, &suit_cost_jsv);

  if ( jacket <= scarf && jacket <= vest ) {
    no_suit_jsv = jacket;
    jacket = 0;
  } else if ( scarf <= jacket && scarf <= vest) {
    no_suit_jsv = scarf;
    jacket -= scarf;
  } else {
    no_suit_jsv = vest;
    jacket -= vest;
  }

  if (tie > jacket) {
    no_suit_jt = jacket;
    tie -= jacket;
  } else {
    no_suit_jt = tie;
    tie = 0;
  }

  for(;suit_cost_jt > suit_cost_jsv && tie && no_suit_jsv; no_suit_jsv--, tie--, no_suit_jt++);

  printf("%d\n", no_suit_jt * suit_cost_jt + no_suit_jsv * suit_cost_jsv);
  return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,sum=0,min;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&f);
    if(f>e)
    {
        if(b<=c && b<=d)
        min=b;
        if(c<=b && c<=d)
        min=c;
        if(d<=b && d<=c)
        min=d;
        sum=(min)*f;
        d=d-min;
        if(a<=d)
        min=a;
        else
        min=d;
        sum+=(min)*e;
    }
    else
    {
        if(a<=d)
        min=a;
        else
        min=d;
        sum+=(min)*e;
        d=d-min;
        if(b<=c && b<=d)
        min=b;
        if(c<=b && c<=d)
        min=c;
        if(d<=b && d<=c)
        min=d;
        sum+=(min)*f;

    }
    printf("%d",sum);
}

#include<stdio.h>
#include<math.h>
int main()
{   int a,b,c,d,e,f,min,p;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

    if(e>f)
    {
        if(a>d)
            p=d*e;
        else
        {
            d=d-a;
            min=b<c?(b<d?b:c):(c<d?c:d);
            if(d>min)
                p=a*e+min*f;
            else
                p=a*e+d*f;
        }

    }
    else
    {min=b<c?(b<d?b:d):(c<d?c:d);
    if(min>d)
        p=d*f;
    else
    {
        d=d-min;
        if(a>d)
            p=min*f+d*e;
        else
            p=min*f+a*e;
    }

    }printf("%d",p);

}

#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,sum=0,x;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&f);
    if(f>=e)
    {
        if(c>=b && d>=b)
        {
            sum=sum+(b*f);
            if(d-b>=a)
            {
                sum=sum+(a*e);
            }
            else if(d-b<=a)
            {
                sum=sum+((d-b)*e);
            }
        }
        else if(b>=c && d>=c)
        {
            sum=sum+(c*f);
            if(d-c>=a)
            {
                sum=sum+(a*e);
            }
            else if(d-c<=a)
            {
                sum=sum+((d-c)*e);
            }
        }
        else if(c>=d && b>=d)
        {
            sum=sum+(d*f);
        }
    }
        else if(f<e)
    {
        if(a>=d)
        {
            sum=sum+(d*e);
        }
        else if(a<=d)
        {
            sum=sum+(a*e);
            x=d-a;
            if(b>=x && c>=x)
            {
                sum=sum+(x*f);
            }
            else if(x>=b && c>=b)
            {
                sum=sum+(b*f);
            }
            else if(x>=c && b>=c)
            {
                sum=sum+(c*f);
            }
        }
    }
    printf("%d",sum);
}

#include <stdio.h>
long a,b,c,d,e,f,maxf,maxe,n;
long min (long a, long b)
{
    if (a > b) return b; else return a;
}
int main()
{
    scanf("%ld", &a);
    scanf("%ld", &b);
    scanf("%ld", &c);
    scanf("%ld", &d);
    scanf("%ld", &e);
    scanf("%ld", &f);
    maxf = b;
    if (maxf > c) maxf = c;
    if (maxf > d) maxf = d;
    maxe = a;
    if (maxe > d) maxe = d;

    if (f > e) n = f *maxf + e * min (maxe, (d - maxf));
    else n = e *maxe + f * min((d - maxe), maxf);
    printf("%ld", n);

    return 0;
}

#include<stdio.h>

long long min(long long x,long long y,long long z){
	if(x<=y && x<=z)
		return x;
	else if(y<=x && y<=z)
		return y;
	else
		return z;
}
int main(){
	long long a,b,c,d,e,f,t1,t2;
	scanf("%lld %lld %lld %lld %lld %lld",&a,&b,&c,&d,&e,&f);
	if(f>e){
		t2=min(b,c,d);
		t1=min((d-t2),a,100005);
	}
	else{
		t1=min(a,d,100005);
		t2=min((d-t1),b,c);
	}
	printf("%lld\n",((t1*e)+t2*f));
	return 0;
}

#include<stdio.h>
int main()
{
    long long int arr[9],max=1000000000,j,sum,i,k;
    for(i=0; i<6; i++)
    {
        scanf("%lld",&arr[i]);
    }
    if(arr[4]<arr[5])
    {
        for(i=1; i<=3; i++)
        {
            if(max>arr[i])
            {
                max=arr[i];
            }
        }
        sum=max*arr[5];
        j=arr[3]-max;
        if(j>arr[0])
        {
            sum=sum+arr[0]*arr[4];
        }
        else
        {
            sum=sum+j*arr[4];
        }
    }
    else
    {
        if(arr[0]>arr[3])
        {
          sum=arr[3]*arr[4];
          k=arr[3];
        }
        else
        {
            sum=arr[0]*arr[4];
            k=arr[0];
        }
        arr[3]=arr[3]-k;
        for(i=1;i<=3;i++)
        {
            if(max>arr[i])
            {
                max=arr[i];
            }
        }
        sum=sum+max*arr[5];
    }
    printf("%lld\n",sum);
}

#include <stdio.h>

int main(void)
{
	long int a,b,c,d,e,f,w,y,x,v;
	scanf("%ld",&a);
	scanf("%ld",&b);
	scanf("%ld",&c);
	scanf("%ld",&d);
	scanf("%ld",&e);
	scanf("%ld",&f);
	if(f>e)
	{
		if((b<=c)&&(b<=d))
		{
			w=b*f;
			x=d-b;
			if(a<x)
			{
				y=a*e;
				v=w+y;
				printf("%ld",v);
			}
			else
			{
				y=x*e;
				v=y+w;
				printf("%ld",v);
			}
		}
		else if((c<=b)&&(c<=d))
		{
			w=c*f;
			x=d-c;
			if(a<x)
			{
				y=a*e;
				v=w+y;
				printf("%ld",v);
			}
			else
			{
				y=x*e;
				v=y+w;
				printf("%ld",v);
			}
		}
		else
		{
			w=d*f;
			printf("%ld",w);
		}
	}
	else
	{
		if(a<d)
		{
			w=a*e;
			x=d-a;
			if((b<=c)&&(b<=x))
			{
				y=b*f;
				v=y+w;
				printf("%ld",v);
			}
			else if((c<=b)&&(c<=x))
			{
				y=c*f;
				v=y+w;
				printf("%ld",v);
			}
			else
			{
				y=x*f;
				v=y+w;
				printf("%ld",v);
			}
		}
		else
		{
			w=d*e;
			printf("%ld",w);
		}
	}
	return 0;
}

#include <stdio.h>
#include <string.h>

int main(){
	int tie,scarf,vest,jacket;
	int n1, n2;
	int s1 = 0, s2 = 0;
 	scanf("%d %d %d %d %d %d", &tie,&scarf,&vest,&jacket,&n1,&n2);
 		if(n2 > n1){
 			while(scarf&&vest&&jacket){
 				if(scarf >= 1 && vest >= 1 && jacket >= 1){
 					s2++;
 					scarf--;
 					vest--;
 					jacket--;
		 		}
			}
		while(jacket&&tie){
		 	if(jacket >= 1 && tie >= 1){
		 		s1++;
		 		jacket--;
		 		tie--;
				}
			}
		}
		else{
			while(jacket&&tie){
		 		if(jacket >= 1 && tie >= 1){
		 			s1++;
		 			jacket--;
		 			tie--;
				}
			}
			while(scarf&&vest&&jacket){
 				if(scarf >= 1 && vest >= 1 && jacket >= 1){
 					s2++;
 					scarf--;
 					vest--;
 					jacket--;
				}
			}
		}
	long long total = s1*n1 + s2*n2;
	printf("%lld", total);

    return 0;
}

#include<stdio.h>
int main()
{
    long long int sum1=0,sum2=0;
    int a,b,c,d,e,f,min=10000000;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    if(e<f)
    {
        if(b<min)
            min = b;
        if(c<min)
            min = c;
        if(d<min)
            min =d;
        sum2 = min*f;
        if(d>min)
        {
            d = d-min;
            if(a>d)
                sum1 = d*e;
            else
                sum1 = a*e;
        }
    }
    else
    {
        min=10000000;
        if(a>d) {
            sum1 = d*e;
            d = 0;
        }
        else {
            sum1 = a*e;
            d = d-a;
        }
        if(b<min)
            min = b;
        if(c<min)
            min = c;
        if(d<min)
            min =d;
        sum2 = min*f;
    }
    printf("%lld\n",sum1+sum2);

    return 0;
}

#include <stdio.h>

int main(){

    int a, b, c, d, e, f;
    int counte =0 , countf = 0;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    // a-d||e
    // b-c-d||f

    if(f > e){
    	while(1){
    		if(b > 0 && c > 0 && d > 0){
    			countf++;
    			b-=1;
    			c-=1;
    			d-=1;
			}
			else{
				break;
			}
		}
		while(1){
    		if(a > 0 && d > 0){
    			counte++;
    			a-=1;
    			d-=1;
			}
			else{
				break;
			}
		}
	}

	else{
		while(1){
    		if(a > 0 && d > 0){
    			counte++;
    			a-=1;
    			d-=1;
			}
			else{
				break;
			}
		}

		while(1){
    		if(b > 0 && c > 0 && d > 0){
    			countf++;
    			b-=1;
    			c-=1;
    			d-=1;
			}
			else{
				break;
			}
		}
	}

    int ans = counte*e + countf*f;
	printf("%d\n", ans);

    return 0;
}

#include <stdio.h>
#include <string.h>

int main(){
    int w0=0,w1=0,w2=0;
    int ntie=0,njacket=0,nscar=0,nvest=0;
    scanf("%d%d%d%d%d%d",&ntie,&nscar,&nvest,&njacket,&w1,&w2);
    if (w1>=w2) {
        if (njacket>=ntie) {
            w0=w1*ntie;
        }else{
            w0=w1*njacket;
        }
    }else{
        if (njacket<=nvest&&njacket<=nscar) {
            w0=w2*njacket;
        }
        if (njacket>=nvest&&nvest<=nscar) {
            if (ntie<=njacket-nvest) {
                w0=w1*ntie+w2*nvest;
            }else{
                w0=w1*(njacket-nvest)+w2*nvest;
            }
        }
        if (njacket>=nscar&&nvest>=nscar) {
            if (ntie<=njacket-nscar) {
                w0=w1*ntie+w2*nscar;
            }else{
                w0=w1*(njacket-nscar)+w2*nscar;
            }

        }
    }
    printf("%d\n",w0);
    return 0;
}

#include <stdio.h>

int main() {

	int i, index, index2, suit1Cost, suit2Cost, remainder, total=0;
	unsigned int clothes[4];
	unsigned int smallest = 100001;

	scanf("%d", &clothes[0]);
	scanf("%d", &clothes[1]);
	scanf("%d", &clothes[2]);
	scanf("%d", &clothes[3]);
	scanf("%d", &suit1Cost);
	scanf("%d", &suit2Cost);

	for (i = 0; i < 4; i++) {
		if (clothes[i] < smallest) {
			smallest = clothes[i];
			index = i;
		}
	}

	if (suit1Cost < suit2Cost) {
		if (index == 0) {
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}
			if (index == 3) {
				total = clothes[index] * suit2Cost;
			}
			else {
				remainder = clothes[3] - smallest;
				if (remainder <= clothes[0]) {
					total = ((smallest)*suit2Cost) + (remainder * suit1Cost);
				}
				else {
					total = ((smallest)*suit2Cost) + (clothes[0] * suit1Cost);
				}
			}
		}
		else if (index == 3) {
			total = clothes[index] * suit2Cost;
		}
		else {
			remainder = clothes[3] - smallest;
			if (remainder > 0) {
				total = smallest * suit2Cost;
				if (remainder <= clothes[0]) {
					total += remainder * suit1Cost;
				}
				else {
					total += clothes[0] * suit1Cost;
				}
			}
			else {
				total = clothes[3] * suit2Cost;
			}
		}
	}
	else if (suit1Cost > suit2Cost) {
		remainder = clothes[3] - clothes[0];
		if (index == 0) {
			total = clothes[0] * suit1Cost;
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}

			if (remainder <= smallest) {
				total += remainder * suit2Cost;
			}
			else {
				total += smallest * suit2Cost;
			}
		}
		else if (index == 3) {
			total = clothes[3] * suit1Cost;
		}
		else {
			if (remainder > 0) {
				total = clothes[0] * suit1Cost;
				if (remainder <= smallest) {
					total += remainder * suit2Cost;
				}
				else {
					total += smallest * suit2Cost;
				}
			}
			else {
				total = clothes[3] * suit1Cost;
			}
		}
	}

	printf("%d", total);

	return 0;
}

#include <stdio.h>

int main()
{
    int a,b,c,d,e,f,set1,set2,total,p,min;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
        if(a>=d)
        set1=d;
        else
        set1=a;
        d=d-set1;
        min=b;
        if(min>c)
        min=c;
        else if(min>d)
        min=d;
        p=set1*e+min*f;
        printf("%d",p);
    }
    else if(f>=e)
    {
      min=b;
        if(min>c)
        min=c;
        else if(min>d)
        min=d;
        d=d-min;
        if(a>=d)
        set1=d;
        else
        set1=a;
        p=set1*e+min*f;
        printf("%d",p);

    }

    return 0;
}

#include <stdio.h>

int min3(int a, int b, int c){
	int min;
	if(a < b){
		if(c < a)
			min = c;
		else
			min = a;
	}
	else{
		if(c < b)
			min = c;
		else
			min = b;
	}
	return min;
}

int min2(int a, int b){
	int min;
	if(a < b)
		min = a;
	else
		min = b;
	return min;

}

int main(){
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	int res;
	if(e < f){
		res = min3(b, c, d) * f + min2(d - min3(b, c, d), a) * e;
	}
	else{
		res = min2(a, d) * e + min3(b, c, d - min2(a, d)) * e;
	}
	printf("%d", res);
	return 0;
}

#include<stdio.h>
int main()
{
	int arr[4],a[2],b[3],e,f;
	int amin,bmin,cost1,cost2,cost3,cost4,cost5,cost6,i;
	for(i=0;i<4;i++)
	{
		scanf("%d",&arr[i]);
	}
	scanf("%d%d",&e,&f);
	a[0] = arr[0];a[1] = arr[3];
	b[0] = arr[1];b[1] = arr[2];b[2] = arr[3];
	amin = a[0];
	for(i=0;i<2;i++)
	{
		if(a[i]<amin)
			amin = a[i];
	}
	bmin = b[0];
	for(i=0;i<3;i++)
	{
		if(b[i]<bmin)
			bmin = b[i];
	}
	cost1 = amin * e;
	if((b[3]-amin) > bmin)
		cost2 = bmin*f;
	else
		cost2 = (b[2]-amin) * f;
	cost3 = bmin * f;
	if((a[2]-bmin) > amin)
		cost4 = amin * e;
	else
		cost4 = (a[1]-bmin) * e;

	cost5 = cost1 + cost2;
	cost6 = cost3 + cost4;
	if(cost5 >= cost6)
		printf("%d\n",cost5);
	else
		printf("%d\n",cost6);
	return 0;
}

#include<stdio.h>
unsigned int min(unsigned int a,unsigned int b) {
    if(a<b)
        return a;
    else
        return b;
}
int main() {
    unsigned int a,b,c,d,e,f,cost,m;
    scanf("%u %u %u %u %u %u",&a,&b,&c,&d,&e,&f);
    if ( f>e ) {
        m=min(min(b,c),d);
        cost=m*f+min(a,d-m)*e;
        printf("%u",cost);
    }
    else {
        m=min(a,d);
        cost=m*e+min(min(a,b),d-m)*f;
        printf("%u",cost);
    }
    return 0;
}

#include<stdio.h>
int main()
{
	int a,b,c,d,e,f,min2;
	scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

	if(b <= c && b <= d)
	{
		min2 = b;
	}
	else if(c <= d && c <= b)
	{
		min2 = c;
	}
	else{
		min2 = d;
	}
	d -= min2;
	int min1 = (a < d) ? a : d;
	if(min1 < 0)
	{
		min1 *= -1;
	}
	min2 *= f;
	min1 *= e;
	printf("%d",min1+min2);
	return 0;

}

#include<stdio.h>
long int min3(long int a,long int b,long int c)
{
  return (a>b&&a>c)?a:(b>c&&b>a)?b:c;
}
long int min2(long int a,long int b)
{
  return (a>b)?a:b;
}
int main()
{
  long int t,s,v,j,first,second,cost=0;
  scanf("%ld\n%ld\n%ld\n%ld\n%ld\n%ld",&t,&s,&v,&j,&first,&second);
  if(first<second)
  {
    cost+=second*min3(s,v,j);
    j-=min3(s,v,j);
    cost+=first*min2(t,j);
  }
  else
  {
    cost+=first*min2(t,j);
    j-=min2(t,j);
    cost+=second*min3(s,v,j);
  }
  printf("%ld",cost);
  return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,s,t=0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    if(e>f){
        if(a<d){
           s=e*a;
        }
        else{
            s=e*d;
            printf("%d",s);
            return 0;
        }
        d=d-a;
        if(b<c)
        {
           if(b<d){
            t=f*b;
           }
           else{
            t=f*d;
           }
        }
        else
        {
              if(c<d){
            t=f*c;
           }
           else{
            t=f*d;
           }
        }
    }
    //allahu akbar
    else{

        if(b<c)
        {
             if(d<c){
                s=f*d;
                printf("%d",s);
                return 0;
            }
            s=f*b;
            d=d-b;
            if(a<d){
                t=e*a;
            }
            else{
                t=e*d;
            }
        }
        else
        {
             if(d<c){
                s=f*d;
                printf("%d",s);
                return 0;
            }
            s=f*c;
            d=d-c;
              if(a<d){
                t=e*a;
            }
            else{
                t=e*d;
            }

        }
    }
    printf("%d",s+t);
    return 0;
}

#include<stdio.h>
int main()
{
    long long int sum1=0,sum2=0;
    int a,b,c,d,e,f,min=10000000;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

    if(b<min)
        min = b;
    if(c<min)
        min = c;
    if(d<min)
        min =d;
    sum2 = min*f;
    if(d>min)
    {
        d = d-min;
        if(a>d)
            sum1 = d*e;
        else
            sum1 = a*e;
    }
    printf("%lld\n",sum1+sum2);

    return 0;
}

#include<stdio.h>
int main()
{
    int t, h, m, min=1440;
    int time, x;
    scanf("%d",&t);
    {
        while(t!=0)
        {
            scanf("%d %d",&h,&m);
            time = h*60 + m;
            if(time!=min)
            x = min-time;
            else
            break;
            printf("%d\n",x);
            t--;
        }
    }
}

#include <stdio.h>
#include <string.h>

int min(int value1, int value2);

int main()
{
	int a, b, c, d, e, f = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);
	scanf("%d", &f);

	int max = 0;

	if (e > f)
	{
		max = (min(a, d)) * e + min(b, min(c, d - (min(a, d))));
	}
	else
	{
		max = (min(b, min(c, d))) * f + min(a, d - (min(b, min(c, d)))) * e;
	}

	printf("%d", max);

	return 0;
}

int min (int value1, int value2)
{
	if (value1 < value2)
	{
		return value1;
	}
	else
	{
		return value2;
	}
}

#include <stdio.h>

int min(int a, int b)
{
    if(a < b) return a;
    else return b;
}

int main()
{
    int a, b, c, d, e, f, g, x, y;
    long long max;

    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);

    if(f > e)
    {
        g = d - min(b, c);
        if((d - g) == min(b, c)){

            x = min(a, g);
            y = min(min(b, c), d - g);
        } else {
            x = 0;
            y = min(min(b, c), d);
        }
    }
    else if(f < e)
    {
        if(d >= a)
        {
            g = a;
            x = a;
            y = min(min(b, c), d - g);
        }
        else
        {
            g = d;
            x = min(a, d);
            y = 0;
        }
    }
    else
    {
        g = 0;
        x = 0;
        y = min(min(b, c), d-g);
    }

    max = x * e + y * f;

    printf("\n%lld", max);
}

#include <stdio.h>
#define INPUT 6

int main(){

    int input[INPUT];
    int price = 0;
    int max_type2=0;

    for(int i =0; i<INPUT; i++){

        scanf("%i", &input[i]);
    }

    if(input[1]>0 && input[2]>0 && input[3>0]){
        if(input[1]>input[2]){
            max_type2 = input[2];
        }
        else if(input[1]<input[2]){

             max_type2 = input[1];
        }
        else{
            max_type2 = input[1];
        }

        if(max_type2> input[3]){
            price = input[3] * input[5];
        }
        else{
            price = max_type2 * input[5];
            input[3] = input[3] - max_type2;
        }
    }

    if(input[0]>0 && input[3]>0){

        if(input[0]> input[3]){

            price = price+(input[3] * input[4]);
        }
        else{

            price = price+(input[0]*input[4]);
        }
    }

    printf("%i\n", price);
}

#include<stdio.h>
int main()
{
	int arr[4],a[2],b[3],e,f;
	int amin,bmin,cost1,cost2,cost3,cost4,cost5,cost6,i;
	for(i=0;i<4;i++)
	{
		scanf("%d",&arr[i]);
	}
	scanf("%d%d",&e,&f);
	a[0] = arr[0];a[1] = arr[3];
	b[0] = arr[1];b[1] = arr[2];b[2] = arr[2];
	amin = a[0];
	for(i=0;i<2;i++)
	{
		if(a[i]<amin)
			amin = a[i];
	}
	bmin = b[0];
	for(i=0;i<3;i++)
	{
		if(b[i]<bmin)
			bmin = b[i];
	}
	cost1 = amin * e;
	if((b[3]-amin) > bmin)
		cost2 = bmin*f;
	else
		cost2 = (b[2]-amin) * f;
	cost3 = bmin * f;
	if((a[2]-bmin) > amin)
		cost4 = amin * e;
	else
		cost4 = (a[1]-bmin) * e;

	cost5 = cost1 + cost2;
	cost6 = cost3 + cost4;
	if(cost5 >= cost6)
		printf("%d\n",cost5);
	else
		printf("%d\n",cost6);
	return 0;
}

#include <stdio.h>

int main()
{
  int a, b, c, d, e, f, min1, min2, cost;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
  if (e >= f)
  {
    min1 = a < d? a : d;
    d = d - min1;
    if (b <= c)
    {
      if (b <= d)
        min2 = b;
      else
        min2 = d;
    }
    else
      min2 = c;
    //printf("%d__%d\n",min1,min2);
    cost = min1*e + min2*f;
  }
  else
  {
    if (b <= c)
    {
      if (b <= d)
        min2 = b;
      else
        min2 = d;
    }
    else
      min2 = c;
    d = d - min2;
    min1 = a < d? a : d;
    //printf("%d__%d\n",min1,min2);
    cost = min1*e + min2*f;
  }
  printf("%d",cost);
  return 0;
}

#include <stdio.h>
int smaller(int a,int b ,int c)
{
    int temp =0;
    if(a <= b && a <= c)
        temp= a;
    else if(b <= c && b <= a)
        temp= b;
    else if (c <= a && b <= b)
        temp= c;

    return temp;

}
int main()
{
    int t,s,v,j,s1,s2;
    scanf("%d %d %d %d %d %d",&t,&s,&v,&j,&s1,&s2);
    int cost1=0, cost2=0;
    if(t<s1)
    cost1=t*s1;
    else
        cost1=j*s1;
    t=smaller(s,v,j);
    cost2=  t*s2;
   // printf("%d   %d",cost1,cost2);
    if(cost1 > cost2)
        printf("%d",cost1);
    else
        printf("%d",cost2);
    return 0;

}

#include <stdio.h>

int main(){

    int a, b, c, d, e, f;
    int counte =0 , countf = 0;
    scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    // a-d||e
    // b-c-d||f

    while(1){
    	if(b > 0 && c > 0 && d > 0){
    		countf++;
    		b-=1;
    		c-=1;
    		d-=1;
		}
		else{
			break;
		}
	}

    while(1){
    	if(a > 0 && d > 0){
    		counte++;
    		a-=1;
    		d-=1;
		}
		else{
			break;
		}
	}

    int ans = counte*e + countf*f;
	printf("%d\n", ans);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

int min(int a, int b)
{
    if(a < b) return a;
    else return b;
}

int main()
{
    int a, b, c, d, e, f, g, x, y;
    long long max, max_1, max_2;

    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    if(e == f)
    {
        max_1 = min(min(b, c), d) * f;

        if(d - min(b, c)  >=  a)
            g = d - min(b, c);
        max_2 = min(a, g) * e + min(min(b, c) , d-g) * f;

        if(max_1 > max_2)
            max = max_1;
        else
            max = max_2;

        printf("\n%d", max);
        exit(0);
    }

    if(f > e)
    {
        g = d - min(b, c);
        if((d - g) == min(b, c)){

            x = min(a, g);
            y = min(min(b, c), d - g);
        } else {
            x = 0;
            y = min(min(b, c), d);
        }
    }
    else if(f < e)
    {
        if(d >= a)
        {
            g = a;
            x = a;
            y = min(min(b, c), d - g);
        }
        else
        {
            g = d;
            x = min(a, d);
            y = 0;
        }
    }

    max = x * e + y * f;

    printf("\n%lld", max);
}

#include<stdio.h>
long int min3(long int a,long int b,long int c)
{
  return (a<b&&a<c)?a:(b<c&&b<a)?b:c;
}
long int min2(long int a,long int b)
{
  return (a<b)?a:b;
}
int main()
{
  long int t,s,v,j,first,second,cost=0;
  scanf("%ld\n%ld\n%ld\n%ld\n%ld\n%ld",&t,&s,&v,&j,&first,&second);
  if(first<second)
  {
    cost+=second*min3(s,v,j);
    j-=min3(s,v,j);
    cost+=first*min2(t,j);
  }
  else
  {
    cost+=first*min2(t,j);
    j-=min2(t,j);
    cost+=second*min3(s,v,j);
  }
  printf("%ld",cost);
  return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

int min(int a,int b)
{
    if(a>b)
    return b;
    else
    return a;
}
int main()
{
   int a,b,c,d,e,f;
   scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
   if(e>f)
   {
     d-=min(a,d);
     int j= min(b,min(c,d));
     int g=  e*min(a,d) + f*j;
     printf("%d",g);
   }
   else
   {
        int j=min(b,min(c,d));
         d-=j;
         int g= e*min(a,d)+ f*j;
         printf("%d",g);
   }
    return 0;
}

#include <stdio.h>

int main() {

	int i, index, index2, suit1Cost, suit2Cost, remainder, total=0;
	unsigned int clothes[4];
	unsigned int smallest = 100001;

	scanf("%d", &clothes[0]);
	scanf("%d", &clothes[1]);
	scanf("%d", &clothes[2]);
	scanf("%d", &clothes[3]);
	scanf("%d", &suit1Cost);
	scanf("%d", &suit2Cost);

	for (i = 0; i < 4; i++) {
		if (clothes[i] < smallest) {
			smallest = clothes[i];
			index = i;
		}
	}

	if (suit1Cost < suit2Cost) {
		if (index == 0) {
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}
			if (index == 3) {
				total = clothes[index] * suit2Cost;
			}
			else {
				remainder = clothes[3] - smallest;
				if (remainder <= clothes[0]) {
					total = ((smallest)*suit1Cost) + (remainder * suit2Cost);
				}
				else {
					total = ((smallest)*suit1Cost) + (clothes[0] * suit2Cost);
				}
			}
		}
		else if (index == 3) {
			total = clothes[index] * suit2Cost;
		}
		else {
			remainder = clothes[3] - smallest;
			total = ((smallest)*suit2Cost) + (remainder * suit1Cost);
		}
	}
	else if (suit1Cost > suit2Cost) {
		remainder = clothes[3] - clothes[0];
		if (index == 0) {
			total = clothes[0] * suit1Cost;
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}

			if (remainder <= smallest) {
				total += remainder * suit2Cost;
			}
			else {
				total += smallest * suit2Cost;
			}
		}
		else if (index == 3) {
			total = clothes[3] * suit1Cost;
		}
		else {
			total = clothes[0] * suit1Cost;
			if (remainder <= smallest) {
				total += remainder * suit2Cost;
			}
			else {
				total += smallest * suit2Cost;
			}
		}
	}

	printf("%d", total);

	return 0;
}

#include<stdio.h>
int min(int x,int y,int z)
{

    int c = 0;
    while (x && y && z) {
        x--;
        y--;
        z--;
        c++;
    }
    return c;
}
int main()
{
    int a,b,c,d,e,f,price=0,m;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
        if(a<d)
        {
            price=a*e;
            d-=a;
            m=min(b,c,d);
            price+=m*f;

        }
        else
        {
            price=a*d;
            d=0;
        }
    }
    else
    {
        m=min(b,c,d);
        price=m*f;
        d-=m;
        if(a>d)
            price+=d*e;
        else
            price+=a*e;
    }
    printf("%d\n",price);
}

#include<stdio.h>
int min(int,int,int);

int main(){
    int t,s,v,j,cf,cs,total = 0;
    int min1,min2,max1;
    scanf("%d %d %d %d %d %d",&t,&s,&v,&j,&cf,&cs);
    max1 = ( cf >= cs ? cf : cs );
    if(max1 == cs){
       if(s > 0 && v > 0 && j > 0){
           min1 = min(s,v,j);
           total = total + ( cs * min1 ) ;
           s = s - min1;
           v = v - min1;
           j = j - min1;
           }
        if(t > 0 && j > 0){

            min2 = (t < j ? t : j);

                total = total + cf * min2;

        }
    }
    else{

        if(t > 0 && j > 0){

            min2 = (t < j ? t : j);

                total = total + cf * min2;

        }
        if(s > 0 && v > 0 && j > 0){
           min1 = min(s,v,j);
           total = total + ( cs * min1 ) ;
           s = s - min1;
           v = v - min1;
           j = j - min1;
           }
    }
    printf("\n\n%d\n",total);
    return 0;
}

int min(int s, int v, int j){
    int min1;
    min1 = (s < v ? (s < j ? s : j ) : ( v < j ? v : j));
    return min1;
}

#include<stdio.h>
int min1(long int x,long int y)
{
    if(x<y)
    return x ;
    else
    {
        return y ;
    }

}
int min(long int x,long int y,long int z)
{
    if(x<=y && x<=z)
    return x ;
    else if(y<=z)
    return y ;
    else
    return z ;
}
int main()
{
    long int a,b,c,d,e,f,cost ;
    scanf("%ld %ld %ld %ld %ld %ld",&a,&b,&c,&d,&e,&f) ;

    if(e>=f)
    {
        cost = min1(a,d)*e + (d - min1(a,d))*f ;
    }
    else
    {
        cost = min(b,c,d)*f  + (d - min(b,c,d))*e ;
    }

    printf("%d\n",cost) ;

    return 0 ;

}

#include<stdio.h>
#include<string.h>
int main()
{
int a,b,c,d,e,f,x,y,z;
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);
scanf("%d",&d);
scanf("%d",&e);
scanf("%d",&f);

if(b<c)
x=b;
else
x=c;

if(f>=e){
    if(x>d)
        printf("%d\n",d*f);
    else if(x<d){
        if(d-x<=a)
            printf("%d\n",f*x+e*(d-x));
        else
            printf("%d\n",f*x+e*a);
        }
    }
else {
if(a>d)
    printf("%d\n",d*e);
else if (a<d){
    if(d-a<=x)
        printf("%d\n",e*a+f*(d-a));
    else
        printf("%d\n",e*a+f*x);
        }

    }
}

#include<stdio.h>
int main()
{
int a,b,c,d,e,f,s,x;
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
x=b;
if(x>c)
x=c;
if(x>d)
x=d;

d=d-x;
if(d>a)
s=e*a;
if(a>d||a==d)
s=e*d;

x=x*f;

printf("%d\n",s+x);

return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,min,min2,s1,s2,s;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    if(a<b&&a<c){min=a;}
    else if(b<a&&b<c){min=b;}
    else{min=c;}
    if(min>d){if(e>f){s=d*e;}
              else{s=d*f;}
    }
    else{
        if(min==a){s1=min*e;s2=(d-min)*f;}
        else{s1=min*f;s2=(d-min)*e;}
        s=s1+s2;
    }
    printf("%d",s);

}

#include<stdio.h>
int main()
{
int a,b,c,d,e,f,s,x;
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
x=b;
if(x>c)
x=c;
if(x>d)
x=d;

if(f>e)
{
d=d-x;
x=x*f;
if(d>a)
{
s=e*a;
}
if(a>d||a==d)
{
s=e*d;
}
}
if(e>f||e==f)
{
 if(a<d)
 {
     s=e*a;
     d=d-a;
 }
    if(d<a)
    {
        s=e*d;
        d=0;
    }

    if(x>d)
        x=d;

    x=x*f;

}

printf("%d\n",s+x);

return 0;
}

#include <stdio.h>

int main()
{
  int a, b, c, d, e, f, min1, min2, cost;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
  if (e >= f)
  {
    min1 = a < d? a : d;
    d = d - min1;
    if (b < c)
    {
      if (b < d)
        min2 = b;
      else
        min2 = d;
    }
    else
      min2 = c;
    //printf("%d__%d\n",min1,min2);
    cost = min1*e + min2*f;
  }
  else
  {
    if (b < c)
    {
      if (b < d)
        min2 = b;
      else
        min2 = d;
    }
    else
      min2 = c;
    d = d - min2;
    min1 = a < d? a : d;
   // printf("%d__%d\n",min1,min2);
    cost = min1*e + min2*f;
  }
  printf("%d",cost);
  return 0;
}

#include <stdio.h>
int smaller (int a,int b,int c)
{
    int temp=0;
    if(a<=b&&a<=c)
    temp=a;
    else if(b<=c&&b<=a )
        temp=b;
    else if(c<=a&&c<=b)
        temp=c;
        return temp;
};
int func1(int a,int b,int c,int d,int e,int f)
{
    int cost1,cost2;
    if(a<d)
    {cost1=a*e;
    d=d-a;}
    else
    {
        cost1=d*e;
        a=a-d;
        }
    cost2=(smaller(b,c,d))*f;
    return (cost1+cost2);

};
int func2(int a,int b, int c ,int d, int e,int f)
{
   int  t=smaller(b,c,d);
   int cost1,cost2=f*t;
   d=d-t;
   if(a<d)
   {
       cost1=a*e;
       }
   else
    cost1=d*e;

  int cost3=cost1+cost2;
  return cost3;

};
int main()
{
    int a,b,c,d,e,f,cost1,cost2;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    int t=func1(a,b,c,d,e,f);
    int s=func2(a,b,c,d,e,f);
    if(t<s)
    printf("%d",s);
    else
        printf("%d",t);
    return 0;

}

#include<stdio.h>
int main()
{
int a,b,c,d,e,f,s,x;
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
x=b;
if(x>c)
x=c;
if(x>d)
x=d;

if(f>e)
{
d=d-x;
x=x*f;
if(d>a)
{
s=e*a;
}
if(a>d||a==d)
{
s=e*d;
}
}
if(e>f||e==f)
{
 if(a<d)
 {
     s=e*a;
     d=d-a;
 }
    if(d<a||d==a)
    {
        s=e*d;
        d=0;
    }

    if(x>d)
        x=d;

    x=x*f;

}

printf("%d\n",s+x);

return 0;
}

#include<stdio.h>

int min1(int a, int b, int c){
	int minn=a;
	if(minn>b){
		minn=b;
	}
	if(minn>c){
		minn=c;
	}
	return minn;
}
int min2(int a, int b){
	int minn=a;
	if(minn>b){
		minn=b;
	}
	return minn;
}
int main(){
	int a,b,c,d,e,f;//a=ties, b=scarf, c=vest, d=jacket
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	int total=0;
	if(f>e){
		int n=min1(b,c,d);
		total=total+(n*f);
		b-=n;
		c-=n;
		d-=n;
	}

		int n=min2(a,d);
		total=total+(n*e);
		a-=n;
		d-=n;

	printf("%d\n", total);
	return 0;
}

#include<stdio.h>
int main()
{
    int a,b,c,d,e,f,g=0,count=0,min=0;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    min=a;
    if(b<min){
        min=b;
    }
    if(c<min){
        min=c;
    }
    if(d<min){
        min=d;
    }

    count=min*f;
    g=d-min;
    if(g>0){
        count+=g*e;
    }

    printf("%d\n", count);
    return 0;
}

#include<stdio.h>
#include<math.h>
int main()
{   int a,b,c,d,e,f,min,p;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);

    if(e>f)
    {
        if(a>d)
            p=d*e;
        else
        {
            d=d-a;
            min=b<c?(c<d?c:d):(b<d?b:c);
            if(d>min)
                p=a*e+min*f;
            else
                p=a*e+d*f;
        }

    }
    else
    {min=b<c?(b<d?b:d):(c<d?c:d);
    if(min>d)
        p=d*f;
    else
    {
        d=d-min;
        if(a>d)
            p=min*f+d*e;
        else
            p=min*f+a*e;
    }

    }printf("%d",p);

}

#include <stdio.h>

int main()
{
    int a,b,c,d,e,f,set1,set2,total,p,min;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
        if(a>=d)
        set1=d;
        else
        set1=a;
        d=d-set1;
        min=b;
        if(min>c)
        min=c;
        else if(min>d)
        min=d;
        p=set1*e+min*f;
        printf("%d",p);
    }
    else if(f>=e)
    {
      min=b;
        if(min>c)
        min=c;
        else if(min>d)
        min=d;
        d=d-min;
        if(a>=d)
        set1=d;
        else
        set1=a;
        p=set1*e+min*f;
        printf("%d",p);

    }

    return 0;
}

#include<stdio.h>
int min(int,int,int);

int main(){
    int t,s,v,j,cf,cs,total = 0;
    int min1,min2,max1;
    scanf("%d %d %d %d %d %d",&t,&s,&v,&j,&cf,&cs);
    max1 = ( cf >= cs ? cf : cs );
    if(max1 == cs){
       if(s > 0 && v > 0 && j > 0){
           min1 = min(s,v,j);
           total = total + ( cs * min1 ) ;
           s = s - min1;
           v = v - min1;
           j = j - min1;
           }
        if(t > 0 && j > 0){

            min2 = (t < j ? t : j);

                total = total + (cf * min2);

        }
    }
    else{

        if(t > 0 && j > 0){

            min2 = (t < j ? t : j);

                total = total + (cf * min2);

        }
        if(s > 0 && v > 0 && j > 0){
           min1 = min(s,v,j);
           total = total + ( cs * min1 ) ;
           s = s - min1;
           v = v - min1;
           j = j - min1;
           }
    }
    printf("\n\n%d\n",total);
    return 0;
}

int min(int s, int v, int j){
    int min1;
    min1 = (s < v ? (s < j ? s : j ) : ( v < j ? v : j));
    return min1;
}

#include <stdio.h>

int min(int value1, int value2);

int main()
{
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
	scanf("%d ", &a);
	scanf("%d ", &b);
	scanf("%d ", &c);
	scanf("%d ", &d);
	scanf("%d ", &e);
	scanf("%d ", &f);

	int max = 0;
	int x = 0;

	if (e > f)
	{
		x = min(a, d);
		max = x * e + min(b, min(c, d - x));
	}
	else
	{
		x = min(b, min(c, d));
		max = x * f + min(a, d - x) * e;
	}

	printf("%d ", max);

	return 0;
}

int min (int value1, int value2)
{
	if (value1 < value2)
	{
		return value1;
	}
	else
	{
		return value2;
	}
}

#include <stdio.h>

int main() {

	int i, index, index2, suit1Cost, suit2Cost, remainder, total=0;
	unsigned int clothes[4];
	unsigned int smallest = 100001;

	scanf("%d", &clothes[0]);
	scanf("%d", &clothes[1]);
	scanf("%d", &clothes[2]);
	scanf("%d", &clothes[3]);
	scanf("%d", &suit1Cost);
	scanf("%d", &suit2Cost);

	for (i = 0; i < 4; i++) {
		if (clothes[i] < smallest) {
			smallest = clothes[i];
			index = i;
		}
	}

	if (suit1Cost < suit2Cost) {
		if (index == 0) {
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}
			if (index == 3) {
				total = clothes[index] * suit2Cost;
			}
			else {
				remainder = clothes[3] - smallest;
				if (remainder <= clothes[0]) {
					total = ((smallest)*suit1Cost) + (remainder * suit2Cost);
				}
				else {
					total = ((smallest)*suit1Cost) + (clothes[0] * suit2Cost);
				}
			}
		}
		else if (index == 3) {
			total = clothes[index] * suit2Cost;
		}
		else {
			remainder = clothes[3] - smallest;
			if (remainder > 0) {
				total = smallest * suit2Cost;
				if (remainder <= clothes[0]) {
					total += remainder * suit2Cost;
				}
				else {
					total += clothes[0] * suit2Cost;
				}
			}
			else {
				total = clothes[3] * suit2Cost;
			}
		}
	}
	else if (suit1Cost > suit2Cost) {
		remainder = clothes[3] - clothes[0];
		if (index == 0) {
			total = clothes[0] * suit1Cost;
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}

			if (remainder <= smallest) {
				total += remainder * suit2Cost;
			}
			else {
				total += smallest * suit2Cost;
			}
		}
		else if (index == 3) {
			total = clothes[3] * suit1Cost;
		}
		else {
			if (remainder > 0) {
				total = clothes[0] * suit1Cost;
				if (remainder <= smallest) {
					total += remainder * suit2Cost;
				}
				else {
					total += smallest * suit2Cost;
				}
			}
			else {
				total = clothes[3] * suit1Cost;
			}
		}
	}

	printf("%d", total);

	return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main()
{   int a,b,c,d,e,f,min;
    long k=0;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&e);
    scanf("%d",&f);
    if(e>=f) {
        min=fmin(a,d);
        k=e*fmin(a,d);
        d=d-min;
        a=a-min;
        printf("a = %d\n",a);
        printf("d =%d\n",d);
        if(d>0){
            min=fmin(b,c);
            min=fmin(min,d);
            k=k+f*min;}
    }
    else {
        min=fmin(b,c);
        min=fmin(min,d);
        k=f*min;
        b=b-min;
        c=c-min;
        d=d-min;
        if(d>0)
            k=k+e*fmin(a,d);
    }
    printf("%ld",k);
    return 0;
}

#include <stdio.h>
int smaller(int a,int b ,int c)
{
    int temp =0;
    if(a <= b && a <= c)
        temp= a;
    else if(b <= c && b <= a)
        temp= b;
    else if (c <= a && b <= b)
        temp= c;

    return temp;

}
int main()
{
    int t,s,v,j,s1,s2;
    scanf("%d %d %d %d %d %d",&t,&s,&v,&j,&s1,&s2);
    int cost1=0, cost2=0;
    if(t<s1)
    cost1=t*s1;
    else
        cost1=j*s1;
    t=smaller(s,v,j);
    cost2=  t*s2;
    printf("%d   %d",cost1,cost2);
    if(cost1 > cost2)
        printf("%d",cost1);
    else
        printf("%d",cost2);
    return 0;

}

#include <stdio.h>
int main()
{
    int a,b,c,d,e,f,i,j,k,x=0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
        if(a<=d)
        {
            x+=a*e;
            d-=a;
            if(b<=c&&b<=d)
                x+=b*f;
            else if(c<=b&&c<=d)
                x+=c*f;
            else
                x+=d*f;
        }
        else
        {
            x+=d*e;
        }
    }
    else
    {
        if(b<=c&&b<=d)
                x+=b*f+(d-b)*e;
        else if(c<=b&&c<=d)
                x+=c*f+(d-c)*e;
        else
                x+=d*f;
    }
    printf("%d",x);
    return 0;
}

#include <stdio.h>

int min3(int a, int b, int c){
	int min;
	if(a < b){
		if(c < a)
			min = c;
		else
			min = a;
	}
	else{
		if(c < b)
			min = c;
		else
			min = b;
	}
	return min;
}

int min2(int a, int b){
	int min;
	if(a < b)
		min = a;
	else
		min = b;
	return min;

}

int main(){
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	int res;
	if(e < f){
		res = min3(b, c, d) * f + min2(d - min3(b, c, d), a) * e;
	}
	else{
		res = min2(a, d) * e + min3(b, c, d - min2(a, d)) * e;
	}
	printf("%d", res);
	return 0;
}

#include<stdio.h>
int min(int,int,int);

int main(){
    long int t,s,v,j,cf,cs,total = 0;
    int min1,min2,max1;
    scanf("%ld %ld %ld %ld %ld %ld",&t,&s,&v,&j,&cf,&cs);
    max1 = ( cf >= cs ? cf : cs );
    if(max1 == cs){
       if(s > 0 && v > 0 && j > 0){
           min1 = min(s,v,j);
           total = total + ( cs * min1 ) ;
           s = s - min1;
           v = v - min1;
           j = j - min1;
           }
        if(t > 0 && j > 0){

            min2 = (t < j ? t : j);

                total = total + (cf * min2);

        }
    }
    else{

        if(t > 0 && j > 0){

            min2 = (t < j ? t : j);

                total = total + (cf * min2);

        }
        if(s > 0 && v > 0 && j > 0){
           min1 = min(s,v,j);
           total = total + ( cs * min1 ) ;
           s = s - min1;
           v = v - min1;
           j = j - min1;
           }
    }
    printf("\n\n%ld\n",total);
    return 0;
}

int min(int s, int v, int j){
    int min1;
    min1 = (s < v ? (s < j ? s : j ) : ( v < j ? v : j));
    return min1;
}

#include<stdio.h>
int main()
{

    int a,b,c,d,e,f,min,min2,taka1=0,taka2 =0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    min = a;
    if(a>d){
        min= d;
    }
    taka1 =  (min*e);
    d -= min;
    if(b>c && d>c){
        min2 = c;
    }
    else if(c>b && d>b){
        min2 = b;
    }
    else {
        min2 = d;
    }
    taka1 += (min2*f);
    d = d+min;
     if(b>c && d>c){
        min2 = c;
    }
    else if(c>b && d>b){
        min2 = b;
    }
    else if(b>d && a>d){
        min2 = d;
    }
    taka2 = (min2*f);
    d = d - min2;
    min = a;
    if(a>d){
        min= d;
    }
    taka2 = taka2 + (min*e);

    if(taka1>=taka2){
        printf("%d\n",taka1);
    }
    else
        printf("%d\n",taka2);

    return 0;
}

#include<stdio.h>
int main()
{
    int t, h, m, min=1440;
    int time, x;
    scanf("%d",&t);
    {
        while(t!=0)
        {
            scanf("%d %d",&h,&m);
            time = h*60 + m;
            if(time!=min)
            x = min-time;
            else
            break;
            printf("%d\n",x);
            t--;
        }
    }
}

#include <stdio.h>
#include <string.h>

int main(){
	int tie,scarf,vest,jacket;
	int n1, n2;
	int s1 = 0, s2 = 0;
 	scanf("%d %d %d %d %d %d", &tie,&scarf,&vest,&jacket,&n1,&n2);
 		if(n2 > n1){
 			while(scarf&&vest&&jacket){
 				if(scarf >= 1 && vest >= 1 && jacket >= 1){
 					s2++;
 					scarf--;
 					vest--;
 					jacket--;
		 		}
			}
		while(jacket&&tie){
		 	if(jacket >= 1 && tie >= 1){
		 		s1++;
		 		jacket--;
		 		tie--;
				}
			}
		}
		else if(n1 > n2){
			while(jacket&&tie){
		 		if(jacket >= 1 && tie >= 1){
		 			s1++;
		 			jacket--;
		 			tie--;
				}
			}
			while(scarf&&vest&&jacket){
 				if(scarf >= 1 && vest >= 1 && jacket >= 1){
 					s2++;
 					scarf--;
 					vest--;
 					jacket--;
				}
			}
		}
	long long total = s1*n1 + s2*n2;
	printf("%lld", total);

    return 0;
}

#include <stdio.h>

int min(int value1, int value2);

int main()
{
	int a = 0, b = 0, c = 0, d = 0, e = 0, f = 0;
	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);
	scanf("%d", &e);
	scanf("%d", &f);

	int max = 0;
	int x = 0;

	if (e > f)
	{
		x = min(a, d);
		max = x * e + min(b, min(c, d - x));
	}
	else
	{
		x = min(b, min(c, d));
		max = x * f + min(a, d - x) * e;
	}

	printf("%d", max);

	return 0;
}

int min (int value1, int value2)
{
	if (value1 < value2)
	{
		return value1;
	}
	else
	{
		return value2;
	}
}

#include<stdio.h>
long int min3(long int a,long int b,long int c)
{
  return (a>b&&a>c)?a:(b>c&&b>a)?b:c;
}
long int min2(long int a,long int b)
{
  return (a>b)?a:b;
}
int main()
{
  long int t,s,v,j,first,second,cost=0;
  scanf("%ld\n%ld\n%ld\n%ld\n%ld\n%ld",&t,&s,&v,&j,&first,&second);
  if(first<second)
  {
    cost+=second*min3(s,v,j);
    j-=min3(s,v,j);
    cost+=first*min2(t,j);
  }
  else
  {
    cost+=first*min2(t,j);
    j-=min2(t,j);
    cost+=second*min3(s,v,j);
  }
  printf("%ld",cost);
  return 0;
}

#include<stdio.h>
int main()
{
    long long int a,b,c,d;
    long long int e,f;
    long long int cost1=0,cost2=0;
        scanf("%lld %lld %lld %lld",&a,&b,&c,&d);
    scanf("%lld %lld",&e,&f);
    int min=0;
    if(a>=d)
    {
        cost1=d*e;
        if(d<=b && d<=c)
            cost2=d*f;
        else
        {
            if(b<=c)
                cost2=b*f+(d-b)*e;
            else
                cost2=c*f+(d-c)*e;
        }
    }
    else
    {
        cost1=a*e;
        if((d-a)<=b && (d-a)<=c)
            cost1+=(d-a)*f;
        else
        {
            if(b<=c)
                cost1+=b*f;
            else
                cost1+=c*f;
        }
        if(d<=b && d<=c)
            cost2=d*f;
        else
        {
            if(b<=c)
                cost2=b*f+(d-b)*e;
            else
                cost2=c*f+(d-c)*e;
        }
    }
    if(cost1>cost2)
        printf("%lld\n",cost1);
    else
        printf("%lld\n",cost2);
return 0;
}

#include<stdio.h>
int main()
{
    int  ties,scarves,vests,jackets,Type1Cost,Type2Cost;
    int cost1,cost2,minimum,maximum,MaxCost;
    scanf("%d %d %d %d %d %d",&ties,&scarves,&vests,&jackets,&Type1Cost,&Type2Cost);
    if(Type2Cost>Type1Cost)
    {
        if(scarves<vests &&scarves<jackets)
        {
            minimum=scarves;
            cost1=Type2Cost*scarves;
        }
        else if(vests<scarves&&vests<jackets)
        {
            minimum=vests;
            cost1=Type2Cost*vests;
        }
        else
        {
            minimum=jackets;
            cost1=Type2Cost*jackets;
        }
        cost2=(jackets-minimum)*Type1Cost;
        MaxCost=cost1+cost2;
        printf("%d\n",MaxCost);

    }
    else
    {
        if(ties>jackets)
        {
            cost2=jackets*Type1Cost;
            MaxCost=cost2;
        }
        else if(ties<jackets)
        {
            cost2=ties*Type1Cost;
            if(scarves>vests &&(jackets-ties)>vests)
            {
                MaxCost=cost2+(vests*Type2Cost);

            }
            else if(scarves<vests &&(jackets-ties)<scarves)
            {
                MaxCost=cost2+(scarves*Type2Cost);
            }
            else
            {
                MaxCost=cost2+(Type2Cost*(jackets-ties));
            }

        }
        else
        {
            MaxCost=ties*jackets;
        }
        printf("%d\n",MaxCost);

    }

    return 0;
}

#include<stdio.h>
int min(int a,int b,int c)
{
if(a<b)
{
if(a<c)
return a;
else
return c;
}
else
{
if(b<c)
return b;
else
return c;
}
}
int main()
{
    int a, b, c, d, e, f,y;
    long long cost=0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
    if(a>=d)
    cost=d*e;
    else
    {
    cost=a*e;
    d-=a;
    }
    y=min(b,c,d);
    cost+=y*f;
    }
    else
    {
    y=min(b,c,d);
    cost=y*f;
    d-=y;
    if(d>=a)
    cost+=a*e;
    else
    cost+=d*e;
    }
    printf("%lld",cost);
    return 0;
}

#include<stdio.h>
int min(int,int,int);

int main(){
    long int t,s,v,j,cf,cs,total = 0;
    int min1,min2,max1;
    scanf("%ld %ld %ld %ld %ld %ld",&t,&s,&v,&j,&cf,&cs);
    max1 = ( cf >= cs ? cf : cs );
    if(max1 == cs){
       if(s > 0 && v > 0 && j > 0 && cs > 0){
           min1 = min(s,v,j);
           total = total + ( cs * min1 ) ;
           s = s - min1;
           v = v - min1;
           j = j - min1;
           }
        if(t > 0 && j > 0  && cf > 0){

            min2 = (t < j ? t : j);

                total = total + (cf * min2);

        }
         printf("\n\n%ld\n",total);
    }
    else{

        if(t > 0 && j > 0 && cf > 0){

            min2 = (t < j ? t : j);

                total = total + (cf * min2);

        }
        if(s > 0 && v > 0 && j > 0 && cs > 0){
           min1 = min(s,v,j);
           total = total + ( cs * min1 ) ;
           s = s - min1;
           v = v - min1;
           j = j - min1;
           }
         printf("\n\n%ld\n",total);
    }

    return 0;
}

int min(int s, int v, int j){
    int min1;
    min1 = (s < v ? (s < j ? s : j ) : ( v < j ? v : j));
    return min1;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

int min(int a,int b)
{
    if(a>b)
    return b;
    else
    return a;
}
int main()
{
   int a,b,c,d,e,f;
   scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
   if(e>f)
   {
     d-=min(a,d);
     int j= min(b,min(c,d));
     int g=  e*min(a,d) + f*j;
     printf("%d",g);
   }
   else
   {
        int j=min(b,min(c,d));
         d-=j;
         int g= e*min(a,d)+ f*j;
         printf("%d",g);
   }
    return 0;
}

#include <stdio.h>
int main ()
{
    int a, b, c, d, e, f;

    scanf ("%d %d %d %d %d %d", &a,  &b,  &c,  &d,  &e,  &f);

    if (f >= e)
    {
        if (b < c && b < d)
        {
            d = d - b;
            if (d < a)
            {
                printf ("%d\n", (b*f)+(e*d));
            }
            else if (d >= a)
            {
                printf ("%d\n", (b*f)+(e*a));
            }
         }
        else if (c < d && c < b)
        {
            d = d - c;
            if (d < a)
            {
                printf ("%d\n", (c*f)+(e*d));
            }
            else if (d >= a)
                printf ("%d\n", (c*f)+(e*a));
            }
            else
            {
                 printf ("%d\n", (d*f));
             }
    }
    else
    {
        if (a > d)
            printf ("%d\n", d*e);
        else
        {
            d = d - a;
            if (d <= b && d <= c)
                printf ("%d\n", (d*f)+(a*e));
            else
                printf ("%d\n", a*e);
        }
    }
    return 0;
}

#include <stdio.h>
main()
{
    int a,b,c,d,e,f,cost;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    if(e>f)
    {
        if(d<a)
        {
            cost=d*e;
        }
        else
        {
            if((d-a)<b&&(d-a)<c)

                cost=a*e+(d-a)*f;
            else if(c<b)
                cost=a*e+(c)*f;

            else
                cost=a*e+(b)*f;

        }
    }
    else
    {
        if(d<b && d<c)
        {
            cost=d*f;
        }
        else
        {
            if(b<c)
                cost=b*f+(d-b)*e;
            else
                cost=c*f+(d-c)*e;
        }
    }

    printf("%d",cost);

}

#include<stdio.h>
int find_min(int b, int c, int d)
{
    if(b<=c && b<=d){
        return b;
    }
    if(c<=b && c<=d){
        return c;
    }
    else {
        return d;
    }
}
int main(void)
{
    int a,b,c,d,e,f;
    int max;
    int le;
    int max1;
    scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f);
    if(a>=d){
        max=d*e;
    }
    else{
        max=a*e;
    }
    max1=find_min(b,c,d)*f;
    if(find_min(b,c,d)!=d){
        le=d-find_min(b,c,d);
        if(le>a){
            max1+=a*e;
        }
        else{
            max1+=le*e;
        }
    }

    if(max>max1){
        printf("%d\n",max);
    }
    else{
        printf("%d\n",max1);
    }
}

#include <stdio.h>
int main(void)
{
	int n,t,s,v,j,e,f,c1=0,c2=0,cost;
	scanf("%d %d %d %d %d %d",&t,&s,&v,&j,&e,&f);
	(s>v)?(n=v):(n=s);
	if (j>=n)
	{
       	j-=n; c1=n*f;
	}
	else
	{
		n=j; j-=n; c1=n*f;
	}
	if(j>=t)
	{
		j-=t; c2=t*e;
	}
	else if(j!=0)
	{
		n=j; c2=n*e;
	}
	cost=c1+c2;
	printf("%d",cost);
	return 0;
}

#include <stdio.h>

int main(int argc, char const *argv[])
{
    long long a, b, c, d, e, f, max_e, max_f, tmp, total;

    scanf("%lld", &a);
    scanf("%lld", &b);
    scanf("%lld", &c);
    scanf("%lld", &d);
    scanf("%lld", &e);
    scanf("%lld", &f);

    max_e = a;
    max_f = b < c ? b : c;

    if (e > f) {
        tmp = max_f;
        max_f = max_e;
        max_e = tmp;

        tmp = f;
        f = e;
        e = tmp;
    }

    if (d > max_f) {
        total = max_f * f + (d - max_f) * e;
    } else {
        total = d * f;
    }

    printf("%lld\n", total);
    return 0;
}

#include<stdio.h>
int min(int num1,int num2,int num3);
int main()
{
	int t,s,v,j,e,f,l,p,q,sum;
	scanf("%d%d%d%d%d%d",&t,&s,&v,&j,&e,&f);
	if(e>f)
	{
	    if(j>t)
	   	 {
	   	    q=t*e;
	   	    j=j-t;
	   	    if(j>0)
	   	    {
	   	       l=min(s,v,j);
	           p=l*f;
			}

		 }
		 else
		 {
		 	q=j*e;
		 	p=0;

		 }
	}
	else if(f>e)
	{
	   l=min(s,v,j);
	   j=j-l;
	   p=l*f;
	   if(j>0)
	   {
	   	 if(j>t)
	   	 {
	   	 	q=t*e;
		 }
		 else
		 {
		 	q=j*e;
		 }
	   }
	   else
	   {
	   	q=0;
	   }
	}
	sum=p+q;
	printf("%d",sum);

}
int min(int num1,int num2,int num3)
{
	if(num1 < num2 && num1 < num3)
	{
		return num1;
	}
	else if(num2 < num3)
	{
		return num2;
	}
	else
	{
		return num3;
	}
}

#include<stdio.h>
#include<math.h>
int main(){
	long long s,st,st1,a,b,c,d,e,f;
	scanf("%lld%lld%lld%lld%lld%lld",&a,&b,&c,&d,&e,&f);
	st=fmin(fmin(c,d),b);
	if(st==d)
		printf("%lld\n",st*f);
	else{
		s=d-st;
		st1=fmin(s,a);
		printf("%lld\n",st*f+st1*e);
	}
	return 0;
}

#include<stdio.h>
int main()
{
    int  ties,scarves,vests,jackets,Type1Cost,Type2Cost;
    int cost1,cost2,minimum,maximum,MaxCost;
    scanf("%d %d %d %d %d %d",&ties,&scarves,&vests,&jackets,&Type1Cost,&Type2Cost);
    if(Type2Cost>Type1Cost)
    {
        if(scarves<vests &&scarves<jackets)
        {
            minimum=scarves;
            cost1=Type2Cost*scarves;
        }
        else if(vests<scarves&&vests<jackets)
        {
            minimum=vests;
            cost1=Type2Cost*vests;
        }
        else
        {
            minimum=jackets;
            cost1=Type2Cost*jackets;
        }
        int Remain;
        Remain=(jackets-minimum);
        if(ties>Remain)
        {
            cost2=Remain*Type1Cost;
        }
        else
        {
            cost2=ties*Type1Cost;
        }
        MaxCost=cost1+cost2;
        printf("%d\n",MaxCost);

    }
    else
    {
        if(ties>jackets)
        {
            cost2=jackets*Type1Cost;
            MaxCost=cost2;
        }
        else if(ties<jackets)
        {
            int RemainJacket;
            RemainJacket=(jackets-ties);
            cost2=ties*Type1Cost;
            if(scarves>vests &&RemainJacket>vests)
            {
                MaxCost=cost2+(vests*Type2Cost);

            }
            else if(scarves<vests &&RemainJacket>scarves)
            {
                MaxCost=cost2+(scarves*Type2Cost);
            }
            else
            {
                MaxCost=cost2+(Type2Cost*RemainJacket);
            }

        }
        else
        {
            MaxCost=ties*jackets;
        }
        printf("%d\n",MaxCost);

    }

    return 0;
}

#include <stdio.h>
#include <stdlib.h>

#define MIN(a, b) ((a) < (b)) ? (a) : (b)
#define MINN(a, b, c) (MIN((a), (b))) < c ? (MIN((a), (b))) : c

int a, b, c, d, e, f;
// costume type N:1 == a && d
// costume type N:2 == b && c && d
// e == price of costume N:1
// f == price of costume N:2

int costume_1 = 0;
int costume_2 = 0;

int main (void)
{
    int tmp;
    //printf ("Enter amount of your stuff: ");
    scanf ("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
    //printf ("Enter your price of the costumes: ");
    //scanf ("%d %d", &e, &f);
    costume_2 = MINN(b, c, d);
    tmp = MINN(b, c, d);
    if (b >= tmp)
        b -= tmp;
    if (c >= tmp)
        c -= tmp;
    if (d >= tmp)
        d -= tmp;
    costume_1 = MIN(a, d);
    printf ("%d", costume_1 * e + costume_2 * f);
    exit (0);
}

#include<stdio.h>

int main ()
{
    long long int t,s,v,j,i,e,f,min;
    long long int sum;

        scanf ("%lld%lld%lld%lld",&t,&s,&v,&j);
        scanf ("%lld%lld",&e,&f);
        if (e<f){
        min = s;
        if (min > v)
            min = v;
        if (min > j)
            min = j;
        j = j -min;
        sum = min*f;
        if (t>j)
            min = j;
        else min = t;
        sum = sum + min*e;
        printf ("%lld\n",sum);}
        else
        {
            min = t;
            if (j<min)
                min = j;
            j = j-min;
            sum = min*e;
            if (min > s)
                min = s;
            if (min > v)
                min = v;
            sum = sum + min*f;
            printf ("%lld\n",sum);
            }

    return 0;
}

#include<stdio.h>
int main()
{
	long long a,b,c,d,e,f,min2,min1;
	scanf("%lld %lld %lld %lld %lld %lld",&a,&b,&c,&d,&e,&f);
if(e < f)
{
	if(b <= c && b <= d)
	{
		min2 = b;
	}
	else if(c <= d && c <= b)
	{
		min2 = c;
	}
	else{
		min2 = d;
	}
	d -= min2;

	min1 = (a < d) ? a : d;
	if(min1 < 0)
	{
		min1 *= -1;
	}

	min2 *= f;
	min1 *= e;
	printf("%lld",min1+min2);
}
else{
	if(a <= d)
	{
		min1 = a;
	}
	else{
		min1 = d;
	}
	d -= min1;

	printf("%lld",min1*e);
}
	return 0;

}

#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a, b, c, d, e, f, sum, b1, c1;
    scanf("%d%d%d%d%d%d", &a, &b, &c, &d, &e, &f);
    if (b > c) {
        b1 = b;
        c1 = c;
    }
    else {
        b1 = c;
        c1 = b;
    }
    if (e > f) {
        if (a >= d)
            printf("%d\n", d * e);
        else {
            if (b > c) {
                if (d - a > c)
                    printf("%d\n", a * e + c * f);
                else
                    printf("%d\n", a * e + (d - a) * f);
            }
        }
    }
    else if (e == f) {
        if (a + c1 >= d)
            printf("%d\n", d * e);
        else
            printf("%d\n", a * e + c1 * f);
    }
    else {
        if (c1 >= d)
            printf("%d\n", d * f);
        else {
            if (d - c1 > a)
                printf("%d\n", c1 * f + a * e);
            else
                printf("%d", c1 * f + (d - c1) * e);
        }
    }
    return 0;
}

#include <stdio.h>
#include <stdlib.h>
int min(int a,int b,int c){
    int min = a;
    if(min>b){
        min = b;
    }
    if(min > c){
        min = c;
    }
    return min;
}int max(int a,int b,int c){
    int min = a;
    if(min<b){
        min = b;
    }
    if(min < c){
        min = c;
    }
    return min;
}
int main()
{
    int a,b,c,d;
    int e,f;
    int sum1 = 0;
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    int sum2= 0,sum3=0,sum4=0;
    int x;
    int maxaandd = a,minanda = d;
    if(a < d){
        maxaandd = d;
        minanda = a;
    }
        x = min(d,b,c);
        sum1+=x*f;
        sum1+= (d-x)*e;
        sum2+= maxaandd*e;
        sum3+= minanda*e;
        sum3+= (d - minanda)*f;
        sum4 +=max(d,b,c)*f;
        int z;
        printf("%d",max(sum1,sum2,sum3));
}

#include <stdio.h>

int main()
{
  int a, b, c, d, e, f, min1, min2, cost;
  scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
  if (e >= f)
  {
    min1 = a < d? a : d;
    d = d - min1;
    if (b <= c)
    {
      if (b <= d)
        min2 = b;
      else
        min2 = d;
    }
    else
      min2 = c;
    printf("%d__%d\n",min1,min2);
    cost = min1*e + min2*f;
  }
  else
  {
    if (b <= c)
    {
      if (b <= d)
        min2 = b;
      else
        min2 = d;
    }
    else
      min2 = c;
    d = d - min2;
    min1 = a < d? a : d;
    printf("%d__%d\n",min1,min2);
    cost = min1*e + min2*f;
  }
  printf("%d",cost);
  return 0;
}

#include<stdio.h>

int min(int a,int b)
{
	if(a > b)
		return b;
	else
		return a;

}
int max(int a,int b)
{
        if(a > b)
                return a;
        else
                return b;

}

int main()
{
	int a,b,c,d,e,f;

	scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);

	int p = min(a,d);
	int mn = min(b,c);
	int q = min(mn,d);

	mn = max(e*p,f*q);

	if( f > e)
	{
		if(p + q < d)
		{
			mn = max(mn, e*p + f*q);

		}

		else
		{
			while( q > 0)
			{
				if( q < d && d < p + q)
				{
					p = d-q;
					mn = max(mn, e*p + f*q);

				}

				q--;

			}

		}

	}

	else
	{
	if(p + q < d)
                {
                        mn = max(mn, e*p + f*q);

                }

                else
                {
                        while( p > 0)
                        {
                                if( p < d && d < p+q)
                                {
                                        q = d-p;
                                        mn = max(mn, e*p + f*q);

                                }

                                p--;

                        }

                }

	}
	printf("%d",mn);
	return 0;
}

#include <stdio.h>
int smaller(int a,int b ,int c)
{
    int temp =0;
    if(a <= b && a <= c)
        temp= a;
    else if(b <= c && b <= a)
        temp= b;
    else if (c <= a && b <= a)
        temp= c;

    return temp;

}
int main()
{
    int t,s,v,j,s1,s2;
    scanf("%d %d %d %d %d %d",&t,&s,&v,&j,&s1,&s2);
    int cost1=0, cost2=0;
    if(t<s1)
    cost1=t*s1;
    else
        cost1=j*s1;
    t=smaller(s,v,j);
    cost2=t*s2;
    if(cost1 > cost2)
        printf("%d",cost1);
    else
        printf("%d",cost2);
    return 0;

}

#include<stdio.h>

int min1(int a, int b, int c){
	int minn=a;
	if(minn>b){
		minn=b;
	}
	if(minn>c){
		minn=c;
	}
	return minn;
}
int min2(int a, int b){
	int minn=a;
	if(minn>b){
		minn=b;
	}
	return minn;
}
int main(){
	int a,b,c,d,e,f;//a=ties, b=scarf, c=vest, d=jacket
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	int total=0;
	if(f>e){
		int n=min1(b,c,d);
		total=total+(n*f);
		b-=n;
		c-=n;
		d-=n;
	}

		int n=min2(a,d);
		total=total+(n*e);
		a-=n;
		d-=n;

	printf("%d\n", total);
	return 0;
}

#include <stdio.h>

int main(){
	int a, b, c, d, e, f;
	scanf("%d %d %d %d %d %d", &a, &b, &c, &d, &e, &f);
	int min1;
	if(b < c){
		if(d < b)
			min1 = d;
		else
			min1 = b;
	}
	else{
		if(d < c)
			min1 = d;
		else
			min1 = c;
	}
	int min2;
	if(d - min1 < a)
		min2 = d - min1;
	else
		min2 = a;
	printf("%d", min1 * f + min2 * e);
	return 0;
}

#include<stdio.h>
int main()
{
int a,b,c,d,e,f,s,x;
scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
x=b;
if(x>c)
x=c;
if(x>d)
x=d;

if(f>e)
{
d=d-x;
x=x*f;
if(d>a)
{
s=e*a;
}
if(a>d||a==d)
{
s=e*d;
}
}
if(e>f||e==f)
{
 if(a<d)
 {
     s=e*a;
     d=d-a;
 }
    if(d<a)
    {
        s=e*d;
        d=0;
    }

    if(x>d)
        x=d;

    x=x*f;

}

printf("%d\n",s+x);

return 0;
}

#include<stdio.h>
long int min3(long int a,long int b,long int c)
{
  return (a>b&&a>c)?a:(b>c&&b>a)?b:c;
}
long int min2(long int a,long int b)
{
  return (a>b)?a:b;
}
int main()
{
  long int t,s,v,j,first,second,cost=0;
  scanf("%ld\n%ld\n%ld\n%ld\n%ld\n%ld",&t,&s,&v,&j,&first,&second);
  if(first<second)
  {
    cost+=second*min3(s,v,j);
    j-=min3(s,v,j);
    cost+=first*min2(t,j);
  }
  else
  {
    cost+=first*min2(t,j);
    j-=min2(t,j);
    cost+=second*min3(s,v,j);
  }
  printf("%ld",cost);
  return 0;
}

#include <stdio.h>
long a,b,c,d,e,f,maxf,maxe,n;
int main()
{
    scanf("%ld", &a);
    scanf("%ld", &b);
    scanf("%ld", &c);
    scanf("%ld", &d);
    scanf("%ld", &e);
    scanf("%ld", &f);
    maxf = b;
    if (maxf > c) maxf = c;
    if (maxf > d) maxf = d;
    maxe = a;
    if (maxe > d) maxe = d;
    if (f > e) n = f *maxf + e * (d - maxf);
    else n = e *maxe + f * (d - maxe);
    printf("%ld", n);

    return 0;
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

int min(int a,int b)
{
    if(a>b)
    return b;
    else
    return a;
}
int main()
{
   int a,b,c,d,e;
   int f;
   scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
   if(e>f)
   {
     d-=min(a,d);
     int j= min(b,min(c,d));
     int g=  e*min(a,d) + f*j;
     printf("%d",g);
   }
   else
   {
        int j=min(b,min(c,d));
         d-=j;
         int g= e*min(a,d)+ f*j;
         printf("%d",g);
   }
    return 0;
}

#include <stdio.h>

int main() {

	int i, index, index2, suit1Cost, suit2Cost, remainder, total=0;
	unsigned int clothes[4];
	unsigned int smallest = 100001;

	scanf("%d", &clothes[0]);
	scanf("%d", &clothes[1]);
	scanf("%d", &clothes[2]);
	scanf("%d", &clothes[3]);
	scanf("%d", &suit1Cost);
	scanf("%d", &suit2Cost);

	for (i = 0; i < 4; i++) {
		if (clothes[i] < smallest) {
			smallest = clothes[i];
			index = i;
		}
	}

	if (suit1Cost < suit2Cost) {
		if (index == 0) {
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}
			if (index == 3) {
				total = clothes[index] * suit2Cost;
			}
			else {
				remainder = clothes[3] - smallest;
				if (remainder <= clothes[0]) {
					total = ((smallest)*suit1Cost) + (remainder * suit2Cost);
				}
				else {
					total = ((smallest)*suit1Cost) + (clothes[0] * suit2Cost);
				}
			}
		}
		else if (index == 3) {
			total = clothes[index] * suit2Cost;
		}
		else {
			remainder = clothes[3] - smallest;
			if (remainder > 0) {
				total = smallest * suit2Cost;
				if (remainder <= clothes[0]) {
					total += remainder * suit1Cost;
				}
				else {
					total += clothes[0] * suit1Cost;
				}
			}
			else {
				total = clothes[3] * suit2Cost;
			}
		}
	}
	else if (suit1Cost > suit2Cost) {
		remainder = clothes[3] - clothes[0];
		if (index == 0) {
			total = clothes[0] * suit1Cost;
			smallest = 100001;
			for (i = 1; i < 4; i++) {
				if (clothes[i] < smallest) {
					smallest = clothes[i];
					index = i;
				}
			}

			if (remainder <= smallest) {
				total += remainder * suit2Cost;
			}
			else {
				total += smallest * suit2Cost;
			}
		}
		else if (index == 3) {
			total = clothes[3] * suit1Cost;
		}
		else {
			if (remainder > 0) {
				total = clothes[0] * suit1Cost;
				if (remainder <= smallest) {
					total += remainder * suit2Cost;
				}
				else {
					total += smallest * suit2Cost;
				}
			}
			else {
				total = clothes[3] * suit1Cost;
			}
		}
	}

	printf("%d", total);

	return 0;
}

#include<stdio.h>
main()
{
    int a,b,c,d,e,f,t;

    scanf("%d", &a);
    scanf("%d", &b);
    scanf("%d", &c);
    scanf("%d", &d);
    scanf("%d", &e);
    scanf("%d", &f);
    if(e>f)
    {
        if(d>a)
        {
            e=e*a;
            d=d-e;
        }
        else
        {
            e=e*d;
            d=0;
        }

        if(d<=b && d<=c)
        {
            f=f*d;
        }
        else if(b<=d && b<=c)
        {
            f=f*b;
        }
        else if(c<=d && c<=b)
        {
            f=f*c;
        }
    }
    else
    {
        if(d<=b && d<=c)
        {
            f=f*d;
            d=0;
        }
        else if(b<=d && b<=c)
        {
            f=f*b;
            d=d-b;
        }
        else if(c<=d && c<=b)
        {
            f=f*c;
            d=d-c;
        }

        if(d>a)
        {
            e=e*a;
        }
        else
        {
            e=e*d;
        }
    }

    t=e+f;
    printf("%d\n", t);

    return 0;
}

#include<stdio.h>
int main()
{
	unsigned long int a,b,c,d,e,f,n=0,A=0;
	scanf("%lu %lu %lu %lu %lu %lu",&a,&b,&c,&d,&e,&f);
if((b<=c) && (b<=d))
{
	d=d-b;
	A=b*f;
}
else if((c<=b) && (c<=d))
{
	d=d-c;
	A=c*f;
}
else
{
	A=d*f;
	d=0;
}
if(d!=0)
{
	if(a<=d)
	A=A+(a*e);
	else
	A=A+(d*e);
}
printf("%lu\n",A);
}

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <ctype.h>
#include <string.h>

int min(int a,int b)
{
    if(a>b)
    return b;
    else
    return a;
}
int main()
{
   int a,b,c,d,e,f;
   scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
   if(e>f)
   {
     d-=min(a,d);
     int j= min(b,min(c,d));
     int g=  e*min(a,d) + f*j;
     printf("%d",g);
   }
   else
   {
        int j=min(b,min(c,d));
         d-=j;
         int g= e*min(a,d)+ f*j;
         printf("%d",g);
   }
    return 0;
}