public class E {

	private final static boolean autoflush = false;

	long [][] A = {
			{ 1, 0, 0, 0, 0, 0 },
			{ 1, 1, 0, 0, 0, 0 },
			{ 2, 1, 2, 1, 1, 0 },
			{ 2, 1, 1, 2, 0, 1 },
			{ 2, 1, 1, 1, 1, 0 },
			{ 2, 1, 1, 1, 0, 1 }
	};

	public E () {
		int N = sc.nextInt();
		int X = sc.nextInt() - 1;
		int Y = sc.nextInt() - 1;
		int VX = sc.nextInt();
		int VY = sc.nextInt();
		long T = sc.nextLong();

		long [] V = { 1, 0, X, Y, VX, VY };
		long [] W = prod(pow(A, T, N), V, N);
		exit(W[2] + 1, W[3] + 1);
	}

	long [] prod(long [][] A, long [] V, long mod) {
		long [][] W = new long [V.length][1];
		for (int i : rep(V.length))
			W[i][0] = V[i];
		long [][] X = prod(A, W, mod);
		long [] res = new long [X.length];
		for (int i : rep(X.length))
			res[i] = X[i][0];
		return res;
	}

	long [][] sum (long [][] A, long [][] B, long mod) {
		int M = A.length, K = A[0].length, N = B[0].length;
		assert(K == B.length);
		long [][] res = new long [M][N];

		for (int i = 0; i < M; ++i)
			for (int j = 0; j < N; ++j)
				res[i][j] = mod(A[i][j] + B[i][j], mod);
		return res;
	}

	long [][] prod (long [][] A, long [][] B, long mod) {
		int M = A.length, K = A[0].length, N = B[0].length;
		assert(K == B.length);
		long [][] res = new long [M][N];

		for (int i = 0; i < M; ++i)
			for (int j = 0; j < N; ++j)
				for (int k = 0; k < K; ++k)
					res[i][j] = mod(res[i][j] + A[i][k] * B[k][j], mod);
		return res;
	}

	long [][] pow (long [][] A, long e, long mod) {
		long [][] res = id(A.length);
		if (e > 0) {
			int M = 1 + Long.numberOfTrailingZeros(Long.highestOneBit(e));
			long [][][] P = new long[M][][]; P[0] = A;
			for (int i : rep(1, M))
				P[i] = prod(P[i-1], P[i-1], mod);
			for (int i : rep(M))
				if ((e & (1 << i)) != 0)
					res = prod(res, P[i], mod);
		}
		return res;
	}

	long [][] id (int N) {
		long [][] res = new long [N][N];
		for (int i : rep(N))
			res[i][i] = 1;
		return res;
	}

	///////////////////////////////////////////////////////////////////////////
	private static int [] rep(int N) { return rep(0, N); }
	private static int [] rep(int S, int T) { if (T <= S) return new int [0]; int [] res = new int [T-S]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	private static long mod(long x, long mod) { return ((x % mod) + mod) % mod; }
	////////////////////////////////////////////////////////////////////////////////////
	private final static MyScanner sc = new MyScanner();
	private static class MyScanner {
		public String next() { newLine(); return line[index++]; }
		public int nextInt() { return Integer.parseInt(next()); }
		public long nextLong() { return Long.parseLong(next()); }
		//////////////////////////////////////////////
		private boolean eol() { return index == line.length; }
		private String readLine() {
			try {
				return r.readLine();
			} catch (Exception e) {
				throw new Error (e);
			}
		}
		private final java.io.BufferedReader r;
		private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
		private MyScanner (java.io.BufferedReader r) {
			try {
				this.r = r;
				while (!r.ready())
					Thread.sleep(1);
				start();
			} catch (Exception e) {
				throw new Error(e);
			}
		}
		private String [] line;
		private int index;
		private void newLine() {
			if (line == null || eol()) {
				line = readLine().split(" ");
				index = 0;
			}
		}
	}
	private static void print (Object o, Object... a) { printDelim(" ", o, a); }
	private static void printDelim (String delim, Object o, Object... a) { pw.println(build(delim, o, a)); }
	private static void exit (Object o, Object... a) { print(o, a); exit(); }
	private static void exit() {
		pw.close();
		System.out.flush();
		System.err.println("------------------");
		System.err.println("Time: " + ((millis() - t) / 1000.0));
		System.exit(0);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static String build (String delim, Object o, Object... a) {
		StringBuilder b = new StringBuilder();
		append(b, o, delim);
		for (Object p : a)
			append(b, p, delim);
		return b.substring(delim.length());
	}
	private static void append(StringBuilder b, Object o, String delim) {
		if (o.getClass().isArray()) {
			int L = java.lang.reflect.Array.getLength(o);
			for (int i = 0; i < L; ++i)
				append(b, java.lang.reflect.Array.get(o, i), delim);
		} else if (o instanceof Iterable<?>)
			for (Object p : (Iterable<?>)o)
				append(b, p, delim);
		else
			b.append(delim).append(o);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static void start() { t = millis(); }
	private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out, autoflush);
	private static long t;
	private static long millis() { return System.currentTimeMillis(); }
	public static void main (String[] args) { new E(); exit(); }
}


public class E {

	private final static boolean autoflush = false;

	long [][] A = {
			{ 1, 0, 0, 0, 0, 0 },
			{ 1, 1, 0, 0, 0, 0 },
			{ 2, 1, 2, 1, 1, 0 },
			{ 2, 1, 1, 2, 0, 1 },
			{ 2, 1, 1, 1, 1, 0 },
			{ 2, 1, 1, 1, 0, 1 }
	};

	public E () {
		int N = sc.nextInt();
		int X = sc.nextInt() - 1;
		int Y = sc.nextInt() - 1;
		int VX = sc.nextInt();
		int VY = sc.nextInt();
		long T = sc.nextLong();

		long [] V = { 1, 0, X, Y, VX, VY };
		long [] W = prod(pow(A, T, N), V, N);
		exit(W[2] + 1, W[3] + 1);
	}

	long [] prod(long [][] A, long [] V, long mod) {
		long [][] W = new long [V.length][1];
		for (int i : rep(V.length))
			W[i][0] = V[i];
		long [][] X = prod(A, W, mod);
		long [] res = new long [X.length];
		for (int i : rep(X.length))
			res[i] = X[i][0];
		return res;
	}

	long [][] sum (long [][] A, long [][] B, long mod) {
		int M = A.length, K = A[0].length, N = B[0].length;
		assert(K == B.length);
		long [][] res = new long [M][N];

		for (int i = 0; i < M; ++i)
			for (int j = 0; j < N; ++j)
				res[i][j] = mod(A[i][j] + B[i][j], mod);
		return res;
	}

	long [][] prod (long [][] A, long [][] B, long mod) {
		int M = A.length, K = A[0].length, N = B[0].length;
		assert(K == B.length);
		long [][] res = new long [M][N];

		for (int i = 0; i < M; ++i)
			for (int j = 0; j < N; ++j)
				for (int k = 0; k < K; ++k)
					res[i][j] = mod(res[i][j] + A[i][k] * B[k][j], mod);
		return res;
	}

	long [][] pow (long [][] A, long e, long mod) {
		long [][] res = id(A.length);
		if (e > 0) {
			int M = 1 + Long.numberOfTrailingZeros(Long.highestOneBit(e));
			long [][][] P = new long[M][][]; P[0] = A;
			for (int i : rep(1, M))
				P[i] = prod(P[i-1], P[i-1], mod);
			for (int i : rep(M))
				if ((e & (1 << i)) != 0)
					res = prod(res, P[i], mod);
		}
		return res;
	}

	long [][] id (int N) {
		long [][] res = new long [N][N];
		for (int i : rep(N))
			res[i][i] = 1;
		return res;
	}

	///////////////////////////////////////////////////////////////////////////
	private static int [] rep(int N) { return rep(0, N); }
	private static int [] rep(int S, int T) { if (T <= S) return new int [0]; int [] res = new int [T-S]; for (int i = S; i < T; ++i) res[i-S] = i; return res; }
	private static long mod(long x, long mod) { return ((x % mod) + mod) % mod; }
	////////////////////////////////////////////////////////////////////////////////////
	private final static MyScanner sc = new MyScanner();
	private static class MyScanner {
		public String next() { newLine(); return line[index++]; }
		public int nextInt() { return Integer.parseInt(next()); }
		//////////////////////////////////////////////
		private boolean eol() { return index == line.length; }
		private String readLine() {
			try {
				return r.readLine();
			} catch (Exception e) {
				throw new Error (e);
			}
		}
		private final java.io.BufferedReader r;
		private MyScanner () { this(new java.io.BufferedReader(new java.io.InputStreamReader(System.in))); }
		private MyScanner (java.io.BufferedReader r) {
			try {
				this.r = r;
				while (!r.ready())
					Thread.sleep(1);
				start();
			} catch (Exception e) {
				throw new Error(e);
			}
		}
		private String [] line;
		private int index;
		private void newLine() {
			if (line == null || eol()) {
				line = readLine().split(" ");
				index = 0;
			}
		}
	}
	private static void print (Object o, Object... a) { printDelim(" ", o, a); }
	private static void printDelim (String delim, Object o, Object... a) { pw.println(build(delim, o, a)); }
	private static void exit (Object o, Object... a) { print(o, a); exit(); }
	private static void exit() {
		pw.close();
		System.out.flush();
		System.err.println("------------------");
		System.err.println("Time: " + ((millis() - t) / 1000.0));
		System.exit(0);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static String build (String delim, Object o, Object... a) {
		StringBuilder b = new StringBuilder();
		append(b, o, delim);
		for (Object p : a)
			append(b, p, delim);
		return b.substring(delim.length());
	}
	private static void append(StringBuilder b, Object o, String delim) {
		if (o.getClass().isArray()) {
			int L = java.lang.reflect.Array.getLength(o);
			for (int i = 0; i < L; ++i)
				append(b, java.lang.reflect.Array.get(o, i), delim);
		} else if (o instanceof Iterable<?>)
			for (Object p : (Iterable<?>)o)
				append(b, p, delim);
		else
			b.append(delim).append(o);
	}
	////////////////////////////////////////////////////////////////////////////////////
	private static void start() { t = millis(); }
	private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out, autoflush);
	private static long t;
	private static long millis() { return System.currentTimeMillis(); }
	public static void main (String[] args) { new E(); exit(); }
}


import java.io.InputStreamReader;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.PrintStream;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 * @author Nipuna Samarasekara
 */
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);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
   /////////////////////////////////////////////////////////////
   static int mod;

