//package timus;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.Writer;
import java.math.BigInteger;
import java.sql.Date;
import java.util.AbstractSet;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Random;
import java.util.Set;
import java.util.Stack;
import java.util.TreeSet;
import java.util.Vector;

public class Abra {
	public static void main(String[] args) throws IOException {
		new Abra().run();
	}

	StreamTokenizer in;
	PrintWriter out;
	boolean oj;
	BufferedReader br;

	void init() throws IOException {
		oj = System.getProperty("ONLINE_JUDGE") != null;
		Reader reader = oj ? new InputStreamReader(System.in) : new FileReader("input.txt");
		Writer writer = oj ? new OutputStreamWriter(System.out) : new FileWriter("output.txt");
		// Reader reader = new InputStreamReader(System.in);
		// Writer writer = new OutputStreamWriter(System.out);
		br = new BufferedReader(reader);
		in = new StreamTokenizer(br);
		out = new PrintWriter(writer);
	}

	long selectionTime = 0;

	void startSelection() {
		selectionTime -= System.currentTimeMillis();
	}

	void stopSelection() {
		selectionTime += System.currentTimeMillis();
	}

	void run() throws IOException {
		long beginTime = System.currentTimeMillis();
		init();
		solve();
		long endTime = System.currentTimeMillis();
		if (!oj) {
			System.out.println("Memory used = " + (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
			System.out.println("Running time = " + (endTime - beginTime));
			System.out.println("Time of the selection = " + selectionTime);
		}
		out.flush();
	}

	int nextInt() throws IOException {
		in.nextToken();
		return (int) in.nval;
	}

	long nextLong() throws IOException {
		in.nextToken();
		return (long) in.nval;
	}

	String nextString() throws IOException {
		in.nextToken();
		return in.sval;
	}

	double nextDouble() throws IOException {
		in.nextToken();
		return in.nval;
	}

	long fact(long x) {
		long a = 1;
		for (long i = 2; i <= x; i++) {
			a *= i;
		}
		return a;
	}

	long digitSum(String x) {
		long a = 0;
		for (int i = 0; i < x.length(); i++) {
			a += x.charAt(i) - '0';
		}
		return a;
	}

	long digitSum(long x) {
		long a = 0;
		while (x > 0) {
			a += x % 10;
			x /= 10;
		}
		return a;
	}

	long digitMul(long x) {
		long a = 1;
		while (x > 0) {
			a *= x % 10;
			x /= 10;
		}
		return a;
	}

	int digitCubesSum(int x) {
		int a = 0;
		while (x > 0) {
			a += (x % 10) * (x % 10) * (x % 10);
			x /= 10;
		}
		return a;
	}

	double pif(double ax, double ay, double bx, double by) {
		return Math.sqrt((ax - bx) * (ax - bx) + (ay - by) * (ay - by));
	}

	long gcd(long a, long b) {
		if (a < b) {
			long c = b;
			b = a;
			a = c;
		}
		while (a % b != 0) {
			a = a % b;
			if (a < b) {
				long c = b;
				b = a;
				a = c;
			}
		}
		return b;
	}

	int gcd(int a, int b) {
		if (a < b) {
			int c = b;
			b = a;
			a = c;
		}
		while (a % b != 0) {
			a = a % b;
			if (a < b) {
				int c = b;
				b = a;
				a = c;
			}
		}
		return b;
	}

	long lcm(long a, long b) throws IOException {
		return a * b / gcd(a, b);
	}

	int lcm(int a, int b) throws IOException {
		return a * b / gcd(a, b);
	}

	int countOccurences(String x, String y) {
		int a = 0, i = 0;
		while (true) {
			i = y.indexOf(x);
			if (i == -1) break;
			a++;
			y = y.substring(i + 1);
		}
		return a;
	}

	int[] findPrimes(int x) {
		boolean[] forErato = new boolean[x - 1];
		List<Integer> t = new Vector<Integer>();
		int l = 0, j = 0;
		for (int i = 2; i < x; i++) {
			if (forErato[i - 2]) continue;
			t.add(i);
			l++;
			j = i * 2;
			while (j < x) {
				forErato[j - 2] = true;
				j += i;
			}
		}
		int[] primes = new int[l];
		Iterator<Integer> iterator = t.iterator();
		for (int i = 0; iterator.hasNext(); i++) {
			primes[i] = iterator.next().intValue();
		}
		return primes;
	}

	int rev(int x) {
		int a = 0;
		while (x > 0) {
			a = a * 10 + x % 10;
			x /= 10;
		}
		return a;
	}

	class myDate {
		int d, m, y;

		int[] ml = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

		public myDate(int da, int ma, int ya) {
			d = da;
			m = ma;
			y = ya;
			if (ma > 12 || ma < 1 || da > ml[ma - 1] || da < 1) {
				d = 1;
				m = 1;
				y = 9999999;
			}
		}

		void incYear(int x) {
			for (int i = 0; i < x; i++) {
				y++;
				if (m == 2 && d == 29) {
					m = 3;
					d = 1;
					return;
				}
				if (m == 3 && d == 1) {
					if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
						m = 2;
						d = 29;
					}
					return;
				}
			}
		}

		boolean less(myDate x) {
			if (y < x.y) return true;
			if (y > x.y) return false;
			if (m < x.m) return true;
			if (m > x.m) return false;
			if (d < x.d) return true;
			if (d > x.d) return false;
			return true;
		}

		void inc() {
			if ((d == 31) && (m == 12)) {
				y++;
				d = 1;
				m = 1;
			} else {
				if (((y % 4 == 0) && (y % 100 != 0)) || (y % 400 == 0)) {
					ml[1] = 29;
				}
				if (d == ml[m - 1]) {
					m++;
					d = 1;
				} else
					d++;
			}
		}
	}

	int partition(int n, int l, int m) {// n - sum, l - length, m - every part
		// <= m
		if (n < l) return 0;
		if (n < l + 2) return 1;
		if (l == 1) return 1;
		int c = 0;
		for (int i = Math.min(n - l + 1, m); i >= (n + l - 1) / l; i--) {
			c += partition(n - i, l - 1, i);
		}
		return c;
	}

	int rifmQuality(String a, String b) {
		if (a.length() > b.length()) {
			String c = a;
			a = b;
			b = c;
		}
		int c = 0, d = b.length() - a.length();
		for (int i = a.length() - 1; i >= 0; i--) {
			if (a.charAt(i) == b.charAt(i + d)) c++;
			else
				break;
		}
		return c;
	}

	String numSym = "0123456789ABCDEF";

	String ZFromXToYNotation(int x, int y, String z) {
		if (z.equals("0")) return "0";
		String a = "";
		long q = 0, t = 1;
		for (int i = z.length() - 1; i >= 0; i--) {
			q += (z.charAt(i) - 48) * t;
			t *= x;
		}
		while (q > 0) {
			a = numSym.charAt((int) (q % y)) + a;
			q /= y;
		}
		return a;
	}

	double angleFromXY(int x, int y) {
		if ((x == 0) && (y > 0)) return Math.PI / 2;
		if ((x == 0) && (y < 0)) return -Math.PI / 2;
		if ((y == 0) && (x > 0)) return 0;
		if ((y == 0) && (x < 0)) return Math.PI;
		if (x > 0) return Math.atan((double) y / x);
		else {
			if (y > 0) return Math.atan((double) y / x) + Math.PI;
			else
				return Math.atan((double) y / x) - Math.PI;
		}
	}

	static boolean isNumber(String x) {
		try {
			Integer.parseInt(x);
		} catch (NumberFormatException ex) {
			return false;
		}
		return true;
	}

	static boolean stringContainsOf(String x, String c) {
		for (int i = 0; i < x.length(); i++) {
			if (c.indexOf(x.charAt(i)) == -1) return false;
		}
		return true;
	}

	long pow(long a, long n) { // b > 0
		if (n == 0) return 1;
		long k = n, b = 1, c = a;
		while (k != 0) {
			if (k % 2 == 0) {
				k /= 2;
				c *= c;
			} else {
				k--;
				b *= c;
			}
		}
		return b;
	}

	int pow(int a, int n) { // b > 0
		if (n == 0) return 1;
		int k = n, b = 1, c = a;
		while (k != 0) {
			if (k % 2 == 0) {
				k /= 2;
				c *= c;
			} else {
				k--;
				b *= c;
			}
		}
		return b;
	}

	double pow(double a, int n) { // b > 0
		if (n == 0) return 1;
		double k = n, b = 1, c = a;
		while (k != 0) {
			if (k % 2 == 0) {
				k /= 2;
				c *= c;
			} else {
				k--;
				b *= c;
			}
		}
		return b;
	}

	double log2(double x) {
		return Math.log(x) / Math.log(2);
	}

	int lpd(int[] primes, int x) {// least prime divisor
		int i;
		for (i = 0; primes[i] <= x / 2; i++) {
			if (x % primes[i] == 0) {
				return primes[i];
			}
		}
		;
		return x;
	}

	int np(int[] primes, int x) {// number of prime number
		for (int i = 0; true; i++) {
			if (primes[i] == x) return i;
		}
	}

	int[] dijkstra(int[][] map, int n, int s) {
		int[] p = new int[n];
		boolean[] b = new boolean[n];
		Arrays.fill(p, Integer.MAX_VALUE);
		p[s] = 0;
		b[s] = true;
		for (int i = 0; i < n; i++) {
			if (i != s) p[i] = map[s][i];
		}
		while (true) {
			int m = Integer.MAX_VALUE, mi = -1;
			for (int i = 0; i < n; i++) {
				if (!b[i] && (p[i] < m)) {
					mi = i;
					m = p[i];
				}
			}
			if (mi == -1) break;
			b[mi] = true;
			for (int i = 0; i < n; i++)
				if (p[mi] + map[mi][i] < p[i]) p[i] = p[mi] + map[mi][i];
		}
		return p;
	}

	boolean isLatinChar(char x) {
		if (((x >= 'a') && (x <= 'z')) || ((x >= 'A') && (x <= 'Z'))) return true;
		else
			return false;
	}

	boolean isBigLatinChar(char x) {
		if (x >= 'A' && x <= 'Z') return true;
		else
			return false;
	}

	boolean isSmallLatinChar(char x) {
		if (x >= 'a' && x <= 'z') return true;
		else
			return false;
	}

	boolean isDigitChar(char x) {
		if (x >= '0' && x <= '9') return true;
		else
			return false;
	}

	class NotANumberException extends Exception {
		private static final long serialVersionUID = 1L;
		String mistake;

		NotANumberException() {
			mistake = "Unknown.";
		}

		NotANumberException(String message) {
			mistake = message;
		}
	}

	class Real {
		String num = "0";
		long exp = 0;
		boolean pos = true;

		long length() {
			return num.length();
		}

		void check(String x) throws NotANumberException {
			if (!stringContainsOf(x, "0123456789+-.eE")) throw new NotANumberException("Illegal character.");
			long j = 0;
			for (long i = 0; i < x.length(); i++) {
				if ((x.charAt((int) i) == '-') || (x.charAt((int) i) == '+')) {
					if (j == 0) j = 1;
					else
						if (j == 5) j = 6;
						else
							throw new NotANumberException("Unexpected sign.");
				} else
					if ("0123456789".indexOf(x.charAt((int) i)) != -1) {
						if (j == 0) j = 2;
						else
							if (j == 1) j = 2;
							else
								if (j == 2)
								;
								else
									if (j == 3) j = 4;
									else
										if (j == 4)
										;
										else
											if (j == 5) j = 6;
											else
												if (j == 6)
												;
												else
													throw new NotANumberException("Unexpected digit.");
					} else
						if (x.charAt((int) i) == '.') {
							if (j == 0) j = 3;
							else
								if (j == 1) j = 3;
								else
									if (j == 2) j = 3;
									else
										throw new NotANumberException("Unexpected dot.");
						} else
							if ((x.charAt((int) i) == 'e') || (x.charAt((int) i) == 'E')) {
								if (j == 2) j = 5;
								else
									if (j == 4) j = 5;
									else
										throw new NotANumberException("Unexpected exponent.");
							} else
								throw new NotANumberException("O_o.");
			}
			if ((j == 0) || (j == 1) || (j == 3) || (j == 5)) throw new NotANumberException("Unexpected end.");
		}

		public Real(String x) throws NotANumberException {
			check(x);
			if (x.charAt(0) == '-') pos = false;
			long j = 0;
			String e = "";
			boolean epos = true;
			for (long i = 0; i < x.length(); i++) {
				if ("0123456789".indexOf(x.charAt((int) i)) != -1) {
					if (j == 0) num += x.charAt((int) i);
					if (j == 1) {
						num += x.charAt((int) i);
						exp--;
					}
					if (j == 2) e += x.charAt((int) i);
				}
				if (x.charAt((int) i) == '.') {
					if (j == 0) j = 1;
				}
				if ((x.charAt((int) i) == 'e') || (x.charAt((int) i) == 'E')) {
					j = 2;
					if (x.charAt((int) (i + 1)) == '-') epos = false;
				}
			}
			while ((num.length() > 1) && (num.charAt(0) == '0'))
				num = num.substring(1);
			while ((num.length() > 1) && (num.charAt(num.length() - 1) == '0')) {
				num = num.substring(0, num.length() - 1);
				exp++;
			}
			if (num.equals("0")) {
				exp = 0;
				pos = true;
				return;
			}
			while ((e.length() > 1) && (e.charAt(0) == '0'))
				e = e.substring(1);
			try {
				if (e != "") if (epos) exp += Long.parseLong(e);
				else
					exp -= Long.parseLong(e);
			} catch (NumberFormatException exc) {
				if (!epos) {
					num = "0";
					exp = 0;
					pos = true;
				} else {
					throw new NotANumberException("Too long exponent");
				}
			}
		}

		public Real() {
		}

		String toString(long mantissa) {
			String a = "", b = "";
			if (exp >= 0) {
				a = num;
				if (!pos) a = '-' + a;
				for (long i = 0; i < exp; i++)
					a += '0';
				for (long i = 0; i < mantissa; i++)
					b += '0';
				if (mantissa == 0) return a;
				else
					return a + "." + b;
			} else {
				if (exp + length() <= 0) {
					a = "0";
					if (mantissa == 0) {
						return a;
					}
					if (mantissa < -(exp + length() - 1)) {
						for (long i = 0; i < mantissa; i++)
							b += '0';
						return a + "." + b;
					} else {
						if (!pos) a = '-' + a;
						for (long i = 0; i < mantissa; i++)
							if (i < -(exp + length())) b += '0';
							else
								if (i + exp >= 0) b += '0';
								else
									b += num.charAt((int) (i + exp + length()));
						return a + "." + b;
					}
				} else {
					if (!pos) a = "-";
					for (long i = 0; i < exp + length(); i++)
						a += num.charAt((int) i);
					if (mantissa == 0) return a;
					for (long i = exp + length(); i < exp + length() + mantissa; i++)
						if (i < length()) b += num.charAt((int) i);
						else
							b += '0';
					return a + "." + b;
				}
			}
		}
	}

	boolean containsRepeats(int... num) {
		Set<Integer> s = new TreeSet<Integer>();
		for (int d : num)
			if (!s.contains(d)) s.add(d);
			else
				return true;
		return false;
	}

	int[] rotateDice(int[] a, int n) {
		int[] c = new int[6];
		if (n == 0) {
			c[0] = a[1];
			c[1] = a[5];
			c[2] = a[2];
			c[3] = a[0];
			c[4] = a[4];
			c[5] = a[3];
		}
		if (n == 1) {
			c[0] = a[2];
			c[1] = a[1];
			c[2] = a[5];
			c[3] = a[3];
			c[4] = a[0];
			c[5] = a[4];
		}
		if (n == 2) {
			c[0] = a[3];
			c[1] = a[0];
			c[2] = a[2];
			c[3] = a[5];
			c[4] = a[4];
			c[5] = a[1];
		}
		if (n == 3) {
			c[0] = a[4];
			c[1] = a[1];
			c[2] = a[0];
			c[3] = a[3];
			c[4] = a[5];
			c[5] = a[2];
		}
		if (n == 4) {
			c[0] = a[0];
			c[1] = a[2];
			c[2] = a[3];
			c[3] = a[4];
			c[4] = a[1];
			c[5] = a[5];
		}
		if (n == 5) {
			c[0] = a[0];
			c[1] = a[4];
			c[2] = a[1];
			c[3] = a[2];
			c[4] = a[3];
			c[5] = a[5];
		}
		return c;
	}

	int min(int... a) {
		int c = Integer.MAX_VALUE;
		for (int d : a)
			if (d < c) c = d;
		return c;
	}

	int max(int... a) {
		int c = Integer.MIN_VALUE;
		for (int d : a)
			if (d > c) c = d;
		return c;
	}

	int[] normalizeDice(int[] a) {
		int[] c = a.clone();
		if (c[0] != 0) if (c[1] == 0) c = rotateDice(c, 0);
		else
			if (c[2] == 0) c = rotateDice(c, 1);
			else
				if (c[3] == 0) c = rotateDice(c, 2);
				else
					if (c[4] == 0) c = rotateDice(c, 3);
					else
						if (c[5] == 0) c = rotateDice(rotateDice(c, 0), 0);
		while (c[1] != min(c[1], c[2], c[3], c[4]))
			c = rotateDice(c, 4);
		return c;
	}

	boolean sameDice(int[] a, int[] b) {
		for (int i = 0; i < 6; i++)
			if (a[i] != b[i]) return false;
		return true;
	}

	final double goldenRatio = (1 + Math.sqrt(5)) / 2;
	final double aGoldenRatio = (1 - Math.sqrt(5)) / 2;

	long Fib(int n) {
		if (n < 0) if (n % 2 == 0) return -Math.round((pow(goldenRatio, -n) - pow(aGoldenRatio, -n)) / Math.sqrt(5));
		else
			return -Math.round((pow(goldenRatio, -n) - pow(aGoldenRatio, -n)) / Math.sqrt(5));
		return Math.round((pow(goldenRatio, n) - pow(aGoldenRatio, n)) / Math.sqrt(5));
	}

	class japaneeseComparator implements Comparator<String> {
		@Override
		public int compare(String a, String b) {
			int ai = 0, bi = 0;
			boolean m = false, ns = false;
			if (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') {
				if (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') m = true;
				else
					return -1;
			}
			if (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') {
				if (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') m = true;
				else
					return 1;
			}
			a += "!";
			b += "!";
			int na = 0, nb = 0;
			while (true) {
				if (a.charAt(ai) == '!') {
					if (b.charAt(bi) == '!') break;
					return -1;
				}
				if (b.charAt(bi) == '!') {
					return 1;
				}
				if (m) {
					int ab = -1, bb = -1;
					while (a.charAt(ai) <= '9' && a.charAt(ai) >= '0') {
						if (ab == -1) ab = ai;
						ai++;
					}
					while (b.charAt(bi) <= '9' && b.charAt(bi) >= '0') {
						if (bb == -1) bb = bi;
						bi++;
					}
					m = !m;
					if (ab == -1) {
						if (bb == -1) continue;
						else
							return 1;
					}
					if (bb == -1) return -1;
					while (a.charAt(ab) == '0' && ab + 1 != ai) {
						ab++;
						if (!ns) na++;
					}
					while (b.charAt(bb) == '0' && bb + 1 != bi) {
						bb++;
						if (!ns) nb++;
					}
					if (na != nb) ns = true;
					if (ai - ab < bi - bb) return -1;
					if (ai - ab > bi - bb) return 1;
					for (int i = 0; i < ai - ab; i++) {
						if (a.charAt(ab + i) < b.charAt(bb + i)) return -1;
						if (a.charAt(ab + i) > b.charAt(bb + i)) return 1;
					}
				} else {
					m = !m;
					while (true) {
						if (a.charAt(ai) <= 'z' && a.charAt(ai) >= 'a' && b.charAt(bi) <= 'z' && b.charAt(bi) >= 'a') {
							if (a.charAt(ai) < b.charAt(bi)) return -1;
							if (a.charAt(ai) > b.charAt(bi)) return 1;
							ai++;
							bi++;
						} else
							if (a.charAt(ai) <= 'z' && a.charAt(ai) >= 'a') return 1;
							else
								if (b.charAt(bi) <= 'z' && b.charAt(bi) >= 'a') return -1;
								else
									break;
					}
				}
			}
			if (na < nb) return 1;
			if (na > nb) return -1;
			return 0;
		}
	}

	void mpr(int x) {
		out.print(' ');
		if (x < 100) out.print(' ');
		if (x < 10) out.print(' ');
		out.print(x);
	}

	int mtry(String s, String alph) {
		String t = "";
		Random r = new Random();
		int c = 0, l = alph.length();
		for (int i = 0; i < s.length(); i++) {
			t += alph.charAt(r.nextInt(l));
			c++;
		}
		while (!t.equals(s)) {
			t = t.substring(1);
			t += alph.charAt(r.nextInt(l));
			c++;
		}
		return c;
	}

	Hashtable<String, Vector> tab;

	void mtest(String s, String alph, int d) {
		int n = d, r = 0;
		for (int i = 0; i < n; i++) {
			r += mtry(s, alph);
		}
		int re = (int) Math.round((0.0 + r) / n);
		out.println("\"" + s + "\" = " + re + ", Average = " + ((0.0 + r) / n));
/*		String res = Integer.toString(re);
		if (!tab.contains(res)) {
			tab.put(res, new Vector<String>());
		}
		tab.get(res).add(s);*/
	}

	void solve() throws IOException {
        /*
         * String[] st = new String[52000]; in.resetSyntax(); in.wordChars(' ' +
         * 1, 255); in.whitespaceChars(0, ' '); int n = 0; while (true) { String
         * t = nextString(); if (in.ttype == StreamTokenizer.TT_EOF) break;
         * st[n] = t; n++; } st = Arrays.copyOf(st, n); Arrays.sort(st, new
         * japaneeseComparator()); for (int i = 0; i < n; i++) {
         * out.println(st[i]); }
         */
        int w = nextInt();
        if (w == 2) {
        	out.print("NO");
        	return;
        }
        if (w % 2 == 0) out.print("YES"); else out.print("NO");
    }
}


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

public class Pascal {

    static PrintWriter out = new PrintWriter(System.out);
    static BufferedReader br;
    static StringTokenizer st;

    public static void main(String[] args) throws IOException {
        br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        int n = nextInt();
        int k = nextInt();
        int min = Integer.MAX_VALUE;
        for (int i = 1; i < k; i++) {
            if (n % i == 0) {
                int x = (n / (i % k)) * k + i;
                if(x < min) min = x;
            }
        }
        out.print(min);
        out.close();
    }

    static int nextInt() throws IOException {
        if (st == null || !st.hasMoreElements()) st = new StringTokenizer(br.readLine());
        return Integer.parseInt(st.nextToken());
    }

    static long nextLong() throws IOException {
        if (st == null || !st.hasMoreElements()) st = new StringTokenizer(br.readLine());
        return Long.parseLong(st.nextToken());
    }

    static String next() throws IOException {
        if (st == null || !st.hasMoreElements()) st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }
}


/*package whatever //do not write package name here */

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

public class GFG {
	public static void main (String[] args) {
	    Scanner s = new Scanner(System.in);
	    int a = s.nextInt();
	    int b = s.nextInt();
	    int c = s.nextInt();
	    int d = s.nextInt();
	    int e = s.nextInt();
	    int f = s.nextInt();
	    int cost=0;
	    if(e<f) {

	        int min = (int)Math.min(b,c);
	        min = (int)Math.min(min,d);
	        cost=min*f;
	        d=d-min;
	        if(d>0) {
	            cost=cost+(int)Math.min(a,d)*e;
	        }

	        System.out.println(cost);
	    }
	    else {
	          int min = (int)Math.min(a,d);

	        cost=min*e;

	        d=d-min;
	        if(d>0) {
	            min = (int)Math.min(b,c);

	        cost=cost+(int)Math.min(min,d)*f;
	        }

	         System.out.println(cost);
	    }

	}
}


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

import static java.lang.Math.*;

public class solution implements Runnable {

	public long bin_pow(long a, long n) {
		long res = 1;
		while (n > 0) {
			if ((n & 1) == 1)
				res = (res * a) % 1000000009;
			a = (a * a) % 1000000009;
			n >>= 1;
		}
		return res;
	}

	public void solve() throws Exception {
		long n = sc.nextLong();
		long m = sc.nextLong();
		long k = sc.nextLong();
		long ans = 0;
		long l = -1, r = (n + k - 1) / k;
		while (r - l > 1) {
			long me = (l + r) / 2;
			if (((n - k * me) / k) * (k - 1) + ((n - k * me) % k) >= m - k * me)
				r = me;
			else
				l = me;
		}
		l = r;
		ans = (bin_pow(2, l + 1) - 2 + 1000000009) % 1000000009;
		ans = ((ans * k) % 1000000009 + m - k * l + 1000000009) % 1000000009;
		out.println(ans);
	}

	static Throwable throwable;

	BufferedReader in;
	FastScanner sc;
	PrintWriter out;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			out = new PrintWriter(System.out);
			sc = new FastScanner(in);
			solve();
		} catch (Throwable throwable) {
			solution.throwable = throwable;
		} finally {
			out.close();
		}
	}

	public static void main(String[] args) throws Throwable {
		Thread thread = new Thread(null, new solution(), "", (1 << 26));
		thread.start();
		thread.join();
		if (solution.throwable != null)
			throw throwable;
	}

}

class FastScanner {
	BufferedReader reader;
	StringTokenizer str;

