import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
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;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long[] abc = new long[3];
            long max = 0;
            int maxIndex = 0;
            for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            }

            int k = in.nextInt();

            for (int i = 0; i < k; i++) abc[maxIndex] *= 2;

            long ans = 0;
            for (int i = 0; i < 3; i++) ans += abc[i];

            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}
 import java.io.OutputStream; OutputStream java.io import java.io.IOException; IOException java.io import java.io.InputStream; InputStream java.io import java.io.PrintWriter; PrintWriter java.io import java.io.IOException; IOException java.io import java.util.NoSuchElementException; NoSuchElementException java.util import java.io.InputStream; InputStream java.io public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long[] abc = new long[3];
            long max = 0;
            int maxIndex = 0;
            for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            }

            int k = in.nextInt();

            for (int i = 0; i < k; i++) abc[maxIndex] *= 2;

            long ans = 0;
            for (int i = 0; i < 3; i++) ans += abc[i];

            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
} Main public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    } main {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    } InputStream inputStream = System.in; inputStream System.in System System.in OutputStream outputStream = System.out; outputStream System.out System System.out FasterScanner in = new FasterScanner(inputStream); in new FasterScanner(inputStream) PrintWriter out = new PrintWriter(outputStream); out new PrintWriter(outputStream) TaskB solver = new TaskB(); solver new TaskB() solver.solve(1, in, out) solver.solve solver 1 in out out.close() out.close out String[] args args static class TaskB {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long[] abc = new long[3];
            long max = 0;
            int maxIndex = 0;
            for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            }

            int k = in.nextInt();

            for (int i = 0; i < k; i++) abc[maxIndex] *= 2;

            long ans = 0;
            for (int i = 0; i < 3; i++) ans += abc[i];

            out.println(ans);
        }

    } TaskB public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long[] abc = new long[3];
            long max = 0;
            int maxIndex = 0;
            for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            }

            int k = in.nextInt();

            for (int i = 0; i < k; i++) abc[maxIndex] *= 2;

            long ans = 0;
            for (int i = 0; i < 3; i++) ans += abc[i];

            out.println(ans);
        } solve {
            long[] abc = new long[3];
            long max = 0;
            int maxIndex = 0;
            for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            }

            int k = in.nextInt();

            for (int i = 0; i < k; i++) abc[maxIndex] *= 2;

            long ans = 0;
            for (int i = 0; i < 3; i++) ans += abc[i];

            out.println(ans);
        } long[] abc = new long[3]; abc new long[3] 3 long max = 0; max 0 int maxIndex = 0; maxIndex 0 for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            } int i = 0; int i = 0; i 0 i < 3 i 3 i++ i++ i {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            } {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            } abc[i] = in.nextLong() abc[i] abc i in.nextLong() in.nextLong in if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                } abc[i] > max abc[i] abc i max {
                    max = abc[i];
                    maxIndex = i;
                } max = abc[i] max abc[i] abc i maxIndex = i maxIndex i int k = in.nextInt(); k in.nextInt() in.nextInt in for (int i = 0; i < k; i++) abc[maxIndex] *= 2; int i = 0; int i = 0; i 0 i < k i k i++ i++ i abc[maxIndex] *= 2; abc[maxIndex] *= 2 abc[maxIndex] abc maxIndex 2 long ans = 0; ans 0 for (int i = 0; i < 3; i++) ans += abc[i]; int i = 0; int i = 0; i 0 i < 3 i 3 i++ i++ i ans += abc[i]; ans += abc[i] ans abc[i] abc i out.println(ans) out.println out ans int testNumber testNumber FasterScanner in in PrintWriter out out static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    } FasterScanner private InputStream in; in private byte[] buffer; buffer private int bufPointer; bufPointer private int bufLength; bufLength public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        } FasterScanner {
            this.in = in;
            buffer = new byte[1024];
        } this.in = in this.in this this.in in buffer = new byte[1024] buffer new byte[1024] 1024 InputStream in in private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        } hasNextByte {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        } if (bufPointer < bufLength) return true; bufPointer < bufLength bufPointer bufLength return true; true bufPointer = 0 bufPointer 0 try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            } IOException e {
                e.printStackTrace();
            } e.printStackTrace() e.printStackTrace e {
                bufLength = in.read(buffer);
            } bufLength = in.read(buffer) bufLength in.read(buffer) in.read in buffer return (bufLength > 0); (bufLength > 0) bufLength 0 private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        } readByte {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        } if (hasNextByte()) return buffer[bufPointer++]; hasNextByte() hasNextByte return buffer[bufPointer++]; buffer[bufPointer++] buffer bufPointer++ bufPointer return -1; -1 1 private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        } isPrintableChar {
            return (c >= 33 && c <= 126);
        } return (c >= 33 && c <= 126); (c >= 33 && c <= 126) c >= 33 c 33 c <= 126 c 126 int c c public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        } hasNext {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        } while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++; hasNextByte() && !isPrintableChar(buffer[bufPointer]) hasNextByte() hasNextByte !isPrintableChar(buffer[bufPointer]) isPrintableChar(buffer[bufPointer]) isPrintableChar buffer[bufPointer] buffer bufPointer bufPointer++ bufPointer return hasNextByte(); hasNextByte() hasNextByte public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        } nextInt {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        } long nl = nextLong(); nl nextLong() nextLong if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException(); nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE nl < Integer.MIN_VALUE nl Integer.MIN_VALUE Integer Integer.MIN_VALUE nl > Integer.MAX_VALUE nl Integer.MAX_VALUE Integer Integer.MAX_VALUE throw new NumberFormatException(); new NumberFormatException() return (int) nl; (int) nl public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        } nextLong {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        } if (!hasNext()) throw new NoSuchElementException(); !hasNext() hasNext() hasNext throw new NoSuchElementException(); new NoSuchElementException() long n = 0; n 0 boolean minus = false; minus false int b = readByte(); b readByte() readByte if (b == '-') {
                minus = true;
                b = readByte();
            } b == '-' b '-' {
                minus = true;
                b = readByte();
            } minus = true minus true b = readByte() b readByte() readByte if (b < '0' || b > '9') throw new NumberFormatException(); b < '0' || b > '9' b < '0' b '0' b > '9' b '9' throw new NumberFormatException(); new NumberFormatException() while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            } true {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            } if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                } b >= '0' && b <= '9' b >= '0' b '0' b <= '9' b '9' {
                    n *= 10;
                    n += b - '0';
                } n *= 10 n 10 n += b - '0' n b - '0' b '0' if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                } b == -1 || !isPrintableChar(b) b == -1 b -1 1 !isPrintableChar(b) isPrintableChar(b) isPrintableChar b {
                    return minus ? -n : n;
                } return minus ? -n : n; minus ? -n : n minus -n n n {
                    throw new NumberFormatException();
                } throw new NumberFormatException(); new NumberFormatException() b = readByte() b readByte() readByte public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long[] abc = new long[3];
            long max = 0;
            int maxIndex = 0;
            for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            }

            int k = in.nextInt();

            for (int i = 0; i < k; i++) abc[maxIndex] *= 2;

            long ans = 0;
            for (int i = 0; i < 3; i++) ans += abc[i];

            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
} public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long[] abc = new long[3];
            long max = 0;
            int maxIndex = 0;
            for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            }

            int k = in.nextInt();

            for (int i = 0; i < k; i++) abc[maxIndex] *= 2;

            long ans = 0;
            for (int i = 0; i < 3; i++) ans += abc[i];

            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
} Main
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.util.NoSuchElementException;
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;
        FasterScanner in = new FasterScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FasterScanner in, PrintWriter out) {
            long[] abc = new long[3];
            long max = 0;
            int maxIndex = 0;
            for (int i = 0; i < 3; i++) {
                abc[i] = in.nextLong();
                if (abc[i] > max) {
                    max = abc[i];
                    maxIndex = i;
                }
            }

            int k = in.nextInt();

            for (int i = 0; i < k; i++) abc[maxIndex] *= 2;

            long ans = 0;
            for (int i = 0; i < 3; i++) ans += abc[i];

            out.println(ans);
        }

    }

    static class FasterScanner {
        private InputStream in;
        private byte[] buffer;
        private int bufPointer;
        private int bufLength;

        public FasterScanner(InputStream in) {
            this.in = in;
            buffer = new byte[1024];
        }

        private boolean hasNextByte() {
            if (bufPointer < bufLength) return true;
            bufPointer = 0;
            try {
                bufLength = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            return (bufLength > 0);
        }

        private int readByte() {
            if (hasNextByte()) return buffer[bufPointer++];
            return -1;
        }

        private static boolean isPrintableChar(int c) {
            return (c >= 33 && c <= 126);
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[bufPointer])) bufPointer++;
            return hasNextByte();
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }

        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9') throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}