    public void solve(int testNumber, FastScanner in, FastPrinter out) {
    long n=in.nextLong();
        mod=(int)n;
        int sx=in.nextInt(),sy=in.nextInt();
        long dx=in.nextInt(),dy=in.nextInt(),t=in.nextLong();
     int[][] A={{2,1,1,1,0,0},
             {1,2,1,1,0,0},
             {1,0,1,0,0,0},
             {0,1,0,1,0,0},
             {1,1,1,1,1,0},
             {0,0,0,0,1,1}
     };
        int[][] B={{sx,sy,(int)dx,(int)dy,0,1},
                {1,2,1,1,0,0},
                {1,0,1,0,0,0},
                {0,1,0,1,0,0},
                {1,1,1,1,1,0},
                {0,0,0,0,1,1}
        };
        Matrix base= new Matrix(A),init= new Matrix(B);
        Matrix fin=Matrix.powMod(base,t,mod);
        Matrix ans= init.multiplyMod(fin,mod);
        int x=ans.get(0,0),y=ans.get(0,1);
        if(x==0)x=mod;
        if(y==0)y=mod;

        out.println(x+" "+y);

    }
}

class FastScanner extends BufferedReader {

    public FastScanner(InputStream is) {
        super(new InputStreamReader(is));
    }

    public int read() {
        try {
            int ret = super.read();
//            if (isEOF && ret < 0) {
//                throw new InputMismatchException();
//            }
//            isEOF = ret == -1;
            return ret;
        } catch (IOException e) {
            throw new InputMismatchException();
        }
    }

    public String next() {
        StringBuilder sb = new StringBuilder();
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        if (c < 0) {
            return null;
        }
        while (c >= 0 && !isWhiteSpace(c)) {
            sb.appendCodePoint(c);
            c = read();
        }
        return sb.toString();
    }

    static boolean isWhiteSpace(int c) {
        return c >= 0 && c <= 32;
    }

    public int nextInt() {
        int c = read();
        while (isWhiteSpace(c)) {
            c = read();
        }
        int sgn = 1;
        if (c == '-') {
            sgn = -1;
            c = read();
        }
        int ret = 0;
        while (c >= 0 && !isWhiteSpace(c)) {
            if (c < '0' || c > '9') {
                throw new NumberFormatException("digit expected " + (char) c
                        + " found");
            }
            ret = ret * 10 + c - '0';
            c = read();
        }
        return ret * sgn;
    }

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

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }

    }

class FastPrinter extends PrintWriter {

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

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

}

class Matrix {
    final int[][] a;
    public final int n;
    public final int m;

    public Matrix(int n, int m) {
        this.n = n;
        this.m = m;
        a = new int[n][m];
    }

    public Matrix(int n) {
        this(n, n);
    }

    public Matrix(int[][] a) {
        n = a.length;
        if (n == 0) {
            throw new AssertionError();
        }
        m = a[0].length;
        this.a = new int[n][];
        for (int i = 0; i < n; i++) {
            if (m != a[i].length) {
                throw new AssertionError();
            }
            this.a[i] = a[i].clone();
        }
    }

    public int get(int x, int y) {
        return a[x][y];
    }

    public static Matrix getOne(int n) {
        Matrix ret = new Matrix(n);
        for (int i = 0; i < n; i++) {
            ret.a[i][i] = 1;
        }
        return ret;
    }

    public Matrix multiplyMod(Matrix b, int mod) {
        if (m != b.n) {
            throw new AssertionError();
        }
        Matrix ret = new Matrix(n, b.m);
        long modmod = (long) mod * mod;
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < b.m; j++) {
                long d = 0;
                for (int k = 0; k < m; k++) {
                    d = (d + (long) a[i][k] * b.a[k][j]);
                    if (d >= modmod) {
                        d -= modmod;
                    }
                }
                ret.a[i][j] = (int) (d % mod);
            }
        }
        return ret;
    }

    public static Matrix powMod(Matrix a, long b, int mod) {
        if (a.n != a.m) {
            throw new AssertionError();
        }
        Matrix ret = getOne(a.n);
        while (b > 0) {
            if ((b & 1) == 1) {
                ret = ret.multiplyMod(a, mod);
            }
            a = a.multiplyMod(a, mod);
            b >>= 1;
        }
        return ret;
    }

    }