	public FastScanner(BufferedReader re) {
		this.reader = re;
	}

	public String nextToken() throws Exception {
		while (str == null || !str.hasMoreTokens()) {
			str = new StringTokenizer(reader.readLine());
		}
		return str.nextToken();
	}

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

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

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


import java.util.Arrays;
import java.util.Scanner;

public class Run {

	public static void main(String[] args)
	{
		Scanner input = new Scanner(System.in);
		String wholeInput = input.nextLine();
		String[] token = wholeInput.split(" ");
		int n = Integer.valueOf(token[0]);
		int m = Integer.valueOf(token[1]);
		wholeInput = input.nextLine();
		token = wholeInput.split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
		{
			a[i] = Integer.valueOf(token[i]);
		}
		input.close();
		token = null;
		int S = 0;
		for (int i = 0; i < n; i++)
		{
			S += a[i];
		}
		if (m > S)
		{
			System.out.print(-1);
		}
		else
		{
			System.out.print(solve(1, m, m, a));
		}
	}

	private static boolean checkAnswer(int m, int day, int[] a)
	{
		for (int i = 0; i < a.length; i++)
		{
			a[i] = -a[i];
		}
		Arrays.sort(a);
		for (int i = 0; i < a.length; i++)
		{
			a[i] = -a[i];
		}
		int arrayMarker = 0;
		int cupMarker = 0;
		int S = 0;
		while(true)
		{
			if (a[arrayMarker] - cupMarker > 0)
			{
				S += a[arrayMarker] - cupMarker;
			}
			arrayMarker++;
			if (arrayMarker % day == 0)
			{
				cupMarker++;
			}
			if (arrayMarker == a.length)
			{
				break;
			}
		}
		if (S >= m)
		{
			return true;
		}
		else
		{
			return false;
		}
	}

