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

public class computers_ab implements Runnable {

	int MAX = 100;
	
	int INF = 100000;
	
	private void solve() throws IOException {
		c = new int[8][8];
		for (int i = 1; i <= 3; ++i) {
			for (int j = 1; j <= 3; ++j) {
				if ((i & j) != 0) {
					c[i][j + 3] = INF;
				}
			}
		}
		for (int i = 0; i < 3; ++i) {
			int a = in.nextInt();
			myAssert(0 <= a && a <= MAX);
			c[0][i + 1] = a;
		}
		for (int i = 0; i < 3; ++i) {
			int a = in.nextInt();
			myAssert(0 <= a && a <= MAX);
			c[i + 4][7] = a;
		}
		
		u = new boolean[c.length];
		int ans = 0;
		while (true) {
			Arrays.fill(u, false);
			int t = dfs(0, 7, INF);
			if (t == 0) { 
				break;
			}
			ans += t;
		}
		out.println(ans);
		
			
	}

	int[][] c;
	boolean[] u;
	
	int dfs(int i, int t, int C) {
		u[i] = true;
		if (i == t) {
			return C;
		}
		for (int j = 0; j < c.length; ++j) {
			if (!u[j] && c[i][j] > 0) {
				int q = dfs(j, t, Math.min(c[i][j], C));
				if (q > 0) {
					c[i][j] -= q;
					c[j][i] += q;
					return q;
				}
			}
		}
		return 0;
	}
	
	
	void myAssert(boolean e) {
		if (!e) {
			throw new Error("Assertion failed");
		}
	}
	
	final String FILE_NAME = "computers";

	SimpleScanner in;
	PrintWriter out;

	@Override
	public void run() {
		try {
			in = new SimpleScanner(new FileReader(FILE_NAME + ".in"));
			out = new PrintWriter(FILE_NAME + ".out");
			solve();
			out.close();
		} catch (Throwable e) {
			e.printStackTrace();
			System.exit(-1);
		}
	}

	public static void main(String[] args) {
		new Thread(new computers_ab()).start();
	}

	class SimpleScanner extends BufferedReader {

		private StringTokenizer st;
		private boolean eof;

		public SimpleScanner(Reader a) {
			super(a);
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(readLine());
				} catch (Exception e) {
					eof = true;
					return "";
				}
			}
			return st.nextToken();
		}

		boolean seekEof() {
			String s = next();
			if ("".equals(s) && eof)
				return true;
			st = new StringTokenizer(s + " " + st.toString());
			return false;
		}

		private String cnv(String s) {
			if (s.length() == 0)
				return "0";
			return s;
		}

		int nextInt() {
			return Integer.parseInt(cnv(next()));
		}

		double nextDouble() {
			return Double.parseDouble(cnv(next()));
		}

		long nextLong() {
			return Long.parseLong(cnv(next()));
		}
	}
}