import java.util.Scanner;

public class BEAR {
    public static int[][] mul(int[][] a, int[][] b, int mod){
        int n  = a.length;
        int m = a[0].length;
        int l = b[0].length;
        int[][] ret = new int[n][l];
        for(int i = 0;i<n;i++)
            for(int j = 0;j<l;j++)
                for(int k = 0;k<m;k++){
                    ret[i][j] = (int) ((ret[i][j] + 1L * a[i][k] * b[k][j])%mod);
                }
        return ret;
    }
    public static int[][] pow(int[][] a, long t, int mod){
        int[][] ret = new int[a.length][a.length];
        for(int i = 0;i<ret.length;i++)ret[i][i]=1;
        while(t>0){
            if((t & 1)!=0){
                ret = mul(ret, a, mod);
            }
            a = mul(a, a, mod);
            t>>=1;
        }
        return ret;
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int x0 = in.nextInt()-1;
        int y0 = in.nextInt()-1;
        int dx0 =(in.nextInt()%n+n)%n;
        int dy0 =( in.nextInt()%n+n)%n;
        long t = in.nextLong();

        int[][] m = {
                { 2, 1, 1, 0, 1, 0 },
                { 1, 2, 0, 1, 1, 0 },
                { 1, 1, 1, 0, 1, 0 },
                { 1, 1, 0, 1, 1, 0 },
                { 0, 0, 0, 0, 1, 1 },
                {0, 0, 0, 0, 0, 1}
                };
        int[][] original = {{x0},
                            {y0},
                            {dx0},
                            {dy0},
                            {0},
                            {1}};
        m = pow(m, t,n);
        int[][] res = mul(m , original, n);
        System.out.println((1+res[0][0])+" "+(1+res[1][0]));
    }
}


import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;
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;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskE solver = new TaskE();
		solver.solve(1, in, out);
		out.close();
	}
}

class TaskE {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
                long n = in.nextLong();
                long sx = in.nextLong();
                long sy = in.nextLong();
                sx--;
                sy--;
                long dx = in.nextLong();
                long dy = in.nextLong();
                long t = in.nextLong();
                long[][] base = {
                        {2, 1, 1, 0, 1, 2},
                        {1, 2, 0, 1, 1, 2},
                        {1, 1, 1, 0, 1, 2},
                        {1, 1, 0, 1, 1, 2},
                        {0, 0, 0, 0, 1, 1},
                        {0, 0, 0, 0, 0, 1}};
                Matrix init = new Matrix(base, n);
                Matrix res = init.power(init, t);
                /*for (int i = 0; i < 6; i++) {
                        for (int j = 0; j < 6; j++)
                                out.print(res.value[i][j] + " ");
                        out.println();
                }*/
                sx = res.value[0][0] * sx  + res.value[0][1] * sy + res.value[0][2] * dx + res.value[0][3] * dy +
                        res.value[0][4] * 0 + res.value[0][5];
                sy = res.value[1][0] * sx  + res.value[1][1] * sy + res.value[1][2] * dx + res.value[1][3] * dy +
                        res.value[1][4] * 0 + res.value[1][5];
                sx %= n;
                sx += n;
                sx %= n;
                sy %= n;
                sy += n;
                sy %= n;
                sx++;
                sy++;
                out.println(sx + " " + sy);
        }
}

class Matrix {
        long mod;
        long[][] value;
        final static int n = 6;

        Matrix(long[][] value, long mod) {
                this.value = value;
                this.mod = mod;
        }

        Matrix getOne() {
                long[][] one = new long[n][n];
                for (int i = 0; i < n; i++)
                        one[i][i] = 1;
                return new Matrix(one, mod);
        }

        Matrix multiply(Matrix other) {
                Matrix res = new Matrix(new long[n][n], mod);
                for (int i = 0; i < n; i++)
                        for (int j = 0; j < n; j++)
                                for (int k = 0; k < n; k++) {
                                        res.value[i][j] += value[i][k] * other.value[k][j] % mod;
                                        res.value[i][j] %= mod;
                                }
                return res;
        }

        Matrix power(Matrix base, long pow) {
                Matrix res = getOne();
                while (pow > 0) {
                        if (pow % 2 == 1)
                                res = base.multiply(res);
                        base = base.multiply(base);
                        pow /= 2;
                }
                return res;
        }
}

class FastScanner {
        BufferedReader reader;
        StringTokenizer tokenizer;

        public FastScanner(InputStream inputStream)  {
                reader = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

        }


import java.util.Scanner;

/**
 *
 * @author RS
 */
public class AChatRoom {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String str = scan.next();
        int index = 0 , leng = str.length();
        int counter = 0;
        char[] chr = {'h' , 'e' , 'l' , 'l', 'o'};
        char currentChar , lastChar;
        boolean equ = true;
        char current;
        while(index<leng){
            current = str.charAt(index);
            if(counter == 0)
                lastChar = currentChar = chr[counter];
            else{
                lastChar = chr[counter -1];
                currentChar = chr[counter];
            }
            if(current == lastChar){
                continue;
            }
            else if(current == currentChar){
                counter++;
                continue;
            }
            for(int i = 0 ; i< chr.length ; i++){
                if(current == chr[i]){
                    equ = false;
                }
            }
        }
        if(equ)
            System.out.println("YES");
        else
            System.out.println("NO");
    }
}


import java.util.*;
public class Main
{
	public static void main(String[] args) {
	    Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int m=sc.nextInt();
		int a=sc.nextInt();
		int b=sc.nextInt();
		int sa=n*a;

	if(m*a<=b)
	{
	    System.out.println(a*n);
	}
	else{
	    int c1=(n/m)*b;
	   c1+=b;
	   System.out.println(c1);

	}


package wtf;

import java.util.Scanner;

public class Wtf {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n,c=0;
        n = scan.nextInt();
        for(int i=1;i<=n;i++)
        {
            for(int j=1;j<=i;j++)
            {
                for(int k=1;k<=j;k++)
                {
                    if((i^j^k)==0)
                    {
                        if(i+j>k && j+k>i && k+i>j)
                        c++;
                        //System.out.println(i+ " "+ j+" "+k+" "+c);
                    }
                }
            }
        }
        System.out.println(c);
    }

}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.io.BufferedOutputStream;

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

    static class TaskA {
        public void solve(int testNumber, Kattio in, PrintWriter out) {
            long x = in.nextLong();
            long y = in.nextLong();

            if (x < y) {
                out.println("No");
            } else {
                long diff = Math.abs(x - y);
                out.println(diff % 2 == 0 ? "Yes" : "No");

            }
        }

    }

    static class Kattio extends PrintWriter {
        private BufferedReader r;
        private String line;
        private StringTokenizer st;
        private String token;

        public Kattio(InputStream i) {
            super(new BufferedOutputStream(System.out));
            r = new BufferedReader(new InputStreamReader(i));
        }

        public Kattio(InputStream i, OutputStream o) {
            super(new BufferedOutputStream(o));
            r = new BufferedReader(new InputStreamReader(i));
        }

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

        private String peekToken() {
            if (token == null)
                try {
                    while (st == null || !st.hasMoreTokens()) {
                        line = r.readLine();
                        if (line == null) return null;
                        st = new StringTokenizer(line);
                    }
                    token = st.nextToken();
                } catch (IOException e) {
                }
            return token;
        }