	private static int solve(int tempPos, int length, int m, int[] a)
	{
		int checkPos = tempPos + length / 2;
		if (length == 0)
		{
			return tempPos;
		}
		if (checkAnswer(m, checkPos, a))
		{
			return solve(tempPos, checkPos - tempPos, m, a);
		}
		else
		{
			return solve(checkPos + 1, tempPos + length - checkPos - 1, m, a);
		}
	}

}


import java.util.*;
public class DIV64 {
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();
		int c1=0,c0=0;
		int i=0;
		while( i<s.length() && s.charAt(i)=='0')
			i++;
		for(;i<s.length();i++)
		{
			if(s.charAt(i)=='1')
				c1++;
			if(s.charAt(i)=='0')
				c0++;
		}

		if(c0>=6 & c1>=1)
			System.out.println("yes");
		else System.out.println("no");
		sc.close();
	}
}


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

public class Main {

    static Scanner input = new Scanner(new BufferedReader(new InputStreamReader(System.in)));

    public static void main(String[] args) {
        int n = input.nextInt();
        String s = input.next();
        int x = 0, y = 0;
        for (int i = 0; i < n; i++) {
            switch (s.charAt(i)) {
                case 'U':
                    y++;
                    break;
                case 'L':
                    x--;
                    break;
                case 'D':
                    y--;
                    break;
                case 'R':
                    x++;
                    break;
            }
        }
        System.out.println(n - Math.abs(x) - Math.abs(y));
    }
}


import java.util.Scanner;

public class A {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[][][] cs = new char[20][8][8];
        for(int i = 0; i < 8; i++) {
            cs[0][i] = sc.next().toCharArray();
        }

        for(int i = 0; i < 19; i++) {
            for(int y = 0; y < 8; y++)
                for(int x = 0; x < 8; x++)
                    if(cs[i][y][x] == 'M')
                        for(int dy = -1; dy <= 1; dy++)
                            for(int dx = -1; dx <= 1; dx++) {
                                final int xx = x+dx;
                                final int yy = y+dy;
                                if(0 <= xx && xx < 8 && 0 <= yy && yy < 8 && cs[i][yy][xx] != 'S')
                                    cs[i+1][yy][xx] = 'M';
                            }

            for(int y = 6; y >= 0; y--)
                for(int x = 0; x < 8; x++)
                    if(cs[i][y][x] == 'S')
                        cs[i+1][y+1][x] = 'S';
        }

        String res = "LOSE";
        for(int y = 0; y < 8; y++)
            for(int x = 0; x < 8; x++)
                if(cs[19][y][x] == 'M')
                    res = "WIN";
        System.out.println(res);
    }
}


import java.io.*;
import java.util.Locale;
import java.util.StringTokenizer;

public class SolutionTest implements Runnable {

    BufferedReader in;
    PrintWriter out;
    StringTokenizer tok = new StringTokenizer("");

    public static void main(String[] args) {
        new Thread(null, new SolutionTest(), "", 256 * (1L << 20)).start();
    }

    public void run() {
        try {
            long t1 = System.currentTimeMillis();
//            in = new BufferedReader(new FileReader("src/codeforces/input.txt"));
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
            Locale.setDefault(Locale.US);
            solve();
            in.close();
            out.close();
            long t2 = System.currentTimeMillis();
            System.err.println("Time = " + (t2 - t1));
        } catch (Throwable t) {
            t.printStackTrace(System.err);
            System.exit(-1);
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    // solution
    void solve() throws IOException {
        out.println(dieRoll9A());
    }

    private String dieRoll9A() throws IOException {
        int y = readInt();
        int w = readInt();
        switch (Math.max(y, w)) {
            case 1:
                return "1/1";
            case 2:
                return "5/6";
            case 3:
                return "2/3";
            case 4:
                return "1/2";
            case 5:
                return "1/3";
            default:
                return "1/6";
        }
    }
}


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

public class Main {
    Scanner in;
    PrintWriter out;
    StreamTokenizer ST;
    BufferedReader br;

    int nextInt() throws IOException {
        ST.nextToken();
        return (int) ST.nval;
    }

    double nextDouble() throws IOException {
        ST.nextToken();
        return ST.nval;
    }

    String next() throws IOException {
        ST.nextToken();
        return ST.sval;
    }

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

    void solve() throws IOException {
        int n = nextInt();
        for(int i=1;i<=n;++i)
        {
            if (i*(i+1)/2==n)
            {
                out.println("YES");
                return;
            }
        }
        out.println("NO");
    }

    public void run() throws IOException {
        // br = new BufferedReader(new FileReader(new File("input.txt")));
        br = new BufferedReader(new InputStreamReader(System.in));
        ST = new StreamTokenizer(br);
        in = new Scanner(br);
        out = new PrintWriter(System.out);
        // out = new PrintWriter(new FileWriter(new File("output.txt")));
        solve();
        in.close();
        out.close();
        br.close();
    }

    public static void main(String[] args) throws Exception {
        new Main().run();
    }

}


import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Random;
import java.util.StringTokenizer;

/**
 * @author Polyarniy Nickolay
 */
public class ProblemB {

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok;
    private final String DELIMETER = " ";
    private final boolean ENABLE_MULTITEST = false;
    private final boolean DEBUG = true;
    private final String FILENAME = null;//if FILENAME = null, then works with console

    public void run() throws Exception {
        initInputOutput();
        do {
            init();
            solve();
        } while (hasMoreTokens() && ENABLE_MULTITEST);
        finish();
    }

    private void init() throws Exception {
    }

    private void solve() throws Exception {
        long n = nextInt();
        long m = nextInt();
        long x = nextInt();
        long y = nextInt();
        long a = nextInt();
        long b = nextInt();
        long nod = nod(a, b);
        a = a / nod;
        b = b / nod;

        long w = 0;
        long h = 0;
        long pow = 1000000000;
        while (pow != 0) {
            while (w + a * pow <= n && h + b * pow <= m) {
                w = w + a * pow;
                h = h + b * pow;
            }
            pow /= 2;
        }
        long x1;
        if (w % 2 == 0) {
            long x1Mid = x - w / 2;
            long x1Max = n - w;
            long x1Min = 0;
            x1 = Math.max(Math.min(x1Mid, x1Max), x1Min);
        } else {
            long x1Mid = x - (w + 1) / 2;
            long x1Max = n - w;
            long x1Min = 0;
            x1 = Math.max(Math.min(x1Mid, x1Max), x1Min);
        }
        long y1;
        if (h % 2 == 0) {
            long y1Mid = y - h / 2;
            long y1Max = m - h;
            long y1Min = 0;
            y1 = Math.max(Math.min(y1Mid, y1Max), y1Min);
        } else {
            long y1Mid = y - (h + 1) / 2;
            long y1Max = m - h;
            long y1Min = 0;
            y1 = Math.max(Math.min(y1Mid, y1Max), y1Min);
        }
        out.println(x1 + " " + y1 + " " + (x1 + w) + " " + (y1 + h));
    }

    private long nod(long a, long b) {
        if (a == 0 || a == b) {
            return b;
        } else if (b == 0)
            return a;
        if (a > b) {
            return nod(a % b, b);
        } else return nod(b % a, a);
    }

    public static void main(String[] args) throws Exception {
        ProblemB solution = new ProblemB();
        solution.run();
    }

    private void initInputOutput() throws Exception {
        if (FILENAME == null) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter("output.txt");
        }
    }

    private void shuffleArray(Object[] arr) {
        Random r = new Random();
        for (int i = 0; i < arr.length; ++i) {
            Object tmp = arr[i];
            int j = r.nextInt(arr.length);
            arr[i] = arr[j];
            arr[j] = tmp;
        }
    }

    private void shuffleArray(int[] arr) {
        Random r = new Random();
        for (int i = 0; i < arr.length; ++i) {
            int tmp = arr[i];
            int j = r.nextInt(arr.length);
            arr[i] = arr[j];
            arr[j] = tmp;
        }
    }

    private int[] nextArrayInt(int n) throws Exception {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = nextInt();
        }
        return res;
    }

