import java.util.*;
import java.io.*;

public class gagarincup_dk_cases {
	BufferedReader br;
	PrintWriter out;
	StringTokenizer stok;

	String nextToken() throws IOException {
		while (stok == null || !stok.hasMoreTokens()) {
			String s = br.readLine();
			if (s == null) {
				return null;
			}
			stok = new StringTokenizer(s);
		}
		return stok.nextToken();
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	char nextChar() throws IOException {
		return (char) (br.read());
	}

	String nextLine() throws IOException {
		return br.readLine();
	}

	
	
	void solve() throws IOException {
		double a, b, c, d, ans;
		a = nextDouble();
		b = nextDouble();
		c = nextDouble();
		d = nextDouble();
		int x, y;
		char score1, defis, score2;
		score1 = nextChar();
		defis = nextChar();
		score2 = nextChar();
		x = score1 - 48;
		y = score2 - 48;    
		if (x == 4 && y == 0) {
			ans = a * a * c * c;
			out.println(ans);
			return;
		}
		if (x == 0 && y == 4) {
			ans = b * b * d * d;
			out.println(ans);
			return;
		}                                
		if (x == 4 && y == 1) {
			ans = a * a * c * d * a;   //W-W-W-L-W
			ans += a * a * d * c * a;   //W-W-L-W-W
			ans += a * b * c * c * a;  //W-L-W-W-W
			ans += b * a * c * c * a;  //L-W-W-W-W
			out.println(ans);
			return;
		}
		if (x == 1 && y == 4) {                              
			ans = b * b * d * c * b;   //W-W-W-L-W
			ans += b * b * c * d * b;   //W-W-L-W-W
			ans += b * a * d * d * b;  //W-L-W-W-W
			ans += a * b * d * d * b;  //L-W-W-W-W
			out.println(ans);
			return;
		}

		if (x == 4 && y == 2) {
			ans = b * b * c * c * a * c; // L-L-W-W-W-W  
			ans += a * a * d * d * a * c; // W-W-L-L-W-W

			ans += b * a * d * c * a * c; // L-W-L-W-W-W
			ans += b * a * c * d * a * c; // L-W-W-L-W-W
			ans += a * b * c * d * a * c; // W-L-W-L-W-W
			ans += a * b * d * c * a * c; // W-L-L-W-W-W

			ans += a * b * c * c * b * c; // W-L-W-W-L-W
			ans += b * a * c * c * b * c; // L-W-W-W-L-W
			ans += a * a * c * d * b * c; // W-W-W-L-L-W
                        ans += a * a * d * c * b * c; // W-W-L-W-L-W
			
			out.println(ans);
			return;
		}
		
		if (x == 2 && y == 4) {
			ans = a * a * d * d * b * d; // L-L-W-W-W-W  
			ans += b * b * c * c * b * d; // W-W-L-L-W-W

			ans += a * b * c * d * b * d; // L-W-L-W-W-W
			ans += a * b * d * c * b * d; // L-W-W-L-W-W
			ans += b * a * d * c * b * d; // W-L-W-L-W-W
			ans += b * a * c * d * b * d; // W-L-L-W-W-W

			ans += b * a * d * d * a * d; // W-L-W-W-L-W
			ans += a * b * d * d * a * d; // L-W-W-W-L-W
			ans += b * b * d * c * a * d; // W-W-W-L-L-W
                        ans += b * b * c * d * a * d; // W-W-L-W-L-W
			
			out.println(ans);
			return;
		}

		if (x == 4 && y == 3) {
		 	ans = a * a * c * d * b * d * a; //W-W-W-L-L-L-W
			ans += a * a * d * c * b * d * a; //W-W-L-W-L-L-W
			ans += a * b * c * c * b * d * a; //W-L-W-W-L-L-W
			ans += b * a * c * c * b * d * a; //L-W-W-W-L-L-W

		 	ans += a * a * d * d * b * c * a; //W-W-L-L-L-W-W
			ans += a * b * d * c * b * c * a; //W-L-L-W-L-W-W
			ans += b * b * c * c * b * c * a; //L-L-W-W-L-W-W
			ans += b * a * d * c * b * c * a; //L-W-L-W-L-W-W
		 	ans += b * a * c * d * b * c * a; //L-W-W-L-L-W-W
			ans += a * b * c * d * b * c * a; //W-L-W-L-L-W-W

			ans += a * a * d * d * a * d * a; //W-W-L-L-W-L-W
			ans += a * b * d * c * a * d * a; //W-L-L-W-W-L-W
			ans += b * b * c * c * a * d * a; //L-L-W-W-W-L-W
			ans += b * a * d * c * a * d * a; //L-W-L-W-W-L-W
			ans += b * a * c * d * a * d * a; //L-W-W-L-W-L-W
			ans += a * b * c * d * a * d * a; //W-L-W-L-W-L-W
			
			ans += a * b * d * d * a * c * a; //W-L-L-L-W-W-W
			ans += b * a * d * d * a * c * a; //L-W-L-L-W-W-W
			ans += b * b * c * d * a * c * a; //L-L-W-L-W-W-W
			ans += b * b * d * c * a * c * a; //L-L-L-W-W-W-W

			out.println(ans);
			return;
		}
		
		if (x == 3 && y == 4) {
			ans = a;
			a = b;
			b = ans;
			ans = c;
			c = d;
			d = ans;
				
		 	ans = a * a * c * d * b * d * a; //W-W-W-L-L-L-W
			ans += a * a * d * c * b * d * a; //W-W-L-W-L-L-W
			ans += a * b * c * c * b * d * a; //W-L-W-W-L-L-W
			ans += b * a * c * c * b * d * a; //L-W-W-W-L-L-W

		 	ans += a * a * d * d * b * c * a; //W-W-L-L-L-W-W
			ans += a * b * d * c * b * c * a; //W-L-L-W-L-W-W
			ans += b * b * c * c * b * c * a; //L-L-W-W-L-W-W
			ans += b * a * d * c * b * c * a; //L-W-L-W-L-W-W
		 	ans += b * a * c * d * b * c * a; //L-W-W-L-L-W-W
			ans += a * b * c * d * b * c * a; //W-L-W-L-L-W-W

			ans += a * a * d * d * a * d * a; //W-W-L-L-W-L-W
			ans += a * b * d * c * a * d * a; //W-L-L-W-W-L-W
			ans += b * b * c * c * a * d * a; //L-L-W-W-W-L-W
			ans += b * a * d * c * a * d * a; //L-W-L-W-W-L-W
			ans += b * a * c * d * a * d * a; //L-W-W-L-W-L-W
			ans += a * b * c * d * a * d * a; //W-L-W-L-W-L-W
			
			ans += a * b * d * d * a * c * a; //W-L-L-L-W-W-W
			ans += b * a * d * d * a * c * a; //L-W-L-L-W-W-W
			ans += b * b * c * d * a * c * a; //L-L-W-L-W-W-W
			ans += b * b * d * c * a * c * a; //L-L-L-W-W-W-W

			out.println(ans);
			return;
		}

	}
	void run() throws IOException {
		 br = new BufferedReader(new FileReader("gagarincup.in"));
		 out = new PrintWriter("gagarincup.out");
		// br = new BufferedReader(new InputStreamReader(System.in));
		// out = new PrintWriter(System.out);
		solve();
		br.close();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		// Localea.setDefault(Locale.US);
		new gagarincup_dk_cases().run();
	}
}