        private String nextToken() {
            String ans = peekToken();
            token = null;
            return ans;
        }

    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class B {
	static boolean visited[][][];

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		boolean[] numbers = new boolean[n + 1];

		int count = 0;

		visited = new boolean[n + 1][n + 1][n + 1];

		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				for (int z = Math.max(i, j); z<=n&&i != j && z < i+j; z++) {
				//	System.out.println(i + " "+j + " "+z);
					if (z != j && (i ^ j ^ z) == 0 && check(i,j,z)) {
						visited[i][j][z] = true;
						visited[i][z][j] = true;
						visited[z][i][j] = true;
						visited[z][j][i] = true;
						visited[j][i][z] = true;
						visited[j][z][i] = true;

						//System.out.println(i + " " + j + " " + z);
						count++;
					}
				}
			}
		}
		System.out.println(count);
		// 011 101 110
		// 00 10 10
	}

	static boolean check(int i, int j, int z) {
		if (!visited[i][j][z] && !visited[i][z][j] && !visited[z][i][j] && !visited[z][j][i] && !visited[j][i][z]
				&& !visited[j][z][i])
			return true;
		return false;
	}

	static int log(int x, int base) {
		return (int) (Math.log(x) / Math.log(base));
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

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

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

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


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

public class SimpleMolecules {

   public static void findBonds(long[] val, long[] mol){
      if ((val[0] == 0 && val[1] == 0) ||
          (val[1] == 0 && val[2] == 0) ||
          (val[0] == 0 && val[2] == 0))
          return;

      int maxpos = findMax(val);
      int minpos = findMin(val);

      val[maxpos] -= 1;
      val[minpos] -= 1;
      mol[maxpos + minpos - 1]++;

      findBonds(val, mol);
   }

   public static int findMax(long[] val){
      int maxpos = 0;
      long max = val[0];
      for(int i = 1; i < val.length; i++)
         if(val[i] > max){
            maxpos = i;
            max = val[i];
         }

      return maxpos;
   }

   public static int findMin(long[] val){
      int minpos = findMax(val);
      long min = val[findMax(val)];
      for(int i = 0; i < val.length; i++)
         if(i != minpos){
            if(val[i] <= min && val[i] > 0){
               minpos = i;
               min = val[i];
            }
         }

      return minpos;
   }

   public static boolean unconnAtom(long[] mol){
      if(mol[0] == 0 && mol[1] == 0)
         return true;
      if(mol[0] == 0 && mol[2] == 0)
         return true;
      if(mol[1] == 0 && mol[2] == 0)
         return true;

      return false;
   }

   public static void main(String[] args) {
      Scanner sc = new Scanner(System.in);
      long[] val = new long[3];
      val[0] = sc.nextLong();
      val[1] = sc.nextLong();
      val[2] = sc.nextLong();
      long[] mol = new long[3];

      findBonds(val, mol);

      if(unconnAtom(mol)){
         System.out.println("Impossible");
         System.exit(1);
      }
      else if(!(val[0] == 0 && val[1] == 0 && val[2] == 0)) {
         System.out.println("Impossible");
         System.exit(1);
      }
      else
         System.out.println(mol[0] + " " + mol[2] + " " + mol[1]);
   }
}


import java.io.*;
import java.util.*;
public class SumOfDigits
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String[] s=br.readLine().split(" ");
        int n=Integer.parseInt(s[0]);
        int k=Integer.parseInt(s[1]);
        int l=Integer.parseInt(s[2]);
        int c=Integer.parseInt(s[3]);
        int d=Integer.parseInt(s[4]);
        int p=Integer.parseInt(s[5]);
        int nl=Integer.parseInt(s[6]);
        int np=Integer.parseInt(s[7]);
        int tl=(k*l)/n;
        int cd=c*d;
        int pnp=p/np;
        int ans=Math.min(tl,cd,pnp)/nl;
        System.out.println(ans);
    }
}


public class Binnum {

public static void main(String args[] ) throws Exception {

        Scanner scan = new Scanner(System.in);

        int n, k, l, c, d, p, nl, np;
        long totml, totmltofrnds, totslices, totsalt, tottoast;

        n = scan.nextInt();
        k = scan.nextInt();
        l = scan.nextInt();
        c = scan.nextInt();
        d = scan.nextInt();
        p = scan.nextInt();
        nl = scan.nextInt();
        np = scan.nextInt();

       totml = k*l;
       totmltofrnds = totml/n;
       totslices = c*d;
       totsalt = p*np;

       long min = Math.min(totmltofrnds, totslices);
       tottoast = Math.min(min, totsalt)/n;

       if(n == 1){
    	   tottoast = tottoast/l;
       }

       if(n == 2){
    	   tottoast = (tottoast/n) - l;
       }

       System.out.println(tottoast);
}
}


/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *cf244b_uln
 * @author zulkan
 */
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import static java.lang.System.*;
import java.math.BigInteger;
import java.util.List;
import java.util.ArrayList;
import java.util.Scanner;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;

public class cf244b_uln {

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

    public static String getString() {
        try {
            return br.readLine();
        } catch (Exception e) {
        }
        return "";
    }

    public static Integer getInt() {
        try {
            return Integer.parseInt(br.readLine());
        } catch (Exception e) {
        }
        return 0;
    }

    public static Integer[] getIntArr() {
        try {
            StringTokenizer temp = new StringTokenizer(br.readLine());
            int n = temp.countTokens();
            Integer temp2[] = new Integer[n];
            for (int i = 0; i < n; i++) {
                temp2[i] = Integer.parseInt(temp.nextToken());
            }
            return temp2;
        } catch (Exception e) {
        }
        return null;
    }

    public static int getMax(Integer[] ar) {
        int t = ar[0];
        for (int i = 0; i < ar.length; i++) {
            if (ar[i] > t) {
                t = ar[i];
            }
        }
        return t;
    }

    public static void print(Object a) {
        out.println(a);
    }

    public static int nextInt() {
        return sc.nextInt();
    }

    public static double nextDouble() {
        return sc.nextDouble();
    }

    public static BigInteger getFact(long in) {
        BigInteger ot = new BigInteger("1");
        for (Integer i = 1; i <= in; i++) {
            ot = ot.multiply(new BigInteger(i.toString()));
        }
        return ot;
    }

    public static String gbase(int a, int base) {
        StringBuilder out = new StringBuilder();
        int temp = a;
        while (temp > 0) {
            //out = temp % base + out;
            out.insert(0, temp % base);
            temp /= base;
        }
        return out.toString();
    }

    public static void main(String[] ar) {

        int n = getInt();
        int out = 0;

        boolean all[] = new boolean[n + 1];
        for (int i = 0; i < 10; i++) {
            for (int j = i; j < 10; j++) {
                if (i != 0 || j != 0) {
                    ArrayList<Integer> last = new ArrayList<Integer>();
                    last.add(i);
                    last.add(j);
                    all[i] = true;
                    all[j] = true;

                    int ls = j;
                    while (ls < n) {
                        ArrayList<Integer> last2 = new ArrayList<Integer>();
                        for (int ii = 0; ii < last.size(); ii++) {
                            int a = last.get(ii) * 10 + i;
                            int b = last.get(ii) * 10 + j;
                            last2.add(a);
                            last2.add(b);
                            //print(a + " " + b);
                            if (b <= n) {

                                all[b] = true;
                            }
                            if (a <= n) {
                                all[a] = true;
                            }
                            ls = b;
                        }
                       // print(ls + " " + last2);
                        last = last2;

                    }

                }
            }
        }
        for (int i = 1; i <= n; i++) {
            //print(i + " " + all[i]);
            if (all[i]) {
                out++;
            }
        }
        print(out);

    }
}


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