    private String nextWord() throws Exception {
        if (updateTokenizer()) {
            return null;
        } else {
            return tok.nextToken();
        }
    }

    private boolean hasMoreTokens() throws Exception {
        return !updateTokenizer();
    }

    private boolean updateTokenizer() throws Exception {
        while (tok == null || !tok.hasMoreTokens()) {
            String nextLine = in.readLine();
            if (nextLine == null || nextLine.isEmpty()) {
                return true;
            }
            tok = new StringTokenizer(nextLine, DELIMETER);
        }
        return false;
    }

    private int nextInt() throws Exception {
        return Integer.parseInt(nextWord());
    }

    private long nextLong() throws Exception {
        return Long.parseLong(nextWord());
    }

    private void finish() throws Exception {
        in.close();
        out.close();
    }

    private void print(String s) {
        if (DEBUG) {
            System.out.print(s);
        }
    }

    private void println(String s) {
        if (DEBUG) {
            System.out.println(s);
        }
    }

    private void println() {
        if (DEBUG) {
            System.out.println();
        }
    }

    private long[] getFirstSimpleNums(int n) {
        boolean[] notPr = new boolean[n];
        int res = n;
        notPr[0] = true;
        res--;
        notPr[1] = true;
        res--;
        for (int i = 2; i < n; ++i) {
            if (!notPr[i]) {
                for (int j = i + i; j < n; j += i) {
                    if (!notPr[j]) {
                        notPr[j] = true;
                        res--;
                    }
                }
            }
        }
        long[] resA = new long[res];
        int next = 0;
        for (int i = 0; i < n; i++) {
            if (!notPr[i]) {
                resA[next] = i;
                next++;
            }
        }
        return resA;
    }

    private static class Pair {

        int a;
        int b;

        public Pair(int a, int b) {
            this.a = a;
            this.b = b;
        }

        public static final Comparator<Pair> comparator = new Comparator<Pair>() {

            @Override
            public int compare(Pair pair1, Pair pair2) {
                return (pair1.a - pair2.a) != 0 ? (pair1.a - pair2.a) : (pair1.b - pair2.b);
            }
        };

        @Override
        public String toString() {
            return "{" + a + "|" + b + '}';
        }
    }

    class TreeMin {

        int n;
        int[] t;

        public TreeMin(int size, int[] defaultValue) {
            n = 1;
            while (n < size) {
                n *= 2;
            }
            t = new int[2 * n];
            for (int i = 0; i < defaultValue.length; i++) {
                t[n + i] = defaultValue[i];
            }
            for (int i = defaultValue.length; i < n; i++) {
                t[n + i] = Integer.MAX_VALUE;
            }
            for (int i = n - 1; i >= 1; i--) {
                t[i] = Math.min(t[2 * i], t[2 * i + 1]);
            }
        }

        public void set(int index, int value) {
            index += n;
            t[index] = value;
            index /= 2;
            while (index >= 1) {
                t[index] = Math.min(t[2 * index], t[2 * index + 1]);
                index /= 2;
            }
        }

        /**
         * @param l inclusive
         * @param r exclusive
         */
        public int getMin(int l, int r) {
            int min = Integer.MAX_VALUE;
            l += n;
            r += n;
            while (l <= r) {
                if (l % 2 == 1) {
                    min = Math.min(min, t[l]);
                    l++;
                }
                if (r % 2 == 0) {
                    min = Math.min(min, t[r]);
                    r--;
                }
                l /= 2;
                r /= 2;
            }
            return min;
        }
    }

    class PriorityQueue {

        int size = 0;
        int capacity = 5;
        int[] key = new int[capacity];
        int[] value = new int[capacity];
        int[] idByInd = new int[capacity];
        int nextID = 0;
        ArrayList<Integer> indById = new ArrayList<Integer>();

        void ensureCapacity(int newSize) {
            if (newSize > capacity) {
                key = increaseArray(key);
                value = increaseArray(value);
                idByInd = increaseArray(idByInd);
                capacity = key.length;
            }
        }

        int[] increaseArray(int[] a) {
            int[] res = new int[Math.max(a.length * 2, 1)];
            for (int i = 0; i < a.length; i++) {
                res[i] = a[i];
            }
            for (int i = a.length; i < res.length; i++) {
                res[i] = Integer.MAX_VALUE;
            }
            return res;
        }

        void swap(int ind1, int ind2) {
            swap(key, ind1, ind2);
            swap(value, ind1, ind2);
            int id1 = idByInd[ind1];
            int id2 = idByInd[ind2];
            swap(idByInd, ind1, ind2);
            swap(indById, id1, id2);
        }

        void swap(int[] a, int ind1, int ind2) {
            int tmp = a[ind1];
            a[ind1] = a[ind2];
            a[ind2] = tmp;
        }

        void swap(ArrayList<Integer> a, int ind1, int ind2) {
            int tmp = a.get(ind1);
            a.set(ind1, a.get(ind2));
            a.set(ind2, tmp);
        }

        int parent(int index) {
            return (index - 1) / 2;
        }

        private void siftUp(int index) {
            while (index > 0) {
                int parent = parent(index);
                if (key[index] < key[parent]) {
                    swap(index, parent);
                }
                index = parent;
            }
        }

        private void siftDown(int index) {
            while (true) {
                int ch1 = 2 * index + 1;
                int ch2 = 2 * index + 2;
                if (ch1 >= size) {
                    ch1 = index;
                }
                if (ch2 >= size) {
                    ch2 = ch1;
                }
                int toSwap = index;
                if (key[ch1] < key[toSwap]) {
                    toSwap = ch1;
                }
                if (key[ch2] < key[toSwap]) {
                    toSwap = ch2;
                }
                if (toSwap == index) {
                    break;
                } else {
                    swap(index, toSwap);
                    index = toSwap;
                }
            }
        }

        public int push(int key, int value) {
            size++;
            ensureCapacity(size);
            int id = nextID;
            nextID++;
            this.key[size - 1] = key;
            this.value[size - 1] = value;
            this.idByInd[size - 1] = id;
            indById.add(size - 1);
            siftUp(size - 1);
            return id;
        }

        public void decreaseKey(int id, int key) {
            int ind = indById.get(id);
            while (key > this.key[ind]) {
            }
            this.key[ind] = key;
            siftUp(ind);
        }

        public final int EMPTY = Integer.MIN_VALUE;

        public int extractMinKey() {
            if (size == 0) {
                return EMPTY;
            } else {
                int res = key[0];
                swap(0, size - 1);
                size--;
                siftDown(0);
                return res;
            }
        }
//        public String toString() {
//            String res = "{" + "size=" + size + "|k,v|";
//            for (int i = 0; i < size; i++) {
//                res += key[i]+"("+idByInd[i]+") ";// + "," + value[i];
//            }
//            res += "}";
//            return res;
//        }
    }
//    /**
//     * Examples(n: res):
//     * 0: 0
//     * 1: 0
//     * 2: 1
//     * 3: 2
//     * 4: 2
//     * 5: 3
//     * 7: 3
//     * 8: 3
//     * 10:4
//     */
//    public static int logCeil(int n) {
//        int res = 0;
//        int pow = 1;
//        while (pow < n) {
//            pow *= 2;
//            res++;
//        }
//        return res;
//    }
//
//    private static class Tree<T> {
//
//        Object[] t;
//        Object[] push;
//        int n;
//        int capacity;
//        TreeType<T> tree;
//
//        public Tree(int capacity, T[] a, TreeType<T> tree) {
//            this.tree = tree;
//            n = 1;
//            while (n < capacity) {
//                n *= 2;
//            }
//            t = new Object[2 * n];
//            push = new Object[n];
//            this.capacity = capacity;
//            System.arraycopy(a, 0, t, n, capacity);
//            for (int i = n - 1; i >= 1; i--) {
//                t[i] = tree.calc((T) t[i * 2], (T) t[i * 2 + 1]);
//            }
//        }
//
//        public T getOnRange(int l, int r) {
//            l += n;
//            r += n;
//            return getOnRange(l, r, 1, n, 2 * n - 1);
//        }
//
//        public T getOnRange(int l, int r, int cur, int rl, int rr) {
//            if (cur >= n) {
//                return (T) t[cur];
//            }
//            push(cur);
//            if (l == rl && r == rr) {
//                return (T) t[cur];
//            }
//            int m = (rl + rr) / 2;
//            T res = null;
//            if (l <= m) {
//                res = tree.sum(res, getOnRange(l, Math.min(m, r), 2 * cur, rl, m));
//            }
//            if (r >= m + 1) {
//                res = tree.sum(res, getOnRange(Math.max(m + 1, l), r, 2 * cur + 1, m + 1, rr));
//            }
//            return res;
//        }
//
//        public T get(int ind) {
//            int cur = 1;
//            int rl = n;
//            int rr = 2 * n - 1;
//            while (cur < n) {
//                push(cur);
//                int m = (rl + rr) / 2;
//                if (ind <= m) {
//                    cur = 2 * ind;
//                    rr = m;
//                } else {
//                    cur = 2 * ind + 1;
//                    rl = m + 1;
//                }
//            }
//            return (T) t[cur];
//        }
//
//        public void add(T x, int ind) {
//            int cur = 1;
//            int rl = n;
//            int rr = 2 * n - 1;
//            while (cur < n) {
//                push(cur);
//                int m = (rl + rr) / 2;
//                if (ind <= m) {
//                    cur = 2 * ind;
//                    rr = m;
//                } else {
//                    cur = 2 * ind + 1;
//                    rl = m + 1;
//                }
//            }
//            t[cur] = tree.calc((T) t[cur], x);
//        }
//
//        private void push(int cur) {
//            if (!tree.isEmpty((T) push[cur])) {
//                for (int ch = 0; ch <= 1; ch++) {
//                    if (2 * cur + ch < n) {
//                        push[2 * cur + ch] = tree.calc((T)push[2 * cur + ch], (T)push[cur]);
//                    } else {
//                        t[2 * cur + ch] = tree.calc((T)t[2 * cur + ch], (T)push[cur]);
//                    }
//                }
//                push[cur] = null;
//            }
//        }
//    }
//
//    private static interface TreeType<T> {
//
//        public T calc(T a, T b);
//
//        public boolean isEmpty(T push);
//    }
}