/**
 *
 * @author sukhdeep
 */
public class Code {
    public static void main(String arg[]) throws IOException
    {
        BufferedReader r=new BufferedReader(new InputStreamReader(System.in));

        StringBuilder str=new StringBuilder(r.readLine());
        long x=1;
        int a[]=new int[10];
        int count=10;
           if(str.charAt(0)=='?')
               x=x*9;
           if(str.charAt(0)>=65&&str.charAt(0)<=74)
           {
               x=x*9;
               a[str.charAt(0)-65 ]=1;
               count--;
           }
           for(int i=1;i<str.length();i++)
           {
               if(str.charAt(i)=='?')
               {
                   x=x*10;
               }
               else if(a[str.charAt(i)-65]==0&&(str.charAt(i)>=65&&str.charAt(i)<=74))
               {a[str.charAt(i)-65]=1;
               x=x*count;
                   count--;
               }
           }
         System.out.println(x);

}
}


import java.util.Arrays;
import java.util.Scanner;
public class Pretty_Integers {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        int m=in.nextInt();
        int n=in.nextInt();
        String X="";
        int [] a=new int[m];
        int [] b=new int [n];
        for (int i = 0; i < m; i++) {
            a[i]=in.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i]=in.nextInt();
        }
        Arrays.sort(a);
        Arrays.sort(b);
        if(a[0]==b[0])
            X+=a[0];
        else{
            if(a[0]<b[0])
                X+=a[0]+""+b[0];
            else
                X+=b[0]+""+a[0];
        }
        System.out.println(X);
    }

}


import java.util.*;
public class A{
       public static void main(String args[]){
              BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
              StringTokenizer st = new StringTokenizer(br.readLine());
              int n = Integer.parseInt(st.nextToken());
              int m = Integer.parseInt(st.nextToken());
              int a[] = new int[10];
              int b[] = new int[10];
              st = new StringTokenizer(br.readLine());
              for(int i = 0; i < n; i++)
                     a[Integer.parseInt(st.nextToken())]++;
              st = new StringTokenizer(br.readLine());
              for(int j = 0; j < m; j++)
                     b[Integer.parseInt(st.nextToken())]++;
              int ans = 0;
              for(int i = 1; i < 10; i++){
                     if(a[i] > 0 && b[i] > 0){
                            ans = i;
                            break;
                     }
              }
              if(ans > 0){
                     System.out.println(ans);
              }else{
                     int first = 0;
                     int second = 0;
                     for(int i = 0; i < 10; i++){
                            if(a[i] > 0){
                                   first = i;
                                   break;
                            }
                     }
                     for(int i = 0; i < 10; i++){
                            if(b[i] > 0){
                                   second = i;
                                   break;
                            }
                     }
                     ans += Math.min(first, second);
                     ans *= 10;
                     ans += Math.max(first, second);
                     System.out.println(ans);
              }
       }
}


import java.io.*;
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.lang.Math;

public class MyCode {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int k = sc.nextInt();
    int x = sc.nextInt();

    ArrayList<Integer> list = new ArrayList<>();
    for(int i = 0; i < n; i++){
      list.add(sc.nextInt());
    }

    ArrayList<Group> newL = new ArrayList<>();
    for(int i = 0; i < n; i++){
      int s = list.get(i);
      if(newL.size() == 0){
        newL.add(new Group(s, 1));
      } else {
        Group last = newL.get(newL.size() - 1);
        int lastVal = last.val;
        if(s == lastVal){
          last.countUp();
        } else {
          newL.add(new Group(s, 1));
        }
      }
    }

    int ansCount = 0;
    int l = 0;
    int r = 0;
    for(int i = 0; i < newL.size(); i++){
      Group s = newL.get(i);
      if(x == s.val){
        if(s.count > 1){
          l = i - 1;
          r = i + 1;
          int tempCount = 2;
          while(l >= 0 && r < newL.size()
          && newL.get(l).val == newL.get(r).val
          && newL.get(l).count + newL.get(r).count >= 3){
            tempCount += newL.get(r).count + newL.get(l).count;
            r += 1;
            l -= 1;
          }
          if(tempCount > ansCount){
            ansCount = tempCount;
          }
        }
      }
    }

    System.out.print(ansCount);
  }
}

public class Group {
  public int val;
  public int count;

  public Group(int val, int count){
    this.val = val;
    this.count = count;
  }

  public void countUp(){
    this.count += 1;
  }
}


import java.io.*;
import static java.lang.Math.max;
import static java.lang.Long.min;
import static java.lang.Math.abs;
import static java.lang.Math.pow;
import static java.lang.System.out;
import java.util.*;

public class Kaudo {
    static Reader in =new Reader();
    static StringBuilder Sd=new StringBuilder();
    static long ans=0,res;
     public static void main(String [] args) {
     int n =in.nextInt(),k=in.nextInt(),x=in.nextInt();
     int a[]=new int [n];
     for(int i=0;i<n;i++)a[i]=in.nextInt();
     for(int i=0;i<n;i++){
     if(a[i]==x){
     int l=1,xo=x;
     for(int u=i,o=i+1;;){
     if(u>=0&&a[u]==xo){l++;u--;}
     if(o<n&&a[o]==xo){l++;o++;}
     if(u>=0&&o<n&&a[u]==a[o]&&a[u]!=xo){xo=a[o];
     if(l>=3){ans+=l;}
     else break;
     l=0;}
     if(o>=n&&u<0){
         if(l>=3){ans+=l;}

         break;}
     if(u<0&&a[o]!=xo){ if(l>=3){ans+=l;}
     break;}
     if(o>=n&&a[u]!=xo){ if(l>=3){ans+=l;}
     break;}}}
     res=max(res,ans-1);
     ans=0;
     }
         System.out.println(res);
     }