import java.util.*;

public class Codeforces {

    public static int count(String p){
		int counts=0;
		for(int i=p.length()-1;i>=0;i--){

			if(p.charAt(i)!='0')
				return counts;
			else
				counts++;

		}

		return counts;
	}

	public static void main(String[] args) {

		Scanner sc=new Scanner(System.in);

		long n=sc.nextLong();
		int k=sc.nextInt();

		String p=""+n;

		if(count(p)>=k)
			System.out.println(n);
		else{
			//System.out.println("not term at first");

			int last=Integer.parseInt(""+p.charAt(p.length()-1));

			if(last==1 || last==3 || last==7 || last==9){

				for(int i=1;i<=k;i++)
					p=p+"0";

				System.out.println(p);

			}
			else{

				while(count(p)<k){
					//System.out.println("count was "+count(p));
					int index=-1;
					for(int i=p.length()-1;i>=0;i--){

						if(p.charAt(i)!='0'){
							index=i;
							break;
						}

					}

					last=Integer.parseInt(""+p.charAt(index));
					//System.out.println("last is "+last);
					if(last==2 || last==4 || last==6 || last==8){
						n=n*5;
						p=""+n;
					}
					else if(last==5){
						n=n*2;
						p=""+n;
					}
					else if(last==1 || last==3 || last==7 || last==9){
						int rem=k-count(p);
						for(int i=1;i<=rem;i++)
							p=p+"0";

						break;

					}

				}

				System.out.println(p);

			}

		}

	}
}


import java.util.Scanner;

public class VasyaTheHipster {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int m=scan.nextInt();
		if(n>m) {
			System.out.println(m);
			n=n-m;
			System.out.println(n/2);
		}
		else if(m>n) {
			System.out.println(n);
			m=m-n;
			System.out.println(m/2);
		}
		else if(n==m) {
			System.out.println(n);
		    System.out.println(n-m);
		}
	}

}


import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws IOException
    {
        BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));
        String temp[]=obj.readLine().split(" ");
        int arr[]=new int[temp.length];
        long total=0;
        for(int i=0;i<temp.length;i++)
        {
            arr[i]=Integer.parseInt(temp[i]);
            total+=arr[i];
        }
        if(total%2!=0)
        {System.out.println("NO");
        return;
        }
        if(possible(arr,total))
        System.out.println("YES");
        else
        System.out.println("NO");
    }
    public static boolean possible(int[] arr,long total)throws IOException
    {
        int n = arr.length;

        // Run a loop for printing all 2^n
        // subsets one by obe
        for (int i = 0; i < (1<<n); i++)
        {
            long sum=0;
            // Print current subset
            for (int j = 0; j < n; j++)
                {
                if ((i & (1 << j)) > 0)
                    sum+=arr[j];
                 }
            if(total==2*sum)
            return true;
    }
    return false;
    }
}


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

public class a {
	public static void main(String[] args) { new a(); }
	FS in = new FS();
	PrintWriter out = new PrintWriter(System.out);

	a() {
		int x = in.nextInt();
		if (x == 2) out.println(2);
		else out.println(1);
		out.close();
	}

	int abs(int x) { if (x < 0) return -x; return x; }
	long abs(long x) { if (x < 0) return -x; return x; }
	int max(int x, int y) { if (x < y) return y; return x; }
	int min(int x, int y) { if (x > y) return y; return x; }
	long max(long x, long y) { if (x < y) return y; return x; }
	long min(long x, long y) { if (x > y) return y; return x; }

	class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
		double nextDouble() { return Double.parseDouble(next()); }

		void intArr(int sz, int[] x) { for (int i = 0; i < sz; i++) x[i] = nextInt(); }
		void longArr(int sz, long[] x) { for (int i = 0; i < sz; i++) x[i] = nextLong(); }
		void doubleArr(int sz, double[] x) { for (int i = 0; i < sz; i++) x[i] = nextDouble(); }
	}
}


//package croc2012.qr;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;

public class D {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		int a = ni(), n = ni();
		int[] d = new int[a+n];
		for(int i = 0;i < a+n;i++){
			d[i] = i;
		}
		for(int i = 2;i * i < a+n;i++){
			for(int j = i*i;j < a+n;j+=i*i){
				d[j] = j / (i*i);
			}
		}

		long tot = 0;
		for(int i = a;i < a+n;i++){
			tot += d[i];
		}
		out.println(tot);
	}

	void run() throws Exception
	{
		is = oj ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		tr(System.currentTimeMillis()-s+"ms");
	}

	public static void main(String[] args) throws Exception
	{
		new D().run();
	}

	public int ni()
	{
		try {
			int num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public long nl()
	{
		try {
			long num = 0;
			boolean minus = false;
			while((num = is.read()) != -1 && !((num >= '0' && num <= '9') || num == '-'));
			if(num == '-'){
				num = 0;
				minus = true;
			}else{
				num -= '0';
			}

			while(true){
				int b = is.read();
				if(b >= '0' && b <= '9'){
					num = num * 10 + (b - '0');
				}else{
					return minus ? -num : num;
				}
			}
		} catch (IOException e) {
		}
		return -1;
	}

	public String ns()
	{
		try{
			int b = 0;
			StringBuilder sb = new StringBuilder();
			while((b = is.read()) != -1 && (b == '\r' || b == '\n' || b == ' '));
			if(b == -1)return "";
			sb.append((char)b);
			while(true){
				b = is.read();
				if(b == -1)return sb.toString();
				if(b == '\r' || b == '\n' || b == ' ')return sb.toString();
				sb.append((char)b);
			}
		} catch (IOException e) {
		}
		return "";
	}

	public char[] ns(int n)
	{
		char[] buf = new char[n];
		try{
			int b = 0, p = 0;
			while((b = is.read()) != -1 && (b == ' ' || b == '\r' || b == '\n'));
			if(b == -1)return null;
			buf[p++] = (char)b;
			while(p < n){
				b = is.read();
				if(b == -1 || b == ' ' || b == '\r' || b == '\n')break;
				buf[p++] = (char)b;
			}
			return Arrays.copyOf(buf, p);
		} catch (IOException e) {
		}
		return null;
	}

	double nd() { return Double.parseDouble(ns()); }
	boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


//package com.example.hackerranksolutions;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class CodeforcesProblems {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] inputs = br.readLine().split(" ");
        int a = Integer.parseInt(inputs[0]);
        int b = Integer.parseInt(inputs[1]);
        int r = Integer.parseInt(inputs[2]);

        if(a>=2*r && b>=2*r) System.out.println("First");
        else System.out.println("Second");
    }
}


import java.util.*;
import java.io.*;
public class code{
    public static void main(String[] args)throws IOException{
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        char[] c = sc.next().toCharArray();
        int[] d = new int[n];
        for(int i=0;i<n;i++) d[i] = (int)c[i];
        Coloring col = new Coloring(n,d);
        int res = col.get(0,n);
        System.out.println(res);
    }

    public static class Coloring{
        int[][] dp;
        int[] q;
        int n;
        int[] c;
        Coloring(int l,int[] tab){
            buildColor(l,tab);
            dp = new int[n][n];
            for(int i=0;i<n;i++) dp[i][i] = 1;
            for(int i=1;i<n;i++){
                for(int j=0;j<n-i;j++){
                    regle(dp,j,j+i);
                }
            }
        }
        void buildColor(int n,int[] tab){
            int[] d = new int[n];
            q = new int[n];
            int cnt = 0;
            int l = 1;
            d[0] = tab[0];
            for(int i=1;i<n;i++){
                q[i] = i-cnt;
                if(tab[i]==tab[i-1]){
                    cnt++;
                    q[i]--;
                    continue;
                }
                d[l] = tab[i];
                l++;
            }
            this.n = l;
            c = new int[l];
            for(int i=0;i<l;i++) c[i] = d[i];
        }
        void regle(int[][] dp,int l,int r){
            dp[l][r] = Math.min(dp[l][r-1]+1,dp[l+1][r]+1);
            if(c[l]==c[l+1]||c[l]==c[r]) dp[l][r] = Math.min(dp[l][r],dp[l+1][r]);
            if(c[r]==c[r-1]||c[r]==c[l]) dp[l][r] = Math.min(dp[l][r],dp[l][r-1]);
            for(int i=l+2;i<r;i++){
                if(c[l]==c[i]){
                    dp[l][r] = Math.min(dp[l][r],dp[l+1][i]+dp[i+1][r]);
                }
            }
            for(int i=r-2;i>l;i--){
                if(c[r]==c[i]){
                    dp[l][r] = Math.min(dp[l][r],dp[l][i-1]+dp[i][r-1]);
                }
            }
        }
        int get(int l,int r){
            return dp[q[l]][q[r-1]];
        }
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class a {
    /*
     * In a Programming contest, you are expected to print the output at the
     * end, so `output` variable will hold all the processed results till the
     * end
     */
    public static String output = "";

    // Program's starting point
    public static void main(String[] args) {

        /*
         * A Scanner class slows down Input/Output a LOT ,thereby increasing
         * your code execution time , Hence for best results that is Fast I/O
         * try to use BufferedReader
         */
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        /*
         * Generally Code Chef, Hacker Rank gives X number of test cases so we
         * process the input for each.
         */
        final int n;
        try {
            n = Integer.parseInt(br.readLine().trim());
            int[][] uni = new int[n][2];
            for(int i = 0; i < n; i++) {
                String[] s = br.readLine().split(" ");
                uni[i][0] = Integer.parseInt(s[0]);
                uni[i][1] = Integer.parseInt(s[1]);

            }

            /*
             * Logic of the program must be separated from the meta code to
             * increase readability and help debugging easier
             * Also note that Solver object is created inside for loop to
             * avoid multiple object creation that drastically increases
             * execution time and memory usage
             */
            Solver solver = new Solver();
            solver.solve(n, uni);

        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        // Print the final output
        System.out.println(output);
    }
}

class Solver {

    /*
     * Logic goes here ...
     * Add to the global variables after processing the input
     * Maybe reverse a string or parse to an integer or , etc.
     */
    public void solve(int n, int[][] uni) {
        int count = 0;
        for(int i = 0; i < n-1; i++) {
            for(int j = i+1; j < n; j++) {
                if(uni[i][0] == uni[j][1]) count++;
                if(uni[i][1] == uni[j][0]) count++;
            }
        }
        a.output = a.output.concat(String.valueOf(count));
    }

}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.sort;

public class Codeforces {
    static FastReader fastReader;
    static PrintWriter out;

    public static void main(String[] args) {
        fastReader = new FastReader();
        out = new PrintWriter(System.out);
         int tt = 1;
//        int tt = fastReader.nextInt();
        outer:while(tt -- > 0) {
            long n  = fastReader.nextLong();
            long x = fastReader.nextLong();
            Queue<Long> q = new LinkedList<>();
            q.add(x);
            HashMap<Long,Long> map = new HashMap<>();
            map.put(x,0L);
            while(!q.isEmpty()){
                long cur = q.remove();
                String s = String.valueOf(cur);
                if(s.length() == n){
                    out.println(map.get(cur));
                    break outer;
                }
                for(int i = 0 ; i < s.length() ; i++){
                    int mul = s.charAt(i) -'0';
                    if(mul < 2) continue;
                    long val = cur*(mul);
                    if(!map.containsKey(val)){
                        q.add(val);
                        map.put(val,map.get(cur)+1);
                    }
                }
            }
            out.println(-1);

        }
        out.close();
    }

    static class Pair{
        int index;
        int  val;
        Pair(int  index, int val){
            this.index = index;
            this.val = val;
        }

        @Override
        public String toString() {
            return "Pair{" +
                    "index=" + index +
                    ", val=" + val +
                    '}';
        }
    }

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final long LMAX = 9223372036854775807L;
    static Random __r = new Random();
    static int[][] direction = new int[][]{{-1,-1}, {-1,0}, {-1,1},  {0,1}, {1,1},  {1,0},  {1,-1},  {0, -1}};

    // math util
    static int minof(int a, int b, int c) {
        return min(a, min(b, c));
    }

    static int minof(int... x) {
        if (x.length == 1)
            return x[0];
        if (x.length == 2)
            return min(x[0], x[1]);
        if (x.length == 3)
            return min(x[0], min(x[1], x[2]));
        int min = x[0];
        for (int i = 1; i < x.length; ++i)
            if (x[i] < min)
                min = x[i];
        return min;
    }
    static char maxc(char a, char b){
        if(a > b){
            return a;
        }
        return b;
    }
    static long minof(long a, long b, long c) {
        return min(a, min(b, c));
    }

    static long minof(long... x) {
        if (x.length == 1)
            return x[0];
        if (x.length == 2)
            return min(x[0], x[1]);
        if (x.length == 3)
            return min(x[0], min(x[1], x[2]));
        long min = x[0];
        for (int i = 1; i < x.length; ++i)
            if (x[i] < min)
                min = x[i];
        return min;
    }

    static int maxof(int a, int b, int c) {
        return max(a, max(b, c));
    }

    static int maxof(int... x) {
        if (x.length == 1)
            return x[0];
        if (x.length == 2)
            return max(x[0], x[1]);
        if (x.length == 3)
            return max(x[0], max(x[1], x[2]));
        int max = x[0];
        for (int i = 1; i < x.length; ++i)
            if (x[i] > max)
                max = x[i];
        return max;
    }

    static long maxof(long a, long b, long c) {
        return max(a, max(b, c));
    }

    static long maxof(long... x) {
        if (x.length == 1)
            return x[0];
        if (x.length == 2)
            return max(x[0], x[1]);
        if (x.length == 3)
            return max(x[0], max(x[1], x[2]));
        long max = x[0];
        for (int i = 1; i < x.length; ++i)
            if (x[i] > max)
                max = x[i];
        return max;
    }

    static int powi(int a, int b) {
        if (a == 0)
            return 0;
        int ans = 1;
        while (b > 0) {
            if ((b & 1) > 0)
                ans *= a;
            a *= a;
            b >>= 1;
        }
        return ans;
    }

    static long powl(long a, int b) {
        if (a == 0)
            return 0;
        long ans = 1;
        while (b > 0) {
            if ((b & 1) > 0)
                ans *= a;
            a *= a;
            b >>= 1;
        }
        return ans;
    }

    static int fli(double d) {
        return (int) d;
    }

    static int cei(double d) {
        return (int) ceil(d);
    }

    static long fll(double d) {
        return (long) d;
    }

    static long cel(double d) {
        return (long) ceil(d);
    }

    static int gcd(int a, int b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    static int lcm(int a, int b) {
        return (a / gcd(a, b)) * b;
    }

    static long gcd(long a, long b) {
        return b == 0 ? a : gcd(b, a % b);
    }

    static long lcm(long a, long b) {
        return (a / gcd(a, b)) * b;
    }

    static int[] exgcd(int a, int b) {
        if (b == 0)
            return new int[] { 1, 0 };
        int[] y = exgcd(b, a % b);
        return new int[] { y[1], y[0] - y[1] * (a / b) };
    }

    static long[] exgcd(long a, long b) {
        if (b == 0)
            return new long[] { 1, 0 };
        long[] y = exgcd(b, a % b);
        return new long[] { y[1], y[0] - y[1] * (a / b) };
    }

    static int randInt(int min, int max) {
        return __r.nextInt(max - min + 1) + min;
    }

    static long mix(long x) {
        x += 0x9e3779b97f4a7c15L;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L;
        x = (x ^ (x >> 27)) * 0x94d049bb133111ebL;
        return x ^ (x >> 31);
    }

    public static boolean[] findPrimes(int limit) {
        assert limit >= 2;

        final boolean[] nonPrimes = new boolean[limit];
        nonPrimes[0] = true;
        nonPrimes[1] = true;

        int sqrt = (int) Math.sqrt(limit);
        for (int i = 2; i <= sqrt; i++) {
            if (nonPrimes[i])
                continue;
            for (int j = i; j < limit; j += i) {
                if (!nonPrimes[j] && i != j)
                    nonPrimes[j] = true;
            }
        }

        return nonPrimes;
    }

    // array util
    static void reverse(int[] a) {
        for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
            int swap = a[i];
            a[i] = a[n - i - 1];
            a[n - i - 1] = swap;
        }
    }

    static void reverse(long[] a) {
        for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
            long swap = a[i];
            a[i] = a[n - i - 1];
            a[n - i - 1] = swap;
        }
    }

    static void reverse(double[] a) {
        for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
            double swap = a[i];
            a[i] = a[n - i - 1];
            a[n - i - 1] = swap;
        }
    }

    static void reverse(char[] a) {
        for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {
            char swap = a[i];
            a[i] = a[n - i - 1];
            a[n - i - 1] = swap;
        }
    }

    static void shuffle(int[] a) {
        int n = a.length - 1;
        for (int i = 0; i < n; ++i) {
            int ind = randInt(i, n);
            int swap = a[i];
            a[i] = a[ind];
            a[ind] = swap;
        }
    }

    static void shuffle(long[] a) {
        int n = a.length - 1;
        for (int i = 0; i < n; ++i) {
            int ind = randInt(i, n);
            long swap = a[i];
            a[i] = a[ind];
            a[ind] = swap;
        }
    }

    static void shuffle(double[] a) {
        int n = a.length - 1;
        for (int i = 0; i < n; ++i) {
            int ind = randInt(i, n);
            double swap = a[i];
            a[i] = a[ind];
            a[ind] = swap;
        }
    }

    static void rsort(int[] a) {
        shuffle(a);
        sort(a);
    }

    static void rsort(long[] a) {
        shuffle(a);
        sort(a);
    }

    static void rsort(double[] a) {
        shuffle(a);
        sort(a);
    }

    static int[] copy(int[] a) {
        int[] ans = new int[a.length];
        for (int i = 0; i < a.length; ++i)
            ans[i] = a[i];
        return ans;
    }

    static long[] copy(long[] a) {
        long[] ans = new long[a.length];
        for (int i = 0; i < a.length; ++i)
            ans[i] = a[i];
        return ans;
    }

    static double[] copy(double[] a) {
        double[] ans = new double[a.length];
        for (int i = 0; i < a.length; ++i)
            ans[i] = a[i];
        return ans;
    }

    static char[] copy(char[] a) {
        char[] ans = new char[a.length];
        for (int i = 0; i < a.length; ++i)
            ans[i] = a[i];
        return ans;
    }