   static class Reader
    {
        private InputStream mIs;private byte[] buf = new byte[1024];private int curChar,numChars;public Reader() { this(System.in); }public Reader(InputStream is) { mIs = is;}
        public int read() {if (numChars == -1) throw new InputMismatchException();if (curChar >= numChars) {curChar = 0;try { numChars = mIs.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 s(){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 l(){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 double d() throws IOException {return Double.parseDouble(s()) ;}
        public boolean isSpaceChar(int c) { return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; }
        public boolean isEndOfLine(int c) { return c == '\n' || c == '\r' || c == -1; }
        public int[] arr(int n){int[] ret = new int[n];for (int i = 0; i < n; i++) {ret[i] = nextInt();}return ret;}
    }

}
class Sorting{

 public static int[] bucketSort(int[] array, int bucketCount) {

 if (bucketCount <= 0) throw new IllegalArgumentException("Invalid bucket count");

 if (array.length <= 1) return array; //trivially sorted

 int high = array[0];

 int low = array[0];

 for (int i = 1; i < array.length; i++) { //find the range of input elements

 if (array[i] > high) high = array[i];

 if (array[i] < low) low = array[i];

 }

 double interval = ((double)(high - low + 1))/bucketCount; //range of one bucket

 ArrayList<Integer> buckets[] = new ArrayList[bucketCount];

 for (int i = 0; i < bucketCount; i++) { //initialize buckets

 buckets[i] = new ArrayList();

 }

 for (int i = 0; i < array.length; i++) { //partition the input array

 buckets[(int)((array[i] - low)/interval)].add(array[i]);

 }

 int pointer = 0;

 for (int i = 0; i < buckets.length; i++) {

 Collections.sort(buckets[i]); //mergeSort

 for (int j = 0; j < buckets[i].size(); j++) { //merge the buckets

 array[pointer] = buckets[i].get(j);

 pointer++;

 }

}

return array;

}

}


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

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

class Solve { public Solve() throws Exception {solve();}

    void solve() throws Exception {
        int n = NI();
        int k = NI();
        int x = NI();
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = NI();
        int res = 0;
        for (int i = 0; i < n - 1; i++) {
            if (a[i] == x)
                res = max(res, count(a, i, i + 1));

        }
        System.out.println(res);

    }

    int count(int[] a, int l, int r) {
        if (l < 0 || r >= a.length || a[l] != a[r])
            return  0;
        int tl = l, tr = r;
        while (tl > 0 && a[l] == a[tl - 1])
            tl--;
        while (tr + 1 < a.length && a[r] == a[tr + 1])
            tr++;
        if (a[tl] == a[l] && a[tr] == a[r]
            &&    a[tr] - a[r] + a[l] - a[tl] >= 0) {
            return count(a, tl - 1, tr + 1) + tr - r + l - tl + 2;
        } else {
            return 0;
        }
    }

    class Pair {
        int index, value, color;
        public Pair(int ind, int val) {
             index = ind;
            value = val;
        }
    }

    static BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st=new StringTokenizer("");
    static Scanner sc = new Scanner(System.in);
    int min(int i1,int i2){return i1<i2?i1:i2;}
    long min(long i1,long i2){return i1<i2?i1:i2;}
    int max(int i1,int i2){return i1>i2?i1:i2;}
    long max(long i1,long i2){return i1>i2?i1:i2;}
    String NS()throws Exception{while(!st.hasMoreTokens())st=new StringTokenizer(stdin.readLine());return st.nextToken();}
    String NLn() throws Exception {return stdin.readLine();}
    int NI()throws Exception{return Integer.parseInt(NS());}
    long NL()throws Exception{return Long.parseLong(NS());}
    double ND()throws Exception{return Double.parseDouble(NS());}
    int abs(int x){return x<0?-x:x;}
}


public class NewWall {
    public static void main(String[] args) {
        Scanner input=new Scanner (System.in);
        int x,y,a,b,a1,b1,c=1,k,count=0;
        x=input.nextInt();
        y=input.nextInt();
        a=input.nextInt();
        b=input.nextInt();
        a1=x;
        b1=y;
        while(true){
            c=b1%a1;
            if(c==0)
                break;
            b1=a1;
            a1=c;
        }

        k=((x*y)/a1);
        int i;
    for ( i = a; i <= b; i++)
        if (i>=k && i%k==0)
         break;
    for (int j = i; j <= b; j+=k)
        count++;
        System.out.println(count);
    }
}


public class Shovel {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,k,l,c,d,p,nl,np,r;
        String scentence  = sc.nextLine();
        String []arr = scentence.split(" ");
        n = Integer.parseInt(arr[0]);
        k = Integer.parseInt(arr[1]);
        l = Integer.parseInt(arr[2]);
        c = Integer.parseInt(arr[3]);
        d = Integer.parseInt(arr[4]);
        p = Integer.parseInt(arr[5]);
        nl = Integer.parseInt(arr[6]);
        np = Integer.parseInt(arr[7]);

        r = n*nl/k*l;
        if(r<=(c*d)&&r<=(p/np*n)){System.out.println(""+r);}

    }
}


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

public class mainsource {
	public static class point {
		int first, second;

		point() {
		}

		point(int f, int s) {
			this.first = f;
			this.second = s;
		}
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		point set[] = new point[8];
		ArrayList<Integer> arr1 = new ArrayList<>();
		ArrayList<Integer> arr2 = new ArrayList<>();
		for (int i = 0; i < 8; ++i) {
			int first = sc.nextInt();
			int second = sc.nextInt();
			set[i] = new point(first, second);
			if (!arr1.contains(first))
				arr1.add(first);
			if (!arr2.contains(second))
				arr2.add(second);
		}
		if (arr1.size()!=3 && arr2.size() != 3) {
			System.out.print("ugly");
		} else {
			Arrays.sort(set, new Comparator<point>() {
				@Override
				public int compare(point a, point b) {
					if (a.first == b.first) {
						return a.second - b.second;
					} else
						return a.first - b.first;
				}
			});
			int idx=0;
			point checker[]=new point[8];
			Collections.sort(arr1);
			Collections.sort(arr2);
			for(int i=0;i<3;++i)
			{
				for(int j=0;j<3;++j)
				{
					if(i==1 && j==1)
						continue;
					checker[idx++]=new point(arr1.get(i),arr2.get(j));
				}
			}
			Boolean flag=true;
			for(int i=0;i<8;++i)
			{
				if(checker[i].first!=set[i].first || checker[i].second!=set[i].second)
				{
					flag=false;
					break;
				}
			}
			if(flag)
				System.out.print("respectable");
			else
				System.out.print("ugly");
		}
	}
}


import java.util.*;

//Current File Class
public class HELL
{
    static Scanner cin=new Scanner(System.in);
    public static void main(String[] args)
    {
        //itr1.hasNext()        return boolean (True,False)
        //itr1.next()           returns the current integer and go to next element in set;
        int[][] arr=new int[3][3];
        Set<Integer> s1=new TreeSet<Integer>();
        Set<Integer> s2=new TreeSet<Integer>();
        List<Integer> l1=new LinkedList<Integer>();
        List<Integer> l2=new LinkedList<Integer>();
        for(int j=0;j<8;++j)
        {
            int a=cin.nextInt(),b=cin.nextInt();
            l1.add(a);          l2.add(b);
            s1.add(a);          s2.add(b);
        }
        if(s1.size()>3 || s2.size()>3)
            System.out.println("ugly");
        else
        {
            Iterator<Integer> itr1,itr2;
            itr1=s1.iterator();         itr2=s2.iterator();
            int x1=itr1.next(),         x2=itr2.next();
            int y1=itr1.next(),         y2=itr2.next();
            int z1=itr1.next(),         z2=itr2.next();

            for(int j=0;j<8;++j)
            {
                if(l1.get(j)==x1)
                {   l1.remove(j);       l1.add(j,0);        }
                else if(l1.get(j)==y1)
                {   l1.remove(j);       l1.add(j,1);        }
                else if(l1.get(j)==z1)
                {   l1.remove(j);       l1.add(j,2);        }
                if(l2.get(j)==x2)
                {   l2.remove(j);       l2.add(j,0);        }
                else if(l2.get(j)==y2)
                {   l2.remove(j);       l2.add(j,1);        }
                else if(l2.get(j)==z2)
                {   l2.remove(j);       l2.add(j,2);        }
            }
            for(int j=0;j<8;++j)
                arr[l1.get(j)][l2.get(j)]=1;

            for(int j=0;j<3;++j)
                for(int i=0;i<3;++i)
                    if(j!=1 || i!=1)
                        if(arr[j][i]!=1)
                        {   System.out.println("ugly");     return;     }

            if(arr[1][1]!=0)
                System.out.println("ugly");
            else
                System.out.println("respectable");
        }
    }
}


import java.util.Scanner;
import java.util.TreeMap;
import java.util.TreeSet;

public class B {

	public static void main (String args[]){

		Scanner in = new Scanner(System.in);

		int x[] = new int[8];
		int y[] = new int[8];
		TreeMap<Integer, Integer>s = new TreeMap<Integer, Integer>();

		TreeMap<Integer, Integer>z = new TreeMap<Integer, Integer>();

		for(int i = 0 ; i < 8 ; i++){
			x[i]=in.nextInt();
			y[i]=in.nextInt();

			s.put(x[i],x[i]);
			z.put(y[i],y[i]);
		}

		if(s.size()!=z.size() && s.size()!=3){
			System.out.println("ugly");
		}
		else{

		int a[] = new int[3];
		int b[] = new int[3];

		for(int i=0;i<3;i++){
			 a[i]=s.lastEntry().getKey();

			 s.remove(a[i]);

			 b[i]=z.lastEntry().getKey();

			 z.remove(b[i]);

		}

		boolean m=true;

		for(int i = 0 ; i < 3  && m; i++){
			for(int j = 0 ; j < 3  && m; j++){
				if(j==1 && i ==1)
					continue;

				boolean f = false;
				for(int k = 0 ; k < 8 ; k++){
					if(x[k]==a[i] && y[k]==b[j]){
						f=true;
						break;
					}
				}
				if(!f){
					System.out.println("ugly");
					m=false;
					break;
				}
			}
		}
		if(m)
		System.out.println("respectable");

	}
	}

}


import java.util.Scanner;
public class Ishu
{
   public static void main(String[] args)
   {
        Scanner scan=new Scanner(System.in);
        int i;
        String s;
        s=scan.next();
        for(i=1;i<s.length()-3;++i)
        {
            if(s.substring(i,i+3).equals("dot"))
            {
                s=s.substring(0,i)+"."+s.substring(i+3,s.length());
            }
        }
        for(i=1;i<s.length()-2;++i)
        {
            if(s.substring(i,i+2).equals("at")
            {
                s=s.substring(0,i)+"@"+s.substring(i+2,s.length());
                break;
            }
        }
        System.out.println(s);
   }
}


import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

@SuppressWarnings("unused")
public class A {
	public  static  FastScanner scan = new FastScanner();
	public static PrintWriter out = new PrintWriter(System.out);

	public static void solve () {
		String s=scan.next();
		if(s.contains("at")) s=s.replaceFirst("at", "@");
		if(s.contains("dot")) s=s.replace("dot", ".");
		if(s.charAt(0)=='.') {
			s="dot"+s.substring(1);
		}
		if(s.charAt(s.length()-1)=='.') {
			s=s.substring(0,s.length()-1)+"dot";
		}
		System.out.println(s);
	}
	public static void main(String[] args) {

		solve();
		out.close();
	}

}


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

public class LenghteningSticks {
	private static final BufferedReader in = new BufferedReader(
			new InputStreamReader(System.in));

	public boolean isTriangle(int a, int b, int c) {
		return (a + b > c && a + c > b && b + c > a);
	}

	public void solve() throws IOException {
		String[] next = in.readLine().split(" ");
		int a = Integer.parseInt(next[0]);
		int b = Integer.parseInt(next[1]);
		int c = Integer.parseInt(next[2]);
		int l = Integer.parseInt(next[3]);

		long ways = 0;
		for (int i = 0; i <= l; i++) {
			// length of one side >= second = third side + whats left of l
			//if (a + i > b + c + l - i) break;
			for (int j = 0; i + j <= l; j++) {
				//if (b + j > a + c + l - i - j) break;
				for (int k = 0; i + j + k <= l; k++) {
					if (isTriangle(a + i,b + j,c + k)) {
						ways++;
					}
					//else { break; }
				}
			}
		}
		System.out.println(ways);
		in.close();
	}

	public static void main(String[] args) throws IOException {
		new LenghteningSticks().solve();
	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * @author Don Li
 */
public class LengtheningSticks {
    void solve() {
        int a = in.nextInt(), b = in.nextInt(), c = in.nextInt(), l = in.nextInt();

        long ans = binomialCoefficient(l + 3, 3) - count(a, b, c, l) - count(b, a, c, l) - count(c, a, b, l);

        out.println(ans);
    }

    private long count(int a, int b, int c, int l) {
        long res = 0;
        int lb = Math.max(c, a + b);
        int ub = c + l;
        for (int i = lb; i <= ub; i++) {
            int x = Math.min(i - a - b, l - i + c);
            if (x >= 0) res += binomialCoefficient(x + 2, 2);
        }
        return res;
    }

    private long binomialCoefficient(int n, int k) {
        if (k > n - k) return binomialCoefficient(n, n - k);
        if (k == 0) return 1;
        long ans = 1;
        for (int i = 1; i <= k; i++) {
            ans = ans * (n - i + 1) / i;
        }
        return ans;
    }

    public static void main(String[] args) {
        in = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
        out = new PrintWriter(System.out);
        new LengtheningSticks().solve();
        out.close();
    }

    static FastScanner in;
    static PrintWriter out;

    static class FastScanner {
        BufferedReader in;
        StringTokenizer st;

        public FastScanner(BufferedReader in) {
            this.in = in;
        }

        public String nextToken() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(in.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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


import java.util.*;
import java.util.Arrays;
public class Lengthening {
	static Scanner seer = new Scanner(System.in);
	static int a,b,c,l;
	public static void main(String[] args) {
		a = seer.nextInt();
		b = seer.nextInt();
		c = seer.nextInt();
		l = seer.nextInt();

		long res = 0;
		for(int k = 0; k <= l; k++){
			res+= calc(k); //System.out.println(calc(k));
		}

		System.out.println(res);
	}
	public static long calc(int k){
		int c = Lengthening.c + k;
		int l = Lengthening.l - k;
		if(Math.abs(a-b) < c){
			int parte_grande = (l+1)*(l+2)/2;
			int parte_chica = (a+b>c)? 0:(c-a-b+1)*(c-a-b+2)/2;
			parte_chica = Math.min(parte_grande,parte_chica);
			int n = a+l-b-c+1;
			int parte_arriba = 0>=n? 0:(n%2==0?(n/2)*(n/2 + 1):(n/2 + 1)*(n/2 + 1));
			n = b+l-a-c+1;
			int parte_abajo = 0>=n? 0:(n%2==0?(n/2)*(n/2 + 1):(n/2 + 1)*(n/2 + 1));

			return parte_grande - parte_chica - parte_arriba - parte_abajo;
		}
		else{
			int p = Math.abs(a-b);
			int n = -p + l + c;
			int parte_grande = 0>=n? 0:(n%2==0?(n/2)*(n/2 + 1):(n/2 + 1)*(n/2 + 1));
			n = -p + l - c + 1;
			int parte_chica = 0>=n? 0:(n%2==0?(n/2)*(n/2 + 1):(n/2 + 1)*(n/2 + 1));

			return parte_grande - parte_chica;
		}
	}
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class C
{
	public static final Random RANDOM = new Random(System.currentTimeMillis());
	private BufferedReader bufferedReader;
	private StringTokenizer stringTokenizer;
	private PrintWriter out;

	public C()
	{
		this(new BufferedReader(new InputStreamReader(System.in)));
	}

	public C(BufferedReader bufferedReader)
	{
		this.bufferedReader = bufferedReader;
		this.stringTokenizer = null;
		this.out = new PrintWriter(new BufferedOutputStream(System.out));
	}

	public C(String file) throws FileNotFoundException
	{
		this(new BufferedReader(new InputStreamReader(new FileInputStream(file))));
	}

	private String next() throws IOException
	{
		while ((this.stringTokenizer == null) || (!this.stringTokenizer.hasMoreTokens()))
		{
			this.stringTokenizer = new StringTokenizer(this.bufferedReader.readLine());
		}
		return stringTokenizer.nextToken();
	}

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

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

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

	public String nextLine() throws IOException
	{
		return this.bufferedReader.readLine();
	}

	public void close()
	{
		out.close();
	}

	public static void main(String[] args)
	{
		C template = new C();
		try
		{
			template.solve();
		}
		catch (IOException exception)
		{
			exception.printStackTrace();
		}
		template.close();
	}

	public boolean degenerate(int[] x)
	{
		boolean result = false;
		for (int index = 0; index < 3; index++)
		{
			result |= x[index] >= x[(index + 1) % 3] + x[(index + 2) % 3];
		}
		return result;
	}

	public void solve() throws IOException
	{
		int x[] = new int[3];
		x[0] = nextInt();
		x[1] = nextInt();
		x[2] = nextInt();
		int l = nextInt();
		Arrays.sort(x);
		long result = 0;
		for (int l2 = 0; l2 <= l; l2++)
		{
			for (int l1 = 0; l1 <= l - l2; l1++)
			{
				int x1 = Math.min(x[1] + l1, x[2] + l2);
				int x2 = Math.max(x[1] + l1, x[2] + l2);
				int l0Min = Math.max(0, x2 - x1 - x[0] + 1);
				int l0Max = Math.min(l - l2 - l1, x1 + x2 - x[0] - 1);
//				out.println(x1 + ", " + x2 + ", " + l0Min + "-" + l0Max);
				result += Math.max(0, l0Max - l0Min + 1);
			}
		}
		System.out.println(result);
	}
}


import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class C
{
	public static final Random RANDOM = new Random(System.currentTimeMillis());
	private BufferedReader bufferedReader;
	private StringTokenizer stringTokenizer;
	private PrintWriter out;

	public C()
	{
		this(new BufferedReader(new InputStreamReader(System.in)));
	}

	public C(BufferedReader bufferedReader)
	{
		this.bufferedReader = bufferedReader;
		this.stringTokenizer = null;
		this.out = new PrintWriter(new BufferedOutputStream(System.out));
	}

	public C(String file) throws FileNotFoundException
	{
		this(new BufferedReader(new InputStreamReader(new FileInputStream(file))));
	}

	private String next() throws IOException
	{
		while ((this.stringTokenizer == null) || (!this.stringTokenizer.hasMoreTokens()))
		{
			this.stringTokenizer = new StringTokenizer(this.bufferedReader.readLine());
		}
		return stringTokenizer.nextToken();
	}

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

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

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

	public String nextLine() throws IOException
	{
		return this.bufferedReader.readLine();
	}

	public void close()
	{
		out.close();
	}

	public static void main(String[] args)
	{
		C template = new C();
		try
		{
			template.solve();
		}
		catch (IOException exception)
		{
			exception.printStackTrace();
		}
		template.close();
	}

	public static boolean degenerate(int[] x)
	{
		boolean result = false;
		for (int index = 0; index < 3; index++)
		{
			result |= x[index] >= x[(index + 1) % 3] + x[(index + 2) % 3];
		}
		return result;
	}

	public static long sumUpTo(int n)
	{
		n = Math.max(0, n);
		return n * (n + 1) / 2;
	}

	public static long countTooLongX0(int x0, int x1, int x2, int l, int l0)
	{
		return sumUpTo(Math.min(x0 + l0 - x1 - x2 + 1, l - l0 + 1));
	}

	public static long countTooLongX1(int x0, int x1, int x2, int l, int l0)
	{
		long result;
		int diff = Math.max(0, l - l0 - (x0 + l0 + x2 - x1 - 1));
		if (diff % 2 == 0)
		{
			result = sumUpTo(diff / 2) * 2;
		}
		else
		{
			result = (diff + 1) * (diff + 1) / 2 / 2;
		}
		return result;
	}

	public static long solveUnsorted(int[] x, int l)
	{
		long result = 0;
		for (int l0 = 0; l0 <= l; l0++)
		{
			result += sumUpTo(l - l0 + 1);
			result -= countTooLongX0(x[0], x[1], x[2], l, l0);
			result -= countTooLongX1(x[0], x[1], x[2], l, l0);
			result -= countTooLongX1(x[0], x[2], x[1], l, l0);
		}
		return result;
	}

	public static long solve(int[] x, int l)
	{
		Arrays.sort(x);
		return solveUnsorted(new int[]
		{ x[2], x[1], x[0] }, l);
	}

	public static long solveSlow(int x0, int x1, int x2, int l)
	{
		long result = 0;
		for (int l0 = 0; l0 <= l; l0++)
		{
			for (int l1 = 0; l1 <= l; l1++)
			{
				for (int l2 = 0; l2 <= l; l2++)
				{
					if (l0 + l1 + l2 <= l)
					{
						if (!degenerate(new int[]
						{ x0 + l0, x1 + l1, x2 + l2 }))
						{
							result += 1;
						}
					}
				}
			}
		}
		return result;
	}

	public void solve() throws IOException
	{
		int[] x = new int[3];
		x[0] = nextInt();
		x[1] = nextInt();
		x[2] = nextInt();
		int l = nextInt();
		//		for (int l2 = 0; l2 <= l; l2++)
		//		{
		//			for (int l1 = 0; l1 <= l - l2; l1++)
		//			{
		//				int x1 = Math.min(x[1] + l1, x[2] + l2);
		//				int x2 = Math.max(x[1] + l1, x[2] + l2);
		//				int l0Min = Math.max(0, x2 - x1 - x[0] + 1);
		//				int l0Max = Math.min(l - l2 - l1, x1 + x2 - x[0] - 1);
		//				result += Math.max(0, l0Max - l0Min + 1);
		//			}
		//		}
		System.out.println(solve(x, l));
	}
}


import java.util.*;
public class Pipeline {
	public static void main(String [] args){
		Scanner input=new Scanner (System.in);
		int n=input.nextInt();
		int k=input.nextInt();
		System.out.println(min(n,k));
	}
	public static int min(int n,int k){
		int min=1;
		int max=k;
		int num=(k*(k-1))/2+1;
		if(num<n)
			return -1;
		else if(k==n)
			return 1;
		else{
			while(min<max){
				int mid=min+(max-min+1)/2;
				if(isValid(mid,num)==true){
					min=mid;
				}
				else max=mid-1;
			}
		}
		return min;
	}
	public static boolean isValid(int mid,int n){
		return(sumMid(mid,n)>n);
	}
	public static long sumMid(int mid,int k){
		long sumFromMid=(mid*(mid-1))/2+1;
		long sumToEnd= (k*(k-1))/2+1;
		return sumToEnd-sumFromMid;
	}
}