    static class FastReader {

        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(
                    new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        int[] ria(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = Integer.parseInt(next());
            return a;
        }

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

        long[] rla(int n) {
            long[] a = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = Long.parseLong(next());
            return a;
        }

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


import java.util.*;

public class cf113c {
	static int max = (int)3e8;
	static int halfmax = max/2;
	static byte[] seive;
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int a = in.nextInt();
		int b = in.nextInt();
		int ret = 0;
		if(a <= 2 && 2 <= b)
			ret++;
		while(a%4 != 1) a++;
		init();
		for(int i=a; i<=b; i+=4)
			if((seive[i>>4] & (1<<((i>>1)&7))) != 0)
				ret++;
		System.out.println(ret);
	}
	static void init() {
		int maxsqrt = (int)(Math.sqrt(max)/2);
		seive = new byte[max/16 + 2];
		Arrays.fill(seive, (byte)0xFF);
		seive[0] = (byte)0xFE;
		for(int i=1; i<maxsqrt; i++)
			if((seive[i>>3] & (1<<(i&7)))!=0)
				for(int j=i+i+i+1; j<halfmax; j+= i+i+1)
					seive[j>>3] &= ~(1<<(j&7));
	}
	static boolean isPrime(int n) {
		return (seive[n>>4] & (1<<((n>>1)&7))) != 0;
	}
}


import java.io.*;
import java.math.*;
import java.security.*;
import java.text.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.regex.*;

public class Solution {
    public static void main(String args[]){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int k=sc.nextInt();
        int a[]=new int[n];
        for(int i=0;i<n;i++){
            a[i]=sc.nextInt();

        }int c=0,i=0,j=n-1,k1=0;
        while(i<j){
            k1=0;
            if(k>=a[i]){
                i++;c++;
                k1=1;
            }
            if(k>=a[j]){
                j--;
                c++;
                k1=1;
            }
            if(k1==0)
                break;

        }
        if(i==j){
            if(k>=a[i])
                c++;
        }

        System.out.println(c);

}
}


import java.util.List;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.ArrayList;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.util.Queue;
import java.util.Collection;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC2 solver = new TaskC2();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskC2 {
	static class Edge {
		int to, f, cap, cost, rev;

		Edge(int v, int cap, int cost, int rev) {
			this.to = v;
			this.cap = cap;
			this.cost = cost;
			this.rev = rev;
		}
	}

	public static List<Edge>[] createGraph(int n) {
		List<Edge>[] graph = new List[n];
		for (int i = 0; i < n; i++)
			graph[i] = new ArrayList<Edge>();
		return graph;
	}

	public static void addEdge(List<Edge>[] graph, int s, int t, int cap, int cost) {
		graph[s].add(new Edge(t, cap, cost, graph[t].size()));
		graph[t].add(new Edge(s, 0, -cost, graph[s].size() - 1));
	}

	static int[] minCostFlow(List<Edge>[] graph, int s, int t, int maxf) {
		int n = graph.length;
		int[] prio = new int[n];
		int[] curflow = new int[n];
		int[] prevedge = new int[n];
		int[] prevnode = new int[n];
		int[] pot = new int[n];

		// bellmanFord can be safely commented if edges costs are non-negative
//		bellmanFord(graph, s, pot);
		int flow = 0;
		int flowCost = 0;
		while (flow < maxf) {
			Queue<Long> q = new PriorityQueue<Long>();
			q.add((long) s);
			Arrays.fill(prio, 0, n, Integer.MAX_VALUE);
			prio[s] = 0;
			curflow[s] = Integer.MAX_VALUE;
			while (!q.isEmpty()) {
				long cur = q.remove();
				int d = (int) (cur >>> 32);
				int u = (int) (cur & 0x7FFFFFFF);
				if (d != prio[u])
					continue;
				for (int i = 0; i < graph[u].size(); i++) {
					Edge e = graph[u].get(i);
					int v = e.to;
					if (e.cap <= e.f)
						continue;
					int nprio = prio[u] + e.cost + pot[u] - pot[v];
					if (prio[v] > nprio) {
						prio[v] = nprio;
						q.add(((long) nprio << 32) + v);
						prevnode[v] = u;
						prevedge[v] = i;
						curflow[v] = Math.min(curflow[u], e.cap - e.f);
					}
				}
			}
			if (prio[t] == Integer.MAX_VALUE)
				break;
			for (int i = 0; i < n; i++)
				pot[i] += prio[i];
			int df = Math.min(curflow[t], maxf - flow);
			flow += df;
			for (int v = t; v != s; v = prevnode[v]) {
				Edge e = graph[prevnode[v]].get(prevedge[v]);
				e.f += df;
				graph[v].get(e.rev).f -= df;
				flowCost += df * e.cost;
			}
		}
		return new int[]{flow, flowCost};
	}

	public void solve(int testNumber, InputReader in, PrintWriter out) {
		int n = in.nextInt();
		int m = in.nextInt();
		int[][] a = new int[n][m];
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				a[i][j] = in.nextInt();
			}
		}

		final List<Edge>[] g = createGraph(n * m + 2);
		int s = n * m;
		int t = s + 1;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				if ((i + j) % 2 == 1) {
					addEdge(g, s, i * m + j, 1, 0);
					int dx[] = {1, -1, 0, 0};
					int dy[] = {0, 0, 1, -1};
					for (int k = 0; k < 4; k++) {
						int ni = i + dx[k];
						int nj = j + dy[k];

						if (0 <= ni && ni < n && 0 <= nj && nj < m) {
							addEdge(g, i * m + j, ni * m + nj, 1, a[i][j] != a[ni][nj] ? 1 : 0);
						}
					}
				} else {
					addEdge(g, i * m + j, t, 1, 0);
				}
			}
		}
		int[] res = minCostFlow(g, s, t, Integer.MAX_VALUE);
		int flow = res[0];
		int flowCost = res[1];
		out.println(flowCost);
	}
}

class InputReader {
	public BufferedReader reader;
	public StringTokenizer tokenizer;

	public InputReader(InputStream stream) {
		reader = new BufferedReader(new InputStreamReader(stream));
	}

	public String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

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


import java.util.*;

public class Solution {

  private static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int n = sc.nextInt(), k = sc.nextInt(), t = sc.nextInt();
    if (t <= k) {
      System.out.println(t);
    } else if (t >= n) {
      System.out.println(k + n - t);
    } else {
      System.out.println(k);
    }
  }

}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;

public class E {

    static StreamTokenizer st;
    static PrintWriter pw;

    private static int nextInt() throws IOException {
        st.nextToken();
        return (int) st.nval;
    }

    public static void main(String[] args) throws IOException {
        st = new StreamTokenizer(new BufferedReader(new InputStreamReader(
                System.in)));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
                System.out)));
        // -----------begin-------------------------
        int n = nextInt();
        int a[][] = new int[n + 1][n + 1];
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                a[i][j] = nextInt();
            }
        }
        int sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += a[i][i];
            sum += a[i][n - i + 1];

        }
        for (int i = 1; i <= n; i++) {
            sum += a[i][(n + 1) / 2];
            sum += a[(n + 1) / 2][i];
        }
        pw.print(sum-3*a[(n+1)/2][(n+1)/2]);
        pw.close();
        // ------------end--------------------------
    }
}


//package com.company;

import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
       int d1=input.nextInt(),d2=input.nextInt(),d3=input.nextInt();
        System.out.println(Math.min(d1,d2+d3)+Math.min(d2,d3+d1)+Math.min(d3,d1+d2));
    }
}


import java.util.Scanner;

public class q6 {
	public static void main(String args[]){
	Scanner scr=new Scanner(System.in);
	int m=scr.nextInt();
	int n=scr.nextInt();

	if(m>=2 || n>=2){

		System.out.println((m*n)/2);
	}
	else
System.out.println(0);
	}
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {

    //const int N = 5e4 + 5, M = 1e5+5, OO = 0x3f3f3f3f;

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        long n = input.nextInt();
        long m = input.nextInt();
        long [] nArr = new long[5];
        long [] mArr = new long[5];
        Arrays.fill(nArr,0);
        Arrays.fill(mArr,0);
        for (long i = 1; i <= n; i++) {
            nArr[(int) (i%5)]++;
        }

        for (long i = 1; i <= m; i++) {
            mArr[(int) (i%5)]++;
        }

        System.out.println(nArr[0] * mArr[0] + nArr[1] * mArr[4] + nArr[4] * mArr[1] + nArr[3] * mArr[2] +nArr[2] * mArr[3]);
    }
}


import java.util.*;
import java.io.*;
//267630EY
public class Main259B2
{
  static PrintWriter out=new PrintWriter(System.out);

  public static void main(String[] args) throws IOException
  {
    Scanner sc=new Scanner(System.in);
    int[][] a=new int[3][3];
    for(int i=0;i<3;i++)
    {
      for(int j=0;j<3;j++)
        a[i][j]=sc.nextInt();
    }
    int first=a[0][1]+a[0][2];
    int second=a[1][0]+a[1][2];
    int third=a[2][0]+a[2][1];
    int fourth=(first+second+third)/2;
    a[0][0]=fourth-first;
    a[1][1]=fourth-second;
    a[2][2]=fourth-third;
    for(int i=0;i<3;i++)
    {
      for(int j=0;j<3;j++)
      {
        out.print(a[i][j]+" ");
      }
      out.println();
    }
    out.flush();

  }

  static class Scanner
  {
    BufferedReader br;
    StringTokenizer tk=new StringTokenizer("");
    public Scanner(InputStream is)
        {
      br=new BufferedReader(new InputStreamReader(is));
    }
        public int nextInt() throws IOException
        {
          if(tk.hasMoreTokens())
                return Integer.parseInt(tk.nextToken());
          tk=new StringTokenizer(br.readLine());
          return nextInt();
        }
        public long nextLong() throws IOException
        {
            if(tk.hasMoreTokens())
              return Long.parseLong(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextLong();
        }
        public String next() throws IOException
        {
          if(tk.hasMoreTokens())
            return (tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return next();
        }
        public String nextLine() throws IOException
        {
          tk=new StringTokenizer("");
          return br.readLine();
        }
        public double nextDouble() throws IOException
        {
            if(tk.hasMoreTokens())
              return Double.parseDouble(tk.nextToken());
            tk=new StringTokenizer(br.readLine());
            return nextDouble();
        }
        public char nextChar() throws IOException
        {
            if(tk.hasMoreTokens())
              return (tk.nextToken().charAt(0));
            tk=new StringTokenizer(br.readLine());
            return nextChar();
        }
        public int[] nextIntArray(int n) throws IOException
        {
            int a[]=new int[n];
            for(int i=0;i<n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArray(int n) throws IOException
        {
          long a[]=new long[n];
            for(int i=0;i<n;i++)
              a[i]=nextLong();
            return a;
        }
        public int[] nextIntArrayOneBased(int n) throws IOException
        {
          int a[]=new int[n+1];
            for(int i=1;i<=n;i++)
              a[i]=nextInt();
            return a;
        }
        public long[] nextLongArrayOneBased(int n) throws IOException
        {
          long a[]=new long[n+1];
          for(int i=1;i<=n;i++)
                a[i]=nextLong();
          return a;
        }
  }
}


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class D1 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt();
        long k = s.nextLong();

        List<Integer> result = getCanonicalPermutation(n, k);
        StringBuilder builder = new StringBuilder();
        builder.append(result.get(0));
        for (int i = 1; i < result.size(); ++i) {
            builder.append(" ").append(result.get(i));
        }
        System.out.println(builder.toString());
    }

    private static List<Integer> getCanonicalPermutation(int length, long order) {
        List<Integer> result = new ArrayList<>();
        if (length == 1) {
            result.add(1);
            return result;
        }
        long[] cLen = new long[length];
        cLen[0] = 1;
        cLen[1] = 2;
        for (int i = 2; i < length; ++i) {
            cLen[i] = cLen[i - 2] + cLen[i -1];
        }
        int currentLength = length;
        for (int i = 0; i < length;) {
            if (currentLength == 1) {
                result.add(i + 1);
                break;
            }
            long remainder = currentLength > 2 ? cLen[currentLength - 1] - cLen[currentLength - 3] : 1;
            boolean shouldSwap = order > remainder;
            if (shouldSwap) {
                result.add(i + 2);
                result.add(i + 1);
                i += 2;
                currentLength -= 2;
                order -= remainder;
            } else {
                result.add(i + 1);
                i++;
                currentLength--;
            }
        }
        return result;
    }
}


import java.io.IOException;
import java.util.InputMismatchException;

public class DrazilAndFactorial {
    public static void main(String[] args) {
        FasterScanner sc = new FasterScanner();

        int N = sc.nextInt();
        String A = sc.nextString();

        int[] freq = new int[10];
        for (int i = 0; i < N; i++) {
        	int d = A.charAt(i) - '0';
        	if (d == 4) {
        		freq[2] += 2;
        		freq[3]++;
        	} else if (d == 6) {
        		freq[3]++;
        		freq[5]++;
        	} else if (d == 8) {
        		freq[2] += 3;
        		freq[7]++;
        	} else if (d == 9) {
        		freq[2]++;
        		freq[3] += 2;
        		freq[7]++;
        	} else {
        		freq[d]++;
        	}
        }

        StringBuilder sb = new StringBuilder();
        for (int i = 9; i >= 2; i--) {
        	sb.append(rep(i, freq[i]));
        }
        System.out.println(sb.toString());
    }

    public static StringBuilder rep(int d, int r) {
    	StringBuilder sb = new StringBuilder();
    	for (int i = 0; i < r; i++) {
    		sb.append(d);
    	}
    	return sb;
    }

	public static class FasterScanner {
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;

		public int read() {
			if (numChars == -1)
				throw new InputMismatchException();
			if (curChar >= numChars) {
				curChar = 0;
				try {
					numChars = System.in.read(buf);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndOfLine(c));
			return res.toString();
		}

		public String nextString() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		public long nextLong() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

		public int nextInt() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-') {
				sgn = -1;
				c = read();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			} while (!isSpaceChar(c));
			return res * sgn;
		}

	    public int[] nextIntArray(int n) {
	        int[] arr = new int[n];
	        for (int i = 0; i < n; i++) {
	            arr[i] = nextInt();
	        }
	        return arr;
	    }

		public long[] nextLongArray(int n) {
		    long[] arr = new long[n];
		    for (int i = 0; i < n; i++) {
		        arr[i] = nextLong();
		    }
		    return arr;
		}

	    private boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		private boolean isEndOfLine(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}
	}
}


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

public class Main {

    public static void main(String[] args) {
        InputStreamReader ir = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(ir);
        String line;
        String[] ar;
        try {
            int r, c, n, k;
            ar = br.readLine().split(" ");
            r = Integer.parseInt(ar[0]);
            c = Integer.parseInt(ar[1]);
            n = Integer.parseInt(ar[2]);
            k = Integer.parseInt(ar[3]);
            int[][] g = new int[r + 1][c + 1];
            for (int i = 0; i < n; i++) {
                ar = br.readLine().split(" ");
                int a = Integer.parseInt(ar[0]);
                int b = Integer.parseInt(ar[1]);
                g[a][b] = 1;
            }
            for (int i = 1; i <= r; i++) {
                for (int j = 1; j <= c; j++) {
                    g[i][j] = g[i - 1][j] + g[i][j - 1] - g[i - 1][j - 1] + g[i][j];
                }
            }
            int ans = 0;
            for (int r1 = 1; r1 <= r; r1++) {
                for (int c1 = 1; c1 <= c; c1++) {
                    for (int r2 = r1; r2 <= r; r2++) {
                        for (int c2 = c1; c2 <= c; c2++) {
                            int v = g[r2][c2] - g[r2][c1 - 1] - g[r1 - 1][c2] + g[r1 - 1][c1 - 1];
                            if (v >= k) {
                                ans++;
                            }
                        }
                    }
                }
            }
            System.out.println(ans);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
}


import java.util.Scanner;

/**
 *
 * @author Annie
 */
public class Sticks {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner s = new Scanner(System.in);
        int a[] = new int[6];
        int y=0,no=0;
        for(int i=0;i<6;i++){
        a[i]=s.nextInt();
        }

        int b[] = new int[10];

        for(int i=0;i<6;i++){
        int x = a[i];
          b[x]++;
        }

        for(int i=1;i<10;i++){
        if(b[i]==4){

        for(int j=1;j<10;j++){
        if(b[j]==2){
            y++;
        }
        else{
         int x=1;
        }
        }

        }//if closed

        else if(b[i]>4){
        if(b[i]==6){
        y++;
        }
        else{
        int x=1;
        }
        }

        else{
        no++;
        }

        }//for closed

        if(no==9){

        System.out.println("Alien");
                }
        else{
        if(y==1){
        System.out.println("Elephant");
        }
        else{
        System.out.println("Bear");
        }

        }

    }

}


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

public class Main {
    private static StringTokenizer st;
    private static BufferedReader br;

    public static void print(Object x) {
        System.out.println(x + "");
    }
    public static String join(List<?> x, String space) {
        StringBuilder sb = new StringBuilder();
        for (Object elt : x) {
            sb.append(elt);
            sb.append(space);
        }
        return sb.toString();
    }

    public static String nextToken() throws IOException {
        while (st == null || !st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine().trim());
        }
        return st.nextToken();
    }
    public static int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    public static long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }

    public static class Env {
        int w;
        int h;
        int num;

        public Env(int w, int h, int num) {
            this.w = w;
            this.h = h;
            this.num = num;
        }
    }

    public static long sumTo(long x) {
        return (x + 1)*x / 2;
    }

    public static long sumFrom(long x, long y) {
        //x+1...y
        return sumTo(y) - sumTo(x);
    }

    public static String solve(long n, long k) {
        k -= 1;
        n -= 1;
        if (sumTo(k) < n) {
            return "-1";
        }

        long j = Math.max(0, (long) Math.sqrt((k + 1) * k - 2 * n));
        j = Math.min(j, k);
        while (sumFrom(j, k) < n) {
            j--;
        }
        while (sumFrom(j, k) > n) {
            j++;
        }
        //j+1...k <= n
        //print(j + " " + k + " = " + sumFrom(j, k));
        if (sumFrom(j, k) == n) {
            return "" + (k - j);
        } else {
            return "" + (k - j + 1);
        }
    }

    public static void main(String[] args) throws Exception {
        boolean debug = false;
        InputStream in = System.in;
        if (debug) {
            in = new FileInputStream("input.in");
        }
        br = new BufferedReader(new InputStreamReader(in));
        long n = nextLong();
        long k = nextLong();
        print(solve(n, k));
    }
}


import java.util.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int x1=sc.nextInt();
    int y1=sc.nextInt();
    int x2=sc.nextInt();
    int y2=sc.nextInt();
    int h=0,v=0;
    h=Math.abs(x1-x2);
    v=Math.abs(y1-y2);
    if(x1==x2)
    h=(h+1)*2;
    else
    h+=1;
    if(y1==y2)
    v=(v+1)*2;
    else
    v+=1;
    System.out.println((h+v)*2);
  }
}


/**
 * ******* Created  on 10/3/20 4:12 PM*******
 */

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

public class B29 implements Runnable {

    private static final int MAX = (int) (1E5 + 5);
    private static final int MOD = (int) (1E9 + 7);
    private static final long Inf = (long) (1E14 + 10);

    private void solve() throws IOException {
        int l= reader.nextInt();
        int d = reader.nextInt();
        int v = reader.nextInt();
        int g = reader.nextInt();
        int r = reader.nextInt();

        double time = (double) d/v;
        time %= (r+g);
        double ans =0.0;
        if(time >=g)
            ans+=( r+g -time);

        ans += ((double) l/v);
        writer.println(ans );
    }

    public static void main(String[] args) throws IOException {
        try (Input reader = new StandardInput(); PrintWriter writer = new PrintWriter(System.out)) {
            new B29().run();
        }
    }

    StandardInput reader;
    PrintWriter writer;

    @Override
    public void run() {
        try {
            reader = new StandardInput();
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    interface Input extends Closeable {
        String next() throws IOException;

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

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

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

        default int[] readIntArray() throws IOException {
            return readIntArray(nextInt());
        }

        default int[] readIntArray(int size) throws IOException {
            int[] array = new int[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = nextInt();
            }
            return array;
        }

        default long[] readLongArray(int size) throws IOException {
            long[] array = new long[size];
            for (int i = 0; i < array.length; i++) {
                array[i] = nextLong();
            }
            return array;
        }
    }

    private static class StandardInput implements Input {
        private final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

        private StringTokenizer stringTokenizer;

        @Override
        public void close() throws IOException {
            reader.close();
        }

        @Override
        public String next() throws IOException {
            if (stringTokenizer == null || !stringTokenizer.hasMoreTokens()) {
                stringTokenizer = new StringTokenizer(reader.readLine());
            }
            return stringTokenizer.nextToken();
        }
    }
}


import java.util.Collections;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Scanner;

public class card_game {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		PriorityQueue<Integer> pq = new PriorityQueue<>(Collections.reverseOrder());
		int n = scn.nextInt();
		int m = scn.nextInt();
		int k = scn.nextInt();
		int a[] = new int[n];

		for (int i = 0; i < n; i++) {
			a[i] = scn.nextInt();
			pq.add(a[i]);
		}
		if (k >= m) {
			System.out.println(0);
		} else {
			int sok = k;
			int count = 0;
			while (pq.size() > 0 && sok < m) {
				sok = sok - 1 + pq.poll();
				count++;
			}
			if (pq.size() == 0 && sok < m) {
				System.out.println(-1);
			} else {
				System.out.println(count);
			}

		}

	}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class AlexAndARhombus1180A {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int t = Integer.parseInt(sc.nextLine());
        System.out.println(solve(t));

    }
    private static int solve(int n) {
        if (n == 1) return n;
        return 4 * (n - 1) + solve(n - 1);
    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author zodiacLeo
 */
public class Main
{
    public static void main(String[] args)
    {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        FastPrinter out = new FastPrinter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA
    {
        public void solve(int testNumber, FastScanner in, FastPrinter out)
        {
            String before = in.next();
            String after = before.replaceAll("VK", "-");
            int cnt = (before.length() - after.length());
            if (after.length() >= 2)
            {
                int index = after.indexOf("VV");
                if (index >= 0 && index < after.length())
                {
                    cnt++;
                    out.println(cnt);
                    return;
                }

                index = after.lastIndexOf("KK");
                if (index >= 0 && index < after.length())
                {
                    cnt++;
                    out.println(cnt);
                    return;
                }
            }
            out.println(cnt);
        }

    }

    static class FastScanner
    {
        public BufferedReader br;
        public StringTokenizer st;

        public FastScanner(InputStream is)
        {
            br = new BufferedReader(new InputStreamReader(is));
        }

        public FastScanner(File f)
        {
            try
            {
                br = new BufferedReader(new FileReader(f));
            } catch (FileNotFoundException e)
            {
                e.printStackTrace();
            }
        }

        public String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                String s = null;
                try
                {
                    s = br.readLine();
                } catch (IOException e)
                {
                    e.printStackTrace();
                }
                if (s == null)
                    return null;
                st = new StringTokenizer(s);
            }
            return st.nextToken();
        }

    }

    static class FastPrinter extends PrintWriter
    {
        public FastPrinter(OutputStream out)
        {
            super(out);
        }

        public FastPrinter(Writer out)
        {
            super(out);
        }

    }
}


import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner scn=new Scanner(System.in);
        int k=scn.nextInt();
        int l=scn.nextInt();
        int m=scn.nextInt();
        int n=scn.nextInt();
        int d=scn.nextInt();
        int arr[]=new int[d+1];
        for(int i=k;i<arr.length;i+=k) {
            arr[i]=1;
        }
        for(int i=l;i<arr.length;i+=l) {
            arr[i]=1;
        }
        for(int i=m;i<arr.length;i+=m) {
            arr[i]=1;
        }
        for(int i=n;i<arr.length;i+=n) {
            arr[i]=1;
        }
        int ans=0;
        for(int i=1;i<arr.length;i++) {
            if(arr[i]==1)
                ans++;
        }
        System.out.println(ans);
    }
}