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

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 *
 * @author pttrung
 */
public class B {

    public static void main(String[] args) {
        Scanner in = new Scanner();
        PrintWriter out = new PrintWriter(System.out);
        int x = in.nextInt();
        if(x < 0){
            x = -x;
        }
        int step = 0;
        while(true){
            long val = step*(step + 1)/2;
            if(val >= x &&(val - x)%2 == 0 ){
                out.println(step);
                break;
            }
            step++;
        }
        out.close();
    }

    public double pow(double a, int b) {
        if (b == 0) {
            return 1;
        }
        if (b == 1) {
            return a;
        }
        double val = pow(a, b / 2);
        if (b % 2 == 0) {
            return val * val;
        } else {
            return val * val * a;
        }
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }

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

    static class Scanner {

        BufferedReader br;
        StringTokenizer st;

        public Scanner() {
            // System.setOut(new PrintStream(new BufferedOutputStream(System.out), true));
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public String next() {

            while (st == null || !st.hasMoreTokens()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

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

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

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

        public String nextLine() {
            st = null;
            try {
                return br.readLine();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }

        public boolean endLine() {
            try {
                String next = br.readLine();
                while (next != null && next.trim().isEmpty()) {
                    next = br.readLine();
                }
                if (next == null) {
                    return true;
                }
                st = new StringTokenizer(next);
                return st.hasMoreTokens();
            } catch (Exception e) {
                throw new RuntimeException();
            }
        }
    }
}


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

public class C952 {

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

		st = new StringTokenizer(in.readLine());
		int n = i();

		st = new StringTokenizer(in.readLine());
		int j = i();

		boolean no = false;

		for (int i = 1; i < n; i++) {
			int k = i();
			if (Math.abs(k - j) >= 2) {
				no = true; break;
			}
			j = k;
		}

		out.println(no ? "NO" : "YES");

		out.close();
	}

	static BufferedReader in;
	static StringTokenizer st;
	static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
	static {
		try {
			in = new BufferedReader(new FileReader("cf.in"));
		} catch (Exception e) {
			in = new BufferedReader(new InputStreamReader(System.in));
		}
	}
	static int i() {return Integer.parseInt(st.nextToken());}
	static double d() {return Double.parseDouble(st.nextToken());}
	static String s() {return st.nextToken();}
	static long l() {return Long.parseLong(st.nextToken());}
}


import java.io.*;
import java.util.*;
public class Main2 {
    BufferedReader in;
    PrintWriter out;
    Main2() {
        try {
            in = new BufferedReader(new FileReader("input.txt"));
            out = new PrintWriter(new FileWriter("output.txt"),true);
            solve();
        } catch (Exception ex) {
            ex.printStackTrace();
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out,true);
            solve();
        } finally {
            try {
                in.close();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            out.close();
        }
    }

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

    public Long nextLong() {
        return Long.valueOf(nextToken());
    }

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

    public void solve() {
        int n = nextInt();
        int m = nextInt();
        int countBus = 0;
        int delta = 0;
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = nextInt();
        }
        delta = arr[0];
        boolean norm = false;
        for (int i = 1; i < n; i++) {
            if (delta + arr[i] <= m) {
                delta += arr[i];
                norm = false;
            } else {
                norm = true;
                countBus++;
                delta = arr[i];
                if (i == n-1) {
                    countBus++;
                }
            }
        }
        if (!norm)
            countBus++;
        out.print(countBus);
    }

    public static void main(String[] args) {
        new Main2();
    }
}


import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class WrongSubtraction {

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

  PrintWriter out;
  Reader in;
  BufferedReader br;

  WrongSubtraction() throws Exception {

    // in = new Reader("input.txt");
    // out = new PrintWriter( new BufferedWriter(new FileWriter("output.txt")) );

    br = new BufferedReader(new InputStreamReader(System.in));
    in = new Reader();
    out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

  }

  void go() throws Exception {

    int t = 1;
    while (t > 0) {
      solve();
      t--;
    }

    //System.err.println(System.currentTimeMillis() - time);

    out.flush();
    out.close();
  }

  int inf = 2000000000;
  int mod = 1000000007;
  double eps = 0.000000001;

  int n;
  int m;

  void solve() throws Exception {

    int n = in.nextInt();
    int k = in.nextInt();

    while (k > 0) {

      if (n%10 == 0) n /= 10; else n--;
      k--;
    }

    out.println(n);
  }

  class Reader {

    BufferedReader  br;
    StringTokenizer tok;

    public Reader(String file) throws Exception {
      br = new BufferedReader( new FileReader(file) );
    }

    public Reader() throws Exception {
      br = new BufferedReader( new InputStreamReader(System.in) );
    }

    public String next() throws Exception {

      while (tok == null || !tok.hasMoreElements())
        tok = new StringTokenizer(br.readLine());
      return tok.nextToken();
    }

    public int nextInt() throws Exception {
      return Integer.valueOf(next());
    }

    public long nextLong() throws Exception {
      return Long.valueOf(next());
    }

    public double nextDouble() throws Exception {
      return Double.valueOf(next());
    }

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

  }

  static class InputReader {

    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public InputReader() {
      din = new DataInputStream(System.in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public InputReader(String file_name) throws Exception {
      din = new DataInputStream(new FileInputStream(file_name));
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
    }

    public String readLine() throws Exception {
      byte[] buf = new byte[64]; // line length
      int cnt = 0, c;
      while ((c = read()) != -1) {
        if (c == '\n') {
          break;
        }
        buf[cnt++] = (byte) c;
      }
      return new String(buf, 0, cnt);
    }

    public int nextInt() throws Exception {
      int ret = 0;
      byte c = read();
      while (c <= ' ') {
        c = read();
      }
      boolean neg = (c == '-');
      if (neg) {
        c = read();
      }
      do {
        ret = ret * 10 + c - '0';
      }  while ((c = read()) >= '0' && c <= '9');

      if (neg) {
        return -ret;
      }
      return ret;
    }

    public long nextLong() throws Exception {
      long ret = 0;
      byte c = read();
      while (c <= ' ') {
        c = read();
      }
      boolean neg = (c == '-');
      if (neg) {
        c = read();
      }
      do {
        ret = ret * 10 + c - '0';
      }
      while ((c = read()) >= '0' && c <= '9');
      return neg ? -ret : ret;
    }

    public double nextDouble() throws Exception {
      double ret = 0, div = 1;
      byte c = read();
      while (c <= ' ')
        c = read();
      boolean neg = (c == '-');
      if (neg)
        c = read();

      do {
        ret = ret * 10 + c - '0';
      }
      while ((c = read()) >= '0' && c <= '9');

      if (c == '.') {
        while ((c = read()) >= '0' && c <= '9') {
          ret += (c - '0') / (div *= 10);
        }
      }

      return neg ? -ret : ret;
    }

    private void fillBuffer() throws Exception {
      bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
      if (bytesRead == -1) {
        buffer[0] = -1;
      }
    }

    private byte read() throws Exception {
      if (bufferPointer == bytesRead) {
        fillBuffer();
      }
      return buffer[bufferPointer++];
    }

    public void close() throws Exception {
      if (din == null) {
        return;
      }
      din.close();
    }
  }

}


import java.util.Scanner;

public class _1A {
	public static void main(String[] args) {

		Scanner key = new Scanner(System.in);

		long m, n, a;
		do {
			m = key.nextInt();
			n = key.nextInt();
			a = key.nextInt();
		}while(m<=0 || n<=0 || a<=0);
		//int x = m+n;
		long c1 = (m%a != 0)? (m/a)+1:m/a;
		long c2 = (n%a != 0)? (n/a)+1:n/a;;
		//c*=c;
		System.out.println(c1*c2);

		//int u = 1000000000;
	}

}


import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
    static Set<Integer> alphabet = new HashSet<>(26);
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner scanner = new Scanner (System.in);
        int n = scanner.nextInt();
        scanner.nextLine();
        String str = scanner.nextLine().toLowerCase();
        int count = 0;
        HashSet<Character> al = new HashSet<Character>();
        char[] arr= str.toCharArray();
        for (int i=0; i<arr.length; i++)
        {
            al.add(arr[i]);
        }

        if(al.size()==26){
            System.out.println("YES");
        }else
            System.out.println("NO");
    }
}


import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.lang.*;
import static java.lang.System.*;
import static java.lang.Math.*;
/*created by aditya76*/
public class adi {
        static int maxx=Integer.MAX_VALUE;
        static int mod=1000000007;
        public static void main(String[] args) throws IOException {
        InputReader sc=new InputReader(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int f=sc.nextInt();
        int k=sc.nextInt();
        int i=0;
        int t=b;
        int ans=0;
    		if(b<f || b<a-f){
    			out.println(-1);
    			return ;
    		}
    		for(i=0;i<k-1;i++){
    			if((i&1)==0)
    			{
    				if(t<f)
    				{
    					out.println(-1);
    					out.close();
    					return ;
    				}
    				if(t<(2*a-f))
    				{
    					ans++;
    					t=b+f-a;
    				}
    				else
    					t-=a;
    			}
    			else
    			{
    				if(t<(a-f))
    				{
    					out.println(-1);
    					return ;
    				}
    				if(t<(a+f))
    				{
    					ans++;
    					t=b-f;
    				}
    				else
    					t-=a;
    			}
    		}
    		if(((i&1)==0 && t<f) || ((i&1)!=0 && t<(a-f)))
    		{
    			out.println(-1);
    			return ;
    		}
    		if(t<a)
    			ans++;
    		out.println(ans);
}

//lcs
public static int lcs(String s1, String s2){
    char[] X=s1.toCharArray();
    char[] Y=s2.toCharArray();
    int m=X.length;
    int n=Y.length;
    int L[][] = new int[m+1][n+1];
    for (int i=0; i<=m; i++){
      for (int j=0; j<=n; j++){
        if (i == 0 || j == 0)
            L[i][j] = 0;
        else if (X[i-1] == Y[j-1])
            L[i][j] = L[i-1][j-1] + 1;
        else
            L[i][j] = unity(L[i-1][j], L[i][j-1]);
      }
    }
  return L[m][n];
  }
//unity function
  public static int unity(int a, int b){
    return (a > b)? a : b;
}

//longest increasing subsequence (n log n)
public static int CeilIndex(int A[],int l,int r,int key){
        while(r-l>1){
            int m=l+(r-l)/2;
            if (A[m]>=key)
                r=m;
            else
                l=m;
      }
      return r;
    }

 public static int lis(int A[]){
        int size=A.length;
        int[] tailTable   = new int[size];
        int len;
        tailTable[0] = A[0];
        len = 1;
        for (int i=1;i<size;i++){
            if (A[i]<tailTable[0])
                tailTable[0]=A[i];
            else if(A[i]>tailTable[len-1])
                tailTable[len++]=A[i];
            else
                tailTable[CeilIndex(tailTable, -1, len-1, A[i])] = A[i];
        }
        return len;
    }

//binary modular
public static long bxp(long a,long b){
        long res=1;
        while(b>0){
          if(b%2!=0)
            res=res*a;
          a=(a*a);
          b>>=1;
      }
  return res;
}
//euclid gcd
public static int gcd(int p, int q) {
        if (q == 0)
          return p;
        return gcd(q, p % q);
      }
//prime
public static boolean isprime(long number){
        for(int i=2;i<=sqrt(number); i++){
          if(number % i == 0){
            return false;
          }
      }
        return true;
}

//large fibbonacci
public static int ffb(int n) {
		BigInteger a = BigInteger.ZERO;
		BigInteger b = BigInteger.ONE;
		int m = 0;
		for (int i = 31 - Integer.numberOfLeadingZeros(n); i >= 0; i--) {
			assert a.equals(sfb(m));
			assert b.equals(sfb(m+1));
			BigInteger d = multiply(a, b.shiftLeft(1).subtract(a));
			BigInteger e = multiply(a, a).add(multiply(b, b));
			a = d;
			b = e;
			m *= 2;
			assert a.equals(sfb(m));
			assert b.equals(sfb(m+1));
			if (((n >>> i) & 1) != 0) {
				BigInteger c = a.add(b);
				a = b;
				b = c;
				m++;
				assert a.equals(sfb(m));
				assert b.equals(sfb(m+1));
			}
		}
		return a.intValue();
	}

public static BigInteger sfb(int n) {
  		BigInteger a = BigInteger.ZERO;
  		BigInteger b = BigInteger.ONE;
  		for (int i = 0; i < n; i++) {
  			BigInteger c = a.add(b);
  			a = b;
  			b = c;
  		}
  		return a;
  	}

public static BigInteger multiply(BigInteger x, BigInteger y) {
    		return x.multiply(y);
  }
//reverse string
public static String rev(String s){
    StringBuilder sb=new StringBuilder(s);
	  sb.reverse();
	  return sb.toString();
}
//least common multiple
public static int lcm(int a, int b){
    return a * (b / gcd(a, b));
}

//depth first search
public static void dfs(ArrayList<ArrayList<Integer>> adjLists,boolean[] neha,int v){
      neha[v]=true;
    //System.out.print(v+" ");
      for(int w:adjLists.get(v)){
        if(!neha[w]){
          dfs(adjLists,neha,w);
      }
    }
}

//sieve prime
public static ArrayList<Integer> sieve(int n,int m){
      boolean[] isPrime = new boolean[n+1];
      ArrayList<Integer> al=new ArrayList<Integer>();
        for (int i = 2; i <= n; i++)
            isPrime[i] = true;
        for (int factor = 2; factor*factor <=n; factor++) {
            if (isPrime[factor]) {
                for (int j = factor; factor*j <= n; j++)
                    isPrime[factor*j] = false;
            }
        }
        int primes = 0;
        for (int i = m; i <= n; i++) {
            if (isPrime[i])
              al.add(i);
            }
        return al;
        }

//input reader
static class InputReader {
      private final InputStream stream;
      private final byte[] buf = new byte[8192];
      private int curChar, snumChars;
      public InputReader(InputStream st) {
            this.stream = st;
        }
      public int read() {
          if (snumChars == -1)
              throw new InputMismatchException();
          if (curChar >= snumChars) {
              curChar = 0;
              try {
                  snumChars = stream.read(buf);
                } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (snumChars <= 0)
                  return -1;
            }
              return buf[curChar++];
          }
      public int nextInt() {
          int c = read();
          while (isSpaceChar(c)) {
              c = read();
            }
          int sgn = 1;
            if (c == '-') {
              sgn = -1;
              c = read();
            }
          int res = 0;
          do{
            res *= 10;
            res += c - '0';
            c = read();
          } while (!isSpaceChar(c));
            return res * sgn;
          }
      public long nextLong() {
          int c = read();
          while (isSpaceChar(c)) {
              c = read();
            }
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = read();
            }
          long res = 0;
          do {
            res *= 10;
            res += c - '0';
            c = read();
          } while (!isSpaceChar(c));
              return res * sgn;
          }
      public int[] nextIntArray(int n) {
              int a[] = new int[n];
              for (int i = 0; i < n; i++) {
                a[i] = nextInt();
              }
              return a;
            }

      public String readString() {
              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 String readLine() {
              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 boolean isSpaceChar(int c) {
              return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
            }

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


import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Test {
    InputStream is;
    PrintWriter out;
    String INPUT = "";
    long[] F;

    void solve()
    {
        F = new long[17];
        F[0] = 1;
        for(int i = 1;i <= 16;i++)F[i] = F[i-1] * i;

        long K = nl();
        int t = ni();
        K--;
        gouter:
        for(int len = 1;;len++){
            long ret = 0;
            int[] rem = new int[16];
            Arrays.fill(rem, t);
            outer:
            for(int i = 0;i < len;i++){
                for(int j = i == 0 ? 1 : 0;j < 16;j++){
                    rem[j]--;
                    long count = count(rem, len-1-i);
                    if(K < count){
                        ret = ret * 16 + j;
                        continue outer;
                    }else{
                        K -= count;
                    }
                    rem[j]++;
                }
                continue gouter;
            }
            out.println(Long.toHexString(ret));
            return;
        }
    }

    long count(int[] rem, int len)
    {
        long[] dp = new long[len+1];
        dp[0] = F[len];
        for(int x : rem){
            if(x < 0)return 0;
            if(x == 0)continue;
            for(int i = len;i >= 0;i--){
                for (int j = 1; j <= x; j++) {
                    if ((i - j) < 0) break;
                    dp[i] += dp[i - j] / F[j];
                }
            }
        }
        return dp[len];
    }

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

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

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

    private byte[] inbuf = new byte[1024];
    private int lenbuf = 0, ptrbuf = 0;

    private int readByte()
    {
        if(lenbuf == -1)throw new InputMismatchException();
        if(ptrbuf >= lenbuf){
            ptrbuf = 0;
            try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
            if(lenbuf <= 0)return -1;
        }
        return inbuf[ptrbuf++];
    }

    private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
    private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

    private double nd() { return Double.parseDouble(ns()); }
    private char nc() { return (char)skip(); }

    private String ns()
    {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    private char[] ns(int n)
    {
        char[] buf = new char[n];
        int b = skip(), p = 0;
        while(p < n && !(isSpaceChar(b))){
            buf[p++] = (char)b;
            b = readByte();
        }
        return n == p ? buf : Arrays.copyOf(buf, p);
    }

    private char[][] nm(int n, int m)
    {
        char[][] map = new char[n][];
        for(int i = 0;i < n;i++)map[i] = ns(m);
        return map;
    }

    private int[] na(int n)
    {
        int[] a = new int[n];
        for(int i = 0;i < n;i++)a[i] = ni();
        return a;
    }

    private int ni()
    {
        int num = 0, b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private long nl()
    {
        long num = 0;
        int b;
        boolean minus = false;
        while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
        if(b == '-'){
            minus = true;
            b = readByte();
        }

        while(true){
            if(b >= '0' && b <= '9'){
                num = num * 10 + (b - '0');
            }else{
                return minus ? -num : num;
            }
            b = readByte();
        }
    }

    private boolean oj = true;//System.getProperty("ONLINE_JUDGE") != null;
    private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


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

public class Solution {
   BufferedReader in;
   StringTokenizer str;
   PrintWriter out;
   String SK;
   String next() throws IOException {
      while ((str == null) || (!str.hasMoreTokens())) {
      SK = in.readLine();
      if (SK == null)
      return null;
      str = new StringTokenizer(SK);
      }
      return str.nextToken();
   }
   int nextInt() throws IOException {
      return Integer.parseInt(next());
   }
   double nextDouble() throws IOException {
      return Double.parseDouble(next());
   }
   long nextLong() throws IOException {
      return Long.parseLong(next());
   }
   char[] charArray() throws IOException{
      return next().toCharArray();
   }
   public static void main(String[] args) throws IOException {
      new Solution().run();
   }
   void run() throws IOException {
      in = new BufferedReader(new InputStreamReader(System.in));
      out = new PrintWriter(System.out);
      //in = new BufferedReader(new FileReader("input.txt"));
      //out = new PrintWriter("output.txt");
      solve();
      out.close();
   }
   void solve() throws IOException {
      int n=nextInt();
      int ar[] = new int[n];
      int res=0;
      for (int i = 0; i < n; i++) {
         ar[i] = nextInt();
         if(ar[i]==1){
            res++;
         }
      }
      int max=0;
      int res2=0;
      for (int i = 0; i < n; i++) {
         for (int j = i; j < n; j++) {
            max=0;
            int o=0;
            for (int k = i; k <= j; k++) {
               if(ar[k]==0){
                  max++;
               }
               else o++;
            }
            res2=Math.max(res2,max+res-o);

         }
       }
      out.println(res2);
   }

}


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

import java.io.*;
import java.util.*;
/**
 *
 * @author Rohan
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        input();
    }

    static int u;
    static int l;
    static int a,b,c,d;
    public static void input() {
        InputReader in=new InputReader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=in.readInt(); a=b=c=d=0; int p,q;
        for(int i=0;i<n;i++) {
            p=in.readInt(); u+=p;
            q=in.readInt(); l+=q; if(q%2!=p%2) a++;

        }
        out.println(solve(n)); out.flush(); out.close();
    }

    public static int solve(int n) {
        if(u%2==0 && l%2==0) return 0;
        if(a%2==0 && a>0) return 1;
        return -1;
    }
}
class InputReader {

        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

        public int readInt() {
            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 long readLong() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            long 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 String readString() {
            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 boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
}


import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;

public class A58 {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		Queue<String> queue = new LinkedList<String>();
		queue.add("h");
		queue.add("e");
		queue.add("l");
		queue.add("l");
		queue.add("o");
		for(int i = 0, len = s.length(); i < len; ++i){
			if(0 == queue.size()){
				break;
			}
			String temp = queue.peek();
			if(s.substring(i, i+1).equals(temp)){
				queue.poll();
			}
		}
		System.out.println(0 == queue.size() ? "YES" : "NO");

	}
}


// B. Network Configuration
// https://codeforces.com/problemset/problem/448/A

import java.util.Scanner;

public class A23 {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int c=0;
		for(int i = 0; i<3;i++)
			c+=sc.nextInt();

		int m=0;
		for(int i = 0; i<3;i++)
			m+=sc.nextInt();

		int s=sc.nextInt();

		int s1= c/5 + (c%5==0?0:1);
		int s2= m/10 + (m%10==0?0:1);

		s-=s1;
		s-=s2;

		if(s<0)
			System.out.println("NO");
		else
			System.out.println("YES");

	}
}


//package que_a;

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

public class utkarsh {

    InputStream is;
    PrintWriter out;

    long inf = (long) (1e15);
    boolean SHOW_TIME;

    void solve() {
        //Enter code here utkarsh
        //SHOW_TIME = true;
        double x1 = nd(), y1 = nd();
        double x2 = nd(), y2 = nd();
        double x3 = nd(), y3 = nd();
        double m1 = inf;
        if(x1 != x2) m1 = (y2 - y1) / (x2 - x1);
        double m2 = inf;
        if(x2 != x3) m2 = (y3 - y2) / (x3 - x2);
        long d1 = (long)((y2 - y1) * (y2 - y1)) + (long)((x2 - x1) * (x2 - x1));
        long d2 = (long)((y3 - y2) * (y3 - y2)) + (long)((x3 - x2) * (x3 - x2));
        //out.println(d1 +" "+ d2);
        if(m1 == m2 || d1 != d2) {
            out.println("No");
        } else {
            out.println("Yes");
        }
    }

    //---------- I/O Template ----------

    public static void main(String[] args) { new utkarsh().run(); }
    void run() {
        is = System.in;
        out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();
        solve();
        long end = System.currentTimeMillis();
        if(SHOW_TIME) out.println("\n" + (end - start) + " ms");
        out.flush();
    }

    byte input[] = new byte[1024];
    int len = 0, ptr = 0;

    int readByte() {
        if(ptr >= len) { ptr = 0;
            try { len = is.read(input); }
            catch(IOException e) { throw new InputMismatchException(); }
            if(len <= 0) { return -1; }
        } return input[ptr++];
    }
    boolean isSpaceChar(int c) { return !( c >= 33 && c <= 126 ); }
    int skip() {
        int b = readByte();
        while(b != -1 && isSpaceChar(b)) { b = readByte(); }
        return b;
    }

    char nc() { return (char)skip(); }
    String ns() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while(!isSpaceChar(b)) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    String nLine() {
        int b = skip();
        StringBuilder sb = new StringBuilder();
        while( !(isSpaceChar(b) && b != ' ') ) { sb.appendCodePoint(b); b = readByte(); }
        return sb.toString();
    }
    int ni() {
        int n = 0, b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        if(b == -1) { return -1; }  //no input
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }
    long nl() {
        long n = 0L;    int b = readByte();
        boolean minus = false;
        while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')) { b = readByte(); }
        if(b == '-') { minus = true; b = readByte(); }
        while(b >= '0' && b <= '9') { n = n * 10 + (b - '0'); b = readByte(); }
        return minus ? -n : n;
    }

    double nd() { return Double.parseDouble(ns()); }
    float nf() { return Float.parseFloat(ns()); }
    int[] na(int n) {
        int a[] = new int[n];
        for(int i = 0; i < n; i++) { a[i] = ni(); }
        return a;
    }
    char[] ns(int n) {
        char c[] = new char[n];
        int i, b = skip();
        for(i = 0; i < n; i++) {
            if(isSpaceChar(b)) { break; }
            c[i] = (char)b; b = readByte();
        } return i == n ? c : Arrays.copyOf(c,i);
    }
}


import java.util.*;
import java.io.*;
import java.lang.*;
public class Task{
public static void main(String[] args) throws FileNotFoundException, IOException{
       Scanner s=new Scanner(System.in);
       BufferedWriter out=new BufferedWriter(new OutputStreamWriter(System.out));
       int n1=s.nextInt(),m1=s.nextInt();
       int n=Math.min(n1,m1),m=Math.min(2*n,n1+m1-n);
       int x=2*n-m,y=2*m-n;
     out.write(x/3+y/3+(x%3+y%3)/3+"");
        out.flush();
  }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.*;

public class A {

    private boolean can(String s) {
        boolean can = true;
        for (int i = 0; i < s.length(); i++) {
            if (Character.isLowerCase(s.charAt(i))) can = false;
        }

        if (can) {
            return true;
        }
        return false;
    }

    private void solve() throws IOException {
        String s = nextToken();
        if (can(s)) {
            System.out.println(s.toLowerCase());
            return;
        }
        if (Character.isLowerCase(s.charAt(0))) {
            if (can(s.substring(1))) {
                System.out.println(Character.toUpperCase(s.charAt(0)) + s.substring(1).toLowerCase());
                return;
            }
        }
        System.out.println(s);
    }

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

    BufferedReader reader;
    StringTokenizer tokenizer;
    PrintWriter writer;

    public void run() {
        try {
            reader = new BufferedReader(new InputStreamReader(System.in));
            tokenizer = null;
            writer = new PrintWriter(System.out);
            solve();
            reader.close();
            writer.close();
        }
        catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

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

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

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

    BigInteger nextBigInteger() throws IOException {
        return new BigInteger(nextToken());
    }

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


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

/**
 *
 */
public class TaskA {
    public static void main(String[] args) {
        InputStream inputStream;
        String str = null;
        if(str == null){
            inputStream = System.in;
        }else{
            inputStream = new ByteArrayInputStream(str.getBytes());
        }

        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(1, in, out);
        out.close();
    }

    static class Solver {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int cost = in.nextInt();
            int current = in.nextInt();
            int bananas = in.nextInt();

            int total = cost*(bananas*(bananas+1)/2);

            System.out.println(Math.max(0,total-current));
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

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


/**
 * Created by gosugdr on 4/22/15.
 */

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

public class A379 {
    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException {
        out.println(in.nextInt() > in.nextInt() ? "First" : "Second");
    }

    public void run() {
        try {
            in = new FastScanner(System.in);
            out = new PrintWriter(System.out);

            solve();

            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

    public static void main(String[] arg) {
        new A379().run();
    }
}


import java.util.Scanner;

public class A{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int start = in.nextInt();
        int distance = in.nextInt();
        int walk = (distance)%n; // gives effective distance

        if (start + walk < 0){
            // System.out.println("Less");
            int out = (n +(walk + start));
            System.out.println(out);
        }else if (start + walk == 0){
            // System.out.println("equal");
            System.out.println(n);
        }else{
            // System.out.println("greater");
            if ((start+walk)%n == 0)
                System.out.println(n);
            else
                System.out.println((start+walk)%n);
        }
    }
}


import java.io.*;

 import java.util.*;

    public class Training {

      public static void main(String[] args) throws IOException {
        Scanner input = new Scanner(System.in);
        long n = input.nextLong(),k= input.nextLong();

         long a  = n/2/(k+1);
         long b = a *k  ;
          System.out.println(a +" "+b+" "+(n-a-b));

     }  // end main

    }


public class C {

	public C () {
		long N = sc.nextLong();

		int res = 0;
		for (int k : rep(1, 2000000)) {
			long M = N - 2*k;
			if (M % 3 == 0)
				if (M/3 >= 1L*k*(k-1)/2)
					++res;
		}

		exit(res);
	}

	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 final static IOUtils.MyScanner sc = new IOUtils.MyScanner();
	private static void exit (Object o, Object ... A) { IOUtils.print(o, A); IOUtils.exit(); }
	private static class IOUtils {
		public static class MyScanner {
			public String next() { newLine(); return line[index++]; }
			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 = split(readLine());
					index = 0;
				}
			}
			private String [] split(String s) { return s.length() > 0 ? s.split(" ") : new String [0]; }
		}
		private static String build(Object o, Object ... A) { return buildDelim(" ", o, A); }
		private static String buildDelim(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 start() { if (t == 0) t = millis(); }
		private static void append(StringBuilder b, Object o, String delim) {
			if (o.getClass().isArray()) {
				int len = java.lang.reflect.Array.getLength(o);
				for (int i = 0; i < len; ++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 {
				if (o instanceof Double)
					o = new java.text.DecimalFormat("#.############").format(o);
				b.append(delim).append(o);
			}
		}
		private static java.io.PrintWriter pw = new java.io.PrintWriter(System.out);
		private static void print(Object o, Object ... A) { pw.println(build(o, A)); }
		private static void err(Object o, Object ... A) { System.err.println(build(o, A)); }
		private static void exit() {
			IOUtils.pw.close();
			System.out.flush();
			err("------------------");
			err(IOUtils.time());
			System.exit(0);
		}
		private static long t;
		private static long millis() { return System.currentTimeMillis(); }
		private static String time() { return "Time: " + (millis() - t) / 1000.0; }
	}
	public static void main (String[] args) { new C(); IOUtils.exit(); }
}


import java.util.Scanner;

public class Main
{
	public static void main(String[] args)
	{
		Scanner input = new Scanner (System.in);
		int N;
		while(input.hasNext())
		{
			N = input.nextInt();
			int ans = (N/7)*2;
			int Mod = N%7;
			if(Mod == 0)
				System.out.printf("%d %d\n",ans, ans);
			else if(Mod == 1)
				System.out.printf("%d %d\n",ans, ans+1);
			else if(Mod >= 2 && Mod <= 5)
				System.out.printf("%d %d\n",ans, ans+2);
			else
				System.out.printf("%d %d\n",ans+1, ans+2);
		}
	}
}


import java.io.*;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
import java.util.function.BiFunction;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.Map.Entry;

public class Main implements Runnable {
    static final int MOD = (int) 1e9 + 7;
    static final int MI = (int) 1e9;
    static final long ML = (long) 1e18;
    static final Reader in = new Reader();
    static final PrintWriter out = new PrintWriter(System.out);
    StringBuilder answer = new StringBuilder();
    Random random = new Random(751454315315L + System.currentTimeMillis());

    public static void main(String[] args) {
        new Thread(null, new Main(), "persefone", 1 << 28).start();
    }

    @Override
    public void run() {
        solve();
        printf();
        flush();
    }

    void solve() {
        int[] s = in.next().chars().map(n -> n - '0').toArray();
        int m = in.nextInt();
        int n = s.length;
        long[][] dp = new long[1 << n][m];
        dp[0][0] = 1;
        for (int mask = 0; mask < 1 << n; mask++) {
            for (int reminder = 0; reminder < m; reminder++) {
                if (dp[mask][reminder] == 0) {
                    continue;
                }
                for (int pos = 0; pos < n; pos++) {
                    if (mask == 0 && s[pos] == 0) continue;
                    if ((mask & (1 << pos)) > 0) continue;
                    int new_reminder = (10 * reminder + s[pos]) % m;
                    dp[mask | (1 << pos)][new_reminder] += dp[mask][reminder];
                }
            }
        }
        long ans = dp[(1 << n) - 1][0];
        long[] fact = new long[20];
        fact[0] = 1;
        for (int i = 1; i < 20; i++) {
            fact[i] = fact[i - 1] * i;
        }
        int[] cnt = new int[10];
        for (int i = 0; i < n; i++) {
            cnt[s[i]]++;
        }
        for (int i = 0; i < 10; i++) {
            ans /= fact[cnt[i]];
        }
        printf(ans);
    }

    void printf() {
        out.print(answer);
    }

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

    void flush() {
        out.flush();
    }

    void printf(Stream<?> str) {
        str.forEach(o -> add(o, " "));
        add("\n");
    }

    void printf(Object... obj) {
        printf(false, obj);
    }

    void printfWithDescription(Object... obj) {
        printf(true, obj);
    }

    private void printf(boolean b, Object... obj) {

        if (obj.length > 1) {
            for (int i = 0; i < obj.length; i++) {
                if (b) add(obj[i].getClass().getSimpleName(), " - ");
                if (obj[i] instanceof Collection<?>) {
                    printf((Collection<?>) obj[i]);
                } else if (obj[i] instanceof int[][]) {
                    printf((int[][]) obj[i]);
                } else if (obj[i] instanceof long[][]) {
                    printf((long[][]) obj[i]);
                } else if (obj[i] instanceof double[][]) {
                    printf((double[][]) obj[i]);
                } else printf(obj[i]);
            }
            return;
        }

        if (b) add(obj[0].getClass().getSimpleName(), " - ");
        printf(obj[0]);
    }

    void printf(Object o) {
        if (o instanceof int[])
            printf(Arrays.stream((int[]) o).boxed());
        else if (o instanceof char[])
            printf(new String((char[]) o));
        else if (o instanceof long[])
            printf(Arrays.stream((long[]) o).boxed());
        else if (o instanceof double[])
            printf(Arrays.stream((double[]) o).boxed());
        else if (o instanceof boolean[]) {
            for (boolean b : (boolean[]) o) add(b, " ");
            add("\n");
        } else
            add(o, "\n");
    }

    void printf(int[]... obj) {
        for (int i = 0; i < obj.length; i++) printf(obj[i]);
    }

    void printf(long[]... obj) {
        for (int i = 0; i < obj.length; i++) printf(obj[i]);
    }

    void printf(double[]... obj) {
        for (int i = 0; i < obj.length; i++) printf(obj[i]);
    }

    void printf(boolean[]... obj) {
        for (int i = 0; i < obj.length; i++) printf(obj[i]);
    }

    void printf(Collection<?> col) {
        printf(col.stream());
    }

    <T, K> void add(T t, K k) {
        if (t instanceof Collection<?>) {
            ((Collection<?>) t).forEach(i -> add(i, " "));
        } else if (t instanceof Object[]) {
            Arrays.stream((Object[]) t).forEach(i -> add(i, " "));
        } else
            add(t);
        add(k);
    }

    <T> void add(T t) {
        answer.append(t);
    }

    static class Reader {
        private BufferedReader br;
        private StringTokenizer st;

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

        Reader(String fileName) throws FileNotFoundException {
            br = new BufferedReader(new FileReader(fileName));
        }

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

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

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

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

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

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

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


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

public class tA {
    public static void main(String[] args) throws IOException {
        boolean oj = System.getProperty("ONLINE_JUDGE") != null;
        Scanner in;
        PrintWriter out;
        if (oj) {
            in = new Scanner(System.in);
            out = new PrintWriter(System.out);
        }
        else {
            Reader reader = new FileReader("input.txt");
            Writer writer = new FileWriter("output.txt");
            in = new Scanner(new BufferedReader(reader));
            out = new PrintWriter(writer);
        }
        int[] s = new int[3];
        for (int i = 0; i < 3; i++)
            s[i] = in.nextInt();
        int a = 0, b = 0, c = 0;
        for (int i = 1; i <= s[0] + s[1] + s[2]; i++) {
            a = i;
            b = s[0] / a;
            c = s[2] / a;
            if (a * b == s[0] && b * c == s[1] && a * c == s[2])
                break;
            b = s[0] / a;
            c = s[1] / a;
            if (a * b == s[0] && b * c == s[1] && a * c == s[2])
                break;
            b = s[1] / a;
            c = s[2] / a;
            if (a * b == s[0] && b * c == s[1] && a * c == s[2])
                break;
        }
        out.println(4 * (a + b + c));
        out.flush();
    }

}


import java.io.*;
import java.util.*;
public class a {
	public static void main(String[] arg) throws IOException {
		new a();
	}
	public a() throws IOException {
		FastScanner in = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(System.out);

		int n = in.nextInt();
		int k = in.nextInt();
		int total = 0;
		for(int i = 0; i < n; i++) {
			total += in.nextInt();
			int give = Math.min(8, total);
			k -= give;
			total -= give;
			if(k <= 0) {
				out.println(i+1);
				break;
			}
		}
		if(k > 0) out.println(-1);
		in.close(); out.close();
	}
	class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		public FastScanner(InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
			st = new StringTokenizer("");
		}
		public void close() throws IOException {
			br.close();
		}
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
		public String next() throws IOException {
			while(!st.hasMoreElements()) st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.awt.PageAttributes.OriginType;
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

	static class TaskC {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			char[] t1 = in.next().toCharArray();
			int[] t = new int[6];
			for (int i = 0; i < 6; i++) {
				t[i] = t1[i] - '0';
			}
			int c = t[0] + t[1] + t[2];
			int c2 = t[3 + 0] + t[3 + 1] + t[3 + 2];
			if (c == c2) {
				out.println("0");
				return;
			} else if (c > c2) {
				for (int i = 0; i < 3; i++) {
					int temp = t[i];
					t[i] = t[i + 3];
					t[i + 3] = temp;
				}
				int temp = c;
				c = c2;
				c2 = temp;
			}
			int step = 0;
			while (c < c2) {
				step++;
				int min = 9;
				int max = 0;
				for (int i = 0; i < 3; i++) {
					min = Math.min(min, t[i]);
					max = Math.max(max, t[i + 3]);
				}
				if (9 - min > max) {
					c -= min;
					for (int i = 0; i < 3; i++) {
						if (t[i] == min) {
							t[i] = 9;
							break;
						}
					}
					c += 9;
				} else {
					c2 -= max;
					c2 += 0;
					for (int i = 3; i < 6; i++) {
						if (t[i] == max) {
							t[i] = 0;
							break;
						}
					}
				}
			}
			out.println(step);
		}
	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

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

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

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

		public double nextFloat() {
			return Double.parseDouble(next());
		}

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

	}
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Calendar;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws ParseException, IOException {

         BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
         long n=Long.parseLong(br.readLine());
         System.out.println((int)Math.ceil(1.0*(n+1)/2));

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            long k = in.nextLong();
            int x = in.nextInt();
            int y = in.nextInt();
            long grid[][] = new long[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    if (k > 0) {
                        grid[i][j] = 1;
                        k--;
                    }
                }
            }

            if (k > 0 && n != 1) {
                long mid = (k / (m * n - m));
                boolean isUp = (k / (m * n - m)) % 2 == 0;
                long topRow = (k / (m * n - m)) / 2 + (!isUp ? 1 : 0);
                long bottomRow = ((k / (m * n - m)) / 2);
                long remK = (k % (m * n - m));
                for (int i = 0; i < grid.length; i++) {
                    for (int j = 0; j < grid[0].length; j++) {
                        if (i == 0) {
                            grid[i][j] += topRow;
                        } else if (i == n - 1) {
                            grid[i][j] += bottomRow;
                        } else {
                            grid[i][j] += mid;
                        }
                    }
                }
                for (int i = isUp ? n - 2 : 1; i >= 0 && i < n; i += isUp ? -1 : 1) {
                    for (int j = 0; j < m; j++) {
                        if (remK > 0) {
                            grid[i][j] += 1;
                            remK--;
                        } else {
                            break;
                        }
                    }
                }
            } else if (n == 1) {
                for (int i = 0; i < m; i++) {
                    grid[0][i] += k / m;
                }
                k = k % m;
                for (int i = 0; i < m; i++) {
                    if (k > 0) {
                        grid[0][i] += 1;
                        k--;
                    }

                }
            }
            long max = Long.MIN_VALUE;
            long min = Long.MAX_VALUE;
            for (long column[] : grid) {
                for (long cell : column) {
                    max = Math.max(max, cell);
                    min = Math.min(min, cell);
                }
            }
            out.println(max + " " + min + " " + grid[x - 1][y - 1]);
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

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

        public int readInt() {
            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 long readLong() {
            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;
        }

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

        public int nextInt() {
            return readInt();
        }

        public long nextLong() {
            return readLong();
        }

    }
}


import java.io.PrintStream;
import  java.lang.*;
import static java.lang.Character.isUpperCase;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;
import java.util.*;
import java.util.TreeMap;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
public class simple {
	static class FastReader
	   {
	       BufferedReader br;
	       StringTokenizer st;

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

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

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

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

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

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

	   }

	public static void main(String[] args) {
		FastReader in=new FastReader();
		int a=in.nextInt();
		int b=in.nextInt();
		int c=in.nextInt();
		int d=in.nextInt();
		if(a==d)
		{
			if(c>0 && (a==0 || d==0) )
				System.out.println(0);
			else
			System.out.println(1);
		}
		else
			System.out.println(0);
	}
}


import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main implements Runnable {
	public static void main(String[] args) {
		new Thread(null, new Main(), "", Runtime.getRuntime().maxMemory()).start();
		// new Main().run();
	}

	ArrayList<Long> div = new ArrayList<>();

	long solve(long a, long b) {
		div.clear();
		div.add(a);
		long a_ = a;
		for (long v = 2; v * v <= a_; ++v)
			if (a_ % v == 0) {
				div.add(v);
				if (v != a_ / v)
					div.add(a_ / v);
				while (a_ % v == 0) {
					a_ /= v;
				}
			}
		Collections.sort(div);
		return f(a, b);

	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		System.out.println(solve(a, b));
	}

	long check(long a, long b) {
		if (b == 0)
			return 0;
		return 1 + f(a, b - gcd(a, b));
	}

	long f(long a, long b) {
		if (a == b)
			return 1;
		if (b == 0) {
			return 0;
		}
		if (a == 1) {
			return b;
		}
		if (gcd(a, b) > 1) {
			long gcd = gcd(a, b);
			return f(a / gcd, b / gcd - 1) + 1;
		}
		long nb = 1;
		for (long i : div) {
			if (i > a)
				break;
			if (a % i == 0)
				nb = Math.max(nb, b / i * i);
		}
		if (b > a && nb < a) {
			nb = a;
		}
		// f(3,2)=f(3,1)+1=f(3,0)+2
		long c = 1 + (b - nb);
		long gcd = gcd(a, nb);
		return c + f(a / gcd, nb / gcd - 1);
	}

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

	static boolean isPrime(long n) {
		// 間違える確率4^(-k)=10^(-6)
		if (n == 1 || n % 2 == 0)
			return false;
		long z = n - 1;
		int c2 = 0;
		while (z % 2 == 0) {
			z /= 2;
			++c2;
		}
		outer: for (int k = 0; k < 10; ++k) {
			long a = (int) (Math.random() * 10000) % n;
			if (a == 0)
				continue;
			a = pow(a, z, n);
			if (a == 1 || a == n - 1)
				continue outer;
			for (int i = 0; i < c2 - 1; ++i) {
				a = (a * a) % n;
				if (a == n - 1)
					continue outer;
			}
			return false;
		}
		return true;
	}

	static long pow(long a, long n, long mod) {
		long ret = 1;
		for (; n > 0; n >>= 1, a = (a * a) % mod) {
			if (n % 2 == 1) {
				ret = (ret * a) % mod;
			}
		}
		return ret;
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}


import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.util.Map.Entry;

import static java.lang.Math.*;

public class Solution extends PrintWriter {

	void run() {
		long rot = -nextLong();
		long a = ((rot % 360) + 360) % 360;

		long b = 360;
		int ans = 0;

		for (int i = 0; i < 4; i++) {
			long c = min(a, 360 - a);
			if (c < b) {
				b = c;
				ans = i;
			}
			a = (a + 90) % 360;
		}

		println(ans);

	}

	int[][] nextMatrix(int n, int m) {
		int[][] matrix = new int[n][m];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < m; j++)
				matrix[i][j] = nextInt();
		return matrix;
	}

	String next() {
		while (!tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(nextLine());
		return tokenizer.nextToken();
	}

	boolean hasNext() {
		while (!tokenizer.hasMoreTokens()) {
			String line = nextLine();
			if (line == null) {
				return false;
			}
			tokenizer = new StringTokenizer(line);
		}
		return true;
	}

	int[] nextArray(int n) {
		int[] array = new int[n];
		for (int i = 0; i < n; i++) {
			array[i] = nextInt();
		}
		return array;
	}

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

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

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

	String nextLine() {
		try {
			return reader.readLine();
		} catch (IOException err) {
			return null;
		}
	}

	public Solution(OutputStream outputStream) {
		super(outputStream);
	}

	static BufferedReader reader;
	static StringTokenizer tokenizer = new StringTokenizer("");
	static Random rnd = new Random();

	public static void main(String[] args) throws IOException {
		Solution solution = new Solution(System.out);
		reader = new BufferedReader(new InputStreamReader(System.in));
		solution.run();
		solution.close();
		reader.close();
	}
}


import java.util.Scanner;

public class QAQ {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner s=new Scanner(System.in);
		String str=s.next();
		int n=str.length();
		int[] countOfQ=new int[n];
		if(str.charAt(0)=='Q') countOfQ[0]=1;
		for(int i=1;i<n;i++){
			char ch=str.charAt(i);
			if(ch=='Q') countOfQ[i]=countOfQ[i-1]+1;
			else countOfQ[i]=countOfQ[i-1];
		}
		int ans=0;
		for(int i=0;i<n;i++){
			if(str.charAt(i)=='A'){
				ans+=(countOfQ[i]*(countOfQ[n-1]-countOfQ[i]));
			}
		}
		System.out.println(ans);
	}

}


//package round272;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

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

	void solve()
	{
		int a = ni(), b = ni();
		int mod = 1000000007;
		long s = (long)a*(a+1)/2%mod*b+a;
		s %= mod;
		s = s * ((long)(b-1)*b/2%mod) % mod;
		out.println(s);
	}

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

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

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

	private byte[] inbuf = new byte[1024];
	private int lenbuf = 0, ptrbuf = 0;

	private int readByte()
	{
		if(lenbuf == -1)throw new InputMismatchException();
		if(ptrbuf >= lenbuf){
			ptrbuf = 0;
			try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
			if(lenbuf <= 0)return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
	private int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }

	private double nd() { return Double.parseDouble(ns()); }
	private char nc() { return (char)skip(); }

	private String ns()
	{
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while(!(isSpaceChar(b))){ // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n)
	{
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while(p < n && !(isSpaceChar(b))){
			buf[p++] = (char)b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m)
	{
		char[][] map = new char[n][];
		for(int i = 0;i < n;i++)map[i] = ns(m);
		return map;
	}

	private int[] na(int n)
	{
		int[] a = new int[n];
		for(int i = 0;i < n;i++)a[i] = ni();
		return a;
	}

	private int ni()
	{
		int num = 0, b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl()
	{
		long num = 0;
		int b;
		boolean minus = false;
		while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
		if(b == '-'){
			minus = true;
			b = readByte();
		}

		while(true){
			if(b >= '0' && b <= '9'){
				num = num * 10 + (b - '0');
			}else{
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private boolean oj = System.getProperty("ONLINE_JUDGE") != null;
	private void tr(Object... o) { if(!oj)System.out.println(Arrays.deepToString(o)); }
}


import java.io.*;
import java.util.*;
public class noob {
    InputReader in;
    final long mod=1000000007;
    long m=998244353;
    StringBuilder sb;
    public static void main(String[] args) throws java.lang.Exception {
        new noob().run();
    }
    void run() throws Exception {
        in=new InputReader(System.in);
        sb = new  StringBuilder();
        int t=1;
        for(int i=1;i<=t;i++)
            solve();
        System.out.print(sb);
    }
    long fib(int n) {
        long a[]=new long[n+1];
        a[1]=1;
        for(int i=2;i<=n;i++)
            a[i]=(a[i-1]+a[i-2])%m;
        return a[n];
    }
    void solve() {
        int i,j,k;
        int n=i();
        long val=fib(n);
        long deno=power(2,n,m);
        long ans=(val%m * power(deno, m-2, m))%m;
        sb.append(ans+"\n");
    }
    long power(long x, long y, long p) {
        long res = 1;
        x = x % p;
        if (x == 0) return 0;
        while (y > 0) {
            if((y & 1)==1)
                res = (res * x) % p;
            y = y >> 1;
            x = (x * x) % p;
        }
        return res%p;
    }
    int gcd(int a, int b) {
        return (b==0)?a:gcd(b,a%b);
    }
    String s(){return in.next();}
    int i(){return in.nextInt();}
    long l(){return in.nextLong();}
    double d(){return in.nextDouble();}
    class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
        public int peek() {
            if (numChars == -1)
                return -1;
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    return -1;
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar];
        }
        public void skip(int x) {
            while (x-->0)
                read();
        }
        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public String nextString() {
            return next();
        }
        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }
        public String nextLine() {
            StringBuffer buf = new StringBuffer();
            int c = read();
            while (c != '\n' && c != -1) {
                if (c != '\r')
                    buf.appendCodePoint(c);
                c = read();
            }
            return buf.toString();
        }
        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }
        public boolean hasNext() {
            int value;
            while (isSpaceChar(value = peek()) && value != -1)
                read();
            return value != -1;
        }
        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
    }
}


import java.util.*;
public class Main {

	public static int primefactors(long n){
		for (int i=3;i<=Math.sqrt(n);i+=2){
			if(n%i==0){
				return i;
			}

		}
		return 0;
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
Scanner sc = new Scanner (System.in);
int m=0;
int t=sc .nextInt();

while(t-->0){
	long n=sc .nextLong();
	if (n%2==0){
		System.out.println( n/2+" "+n/2);

	}
	else{

	m=primefactors(n);
	if(m!=0){
	System.out.println((n/m)+" "+(n-n/m));
	}
	else{
		System.out.println(1+" "+ (n-1));
	}

	}

}}}


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

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n=scanner.nextInt();
        int m=scanner.nextInt();
        m--;
        int max=scanner.nextInt();
        int a[]=new int[n];
        for (int i=0;i<n;i++){
            a[i]=scanner.nextInt();
        }
        int minR=-1;
        int minL=-1;
        for (int i=m;i<n;i++){
            if (a[i]!=0 && a[i]<=max){
                minR=i;
                break;
            }
        }
        for (int i=m;i>=0;i--){
            if (a[i]!=0 && a[i]<=max){
                minL=i;
                break;
            }
        }
        if (minR ==-1){
            System.out.println(Math.abs(minL-m)*10);
        }else if (minL ==-1){
            System.out.println(Math.abs(minR-m)*10);
        }else {
            System.out.println(Math.min(Math.abs(minR-m),Math.abs(minL-m))*10);
        }

    }
}


import java.util.Scanner;
import java.io.*;
import java.util.*;
import java.math.*;
import java.lang.*;
import static java.lang.Math.*;

public class TestClass //implements Runnable
{
	/*
	int x,y;
	public TestClass(int x,int y)
	{
		this.x=x;
		this.y=y;
	}*/

	public static void main(String args[]) throws Exception
	{/*
		new Thread(null, new TestClass(),"TESTCLASS",1<<18).start();
	}
	public void run()
	{*/
		//Scanner scan=new Scanner(System.in);
		InputReader hb=new InputReader(System.in);
		PrintWriter w=new PrintWriter(System.out);

		int n=hb.nextInt();
		int m=hb.nextInt();
		int k=hb.nextInt();

		int x=(int)Math.ceil((double)k/(2*m));
		w.print(x+" ");
		int y=(x-1)*2*m;
		y=k-y;
		w.print((int)Math.ceil((double)y/2)+" ");
		if(k%2==0)
			w.print("R");
		else
			w.print("L");
		w.close();
	}

	public static long count(long l, long r)
	{
		if (l == r)
			return l;

		long b = (long) (Math.log(r) / Math.log(2));
		long num = (long) Math.pow(2, b);

		if (num <= l)
			return count(l - num, r - num) + num;
		else if (2 * num - 1 <= r)
			return 2 * num - 1;
		else
			return num - 1;
	}

	private void shuffle(int[] arr)
	{
		Random ran = new Random();
		for (int i = 0; i < arr.length; i++) {
			int i1 = ran.nextInt(arr.length);
			int i2 = ran.nextInt(arr.length);

			int temp = arr[i1];
			arr[i1] = arr[i2];
			arr[i2] = temp;
		}
	}

	static class DSU
	{
		int parent[];
		int sizeParent[];
		DSU(int n)
		{
			parent=new int[n];
			sizeParent=new int[n];
			Arrays.fill(sizeParent,1);
			for(int i=0;i<n;i++)
				parent[i]=i;
		}

		int find(int x)
		{
			if(x!=parent[x])
				parent[x]=find(parent[x]);
			return parent[x];
		}

		void union(int x,int y)
		{
			x=find(x);
			y=find(y);
			if(sizeParent[x]>=sizeParent[y])
			{
				if(x!=y)
					sizeParent[x]+=sizeParent[y];
				parent[y]=x;
			}
			else
			{
				if(x!=y)
					sizeParent[y]+=sizeParent[x];
				parent[x]=y;
			}
		}
	}

	static class InputReader
	{
		private InputStream stream;
		private byte[] buf = new byte[1024];
		private int curChar;
		private int numChars;
		private SpaceCharFilter filter;

		public InputReader(InputStream stream)
		{
			this.stream = stream;
		}

		public int read()
		{
			if (numChars==-1)
				throw new InputMismatchException();

			if (curChar >= numChars)
			{
				curChar = 0;
				try
				{
					numChars = stream.read(buf);
				}
				catch (IOException e)
				{
					throw new InputMismatchException();
				}

				if(numChars <= 0)
					return -1;
			}
			return buf[curChar++];
		}

		public String nextLine()
		{
			BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
			String str = "";
			try
			{
				str = br.readLine();
			}
			catch (IOException e)
			{
				e.printStackTrace();
			}
			return str;
		}
		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 long nextLong()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			long res = 0;

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

		public double nextDouble()
		{
			int c = read();
			while (isSpaceChar(c))
				c = read();
			int sgn = 1;
			if (c == '-')
			{
				sgn = -1;
				c = read();
			}
			double res = 0;
			while (!isSpaceChar(c) && c != '.')
			{
				if (c == 'e' || c == 'E')
					return res * Math.pow(10, nextInt());
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res *= 10;
				res += c - '0';
				c = read();
			}
			if (c == '.')
			{
				c = read();
				double m = 1;
				while (!isSpaceChar(c))
				{
					if (c == 'e' || c == 'E')
						return res * Math.pow(10, nextInt());
					if (c < '0' || c > '9')
						throw new InputMismatchException();
					m /= 10;
					res += (c - '0') * m;
					c = read();
				}
			}
			return res * sgn;
		}

		public String readString()
		{
			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 boolean isSpaceChar(int c)
		{
			if (filter != null)
				return filter.isSpaceChar(c);
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		public String next()
		{
			return readString();
		}

		public interface SpaceCharFilter
		{
			public boolean isSpaceChar(int ch);
		}
	}

	static class Pair implements Comparable<Pair>
	{
		int a;
		int b;
		String str;
		public Pair(int a,int b)
		{
			this.a=a;
			this.b=b;
			str=min(a,b)+" "+max(a,b);
		}

		public int compareTo(Pair pair)
		{
			if(Integer.compare(a,pair.a)==0)
				return Integer.compare(b,pair.b);

			return Integer.compare(a,pair.a);
		}
	}

}


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

public class B {
    public static void main(String[] args) throws Exception {
        new B().solve();
    }

    boolean[] xd=new boolean[10];//0~9
    void solve() throws IOException {
        // BufferedReader in = new BufferedReader(new
        // InputStreamReader(System.in));
        Scanner sc = new Scanner(System.in);
        int x=sc.nextInt();

        for(int xx=x; xx>0; xx/=10){
            xd[xx%10]=true;
        }

        int count=0;
        for(int k=1; k*k<=x; k++){
            if(x%k==0){
                //k, x/k
                if(check(k)){
                    count++;
                }
                if(k*k<x && check(x/k)){
                    count++;
                }
            }
        }
        System.out.println(count);

    }

    boolean check(int k){
        for(int kk=k; kk>0; kk/=10){
            if(xd[kk%10]){
                return true;
            }
        }
        return false;
    }
}


import static java.lang.Math.*;
import static java.util.Arrays.*;

public class D {

	private final static boolean autoflush = false;

	public D () {
		N = sc.nextInt();
		L = sc.nextInt();
		R = sc.nextInt();
		F = sc.nextDoubles(N);

		M = (1 << N);
		S = new double [M];
		fill(S, L);

		for (int m : rep(M))
			solve(m);

		double res = S[M-1] - L;
		exit(res);
	}

	void solve(int b) {
		double a = S[b];
		for (int i : rep(N)) {
			int m = (b | (1 << i));
			if (m != b) {
				double x = F[i][0], y = F[i][1];
				double alpha = PI/180 * F[i][2], beta = atan2(y, x-a), gamma = atan2(y, x-R);
				if (beta < 0) beta += PI;
				if (gamma < 0) gamma += PI;
				if (alpha + beta > gamma)
					S[m] = R;
				else
					S[m] = max(S[m], x - y / tan(alpha + beta));
			}
		}
	}

	int N, M;
	double L, R;
	Double [][] F;
	double [] S;

	///////////////////////////////////////////////////////////////////////////
	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 <T extends Comparable<T>> T max(T x, T y) { return x.compareTo(y) > 0 ? x : y; }
	////////////////////////////////////////////////////////////////////////////////////
	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 String nextLine() { line = null; return readLine(); }
		public String [] nextStrings() { return nextLine().split(" "); }
		public Double [] nextDoubles() {
			String [] L = nextStrings();
			Double [] res = new Double [L.length];
			for (int i = 0; i < L.length; ++i)
				res[i] = Double.parseDouble(L[i]);
			return res;
		}
		public Double [][] nextDoubles (int N) {
			Double [][] res = new Double [N][];
			for (int i = 0; i < N; ++i)
				res[i] = nextDoubles();
			return res;
		}
		//////////////////////////////////////////////
		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 D(); exit(); }
}


import java.util.Scanner;

public class Problem_11 {
    static long p = 100000;

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String s = input.nextLine();
        //13542
        long n = Long.valueOf(s.substring(0, 1) + s.substring(2, 3) + s.substring(4, 5) + s.substring(3, 4) + s.substring
                (1,2));

        System.out.printf("%05d", (((((n * n * n) % p) * n) % p) * n) % p);
    }
}


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Solution{

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

    	FastScanner fs = new FastScanner();
    	PrintWriter out = new PrintWriter(System.out);

    	int tt = 1;
    	while(tt-->0) {

    		int n = fs.nextInt(), m = fs.nextInt();
    		Pair[] a = new Pair[n];
    		for(int i=0;i<n;i++) {
    			a[i] = new Pair(fs.nextInt(), fs.nextInt());
    		}

    		Pair[] b = new Pair[m];
    		for(int i=0;i<m;i++) {
    			b[i] = new Pair(fs.nextInt(), fs.nextInt());
    		}

    		int q = 2;

    		HashSet<Integer>[] set = new HashSet[2];
    		for(int i=0;i<2;i++) set[i] = new HashSet<Integer>();

    		while(q-->0) {
        		for(int i=0;i<n;i++) {
        			int pre = -1;
        			for(int j=0;j<m;j++) {
        				int k = a[i].matches(b[j]);
        				if(k==-1) continue;
        				if(pre!=-1 && pre!=k) {
        					out.println(-1);
        					out.flush();
        					return;
        				}
        				pre = k;
        				set[q].add(k);
        			}
        		}

    			int temp = n; n = m; m = temp;
    			Pair[] temp2 = a; a = b; b = temp2;
    		}

    		if(set[0].size()>1 || set[1].size()>1) {
    			out.println(0);
    		}
    		else {
    			out.println(set[0].iterator().next());
    		}

    	}

    	out.close();

    }

    static class Pair{
    	int x, y;

    	Pair(int x, int y){
    		this.x = x;
    		this.y = y;
    	}

    	int matches(Pair p) {
    		if(p.x==this.x || p.x==this.y) {
    			if (p.y!=this.x && p.y!=this.y) return p.x;
    		}
    		if(p.y==this.x || p.y==this.y) {
    			if (p.x!=this.x && p.x!=this.y) return p.y;
    		}
    		return -1;
    	}

    }

    static final Random random=new Random();

    static void ruffleSort(int[] a) {
    	int n=a.length;//shuffle, then sort
    	for (int i=0; i<n; i++) {
    		int oi=random.nextInt(n); int temp=a[oi];
    		a[oi]=a[i]; a[i]=temp;
    	}
    	Arrays.sort(a);
    }

    static class FastScanner{
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	StringTokenizer st = new StringTokenizer("");

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

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

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

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

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

    	public char nextChar() {
    		return next().toCharArray()[0];
    	}
    }

}


import java.io.*;
import java.util.*;
public class S
{
    public static void main(String ag[])
    {
        Scanner sc=new Scanner(System.in);
        int i,j,k;
        int N=sc.nextInt();
        int arr[] ={4,1,3,2,0,5};
        int ans=0;
        for(i=0;i<=5;i++)
        {
            if((N&(1<<i))>=1)
            {
                ans+=(1<<arr[i]);
            }
        }
        System.out.println(ans);
    }

}


import java.util.*;
import java.util.Map.Entry;
import java.lang.*;
import java.math.*;
import java.text.*;
import java.io.*;
		public final class Solve {
		static List<List<Integer>> list = new ArrayList<>();
		static PrintWriter out = new PrintWriter(System.out);
		static void flush() {
	 	out.flush();
	 	}
		static void run(long s, long e) {
		NumberFormat formatter = new DecimalFormat("#0.00000");
		System.out.print("Execution time is " + formatter.format((e - s) / 1000d) + " seconds");
		}

		static class FastReader {
	     static BufferedReader br;
	    StringTokenizer st;

	    public FastReader() {
	    br = new BufferedReader(new
	    InputStreamReader(System.in));
	    }
	    static boolean isPalindrome(String str1, String str2) {
	    String str3 = str1+str2;
	    int i = 0, j = str3.length()-1;
	    while(i < j) {
	    char a = str3.charAt(i), b = str3.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    static boolean isPalindrome(String str) {
	    int i = 0, j = str.length()-1;
	    while(i < j) {
	    char a = str.charAt(i), b = str.charAt(j);
	    if(a != b) return false;
	    i++;j--;
	    }
	    return true;
	    }
	    String next() {
	    while (st == null || !st.hasMoreElements()) {
	    try{st = new StringTokenizer(br.readLine());}
	    catch (IOException  e) {e.printStackTrace();}
	    }
	    return st.nextToken();
	    }
	    int nextInt(){ return Integer.parseInt(next()); }
	    long nextLong() { return Long.parseLong(next());}
	    static int fact(int n) {
	    if(n == 1) return 1;
	    return n * fact(n-1);
	   	}
	    public int[] readIntArray(int n) {
	    int[] arr = new int[n];
		for(int i=0; i<n; ++i)
		arr[i]=nextInt();
		return arr;
		}
	    public long[] readLongArray(int n) {
	    	long[] arr = new long[n];
	    	for(int i=0; i<n; ++i)
	    		arr[i]=nextLong();
	    	return arr;
	    }
	    public int[][] readIntArray(int m, int n){
		int[][] arr = new int[m][n];
		for(int i = 0;i<m;i++)
		for(int j = 0;j<n;j++)
		arr[i][j] = nextInt();
		return arr;
	    }
	    public String[] readStringArray(int n) {
		String[] arr = new String[n];
		for(int i=0; i<n; ++i)
		arr[i]= nextLine();
		return arr;
	    }
	    double nextDouble() {return Double.parseDouble(next());}
	    String nextLine() {
	    String str = "";
	    try{str = br.readLine();}
	    catch (IOException e) {e.printStackTrace();}
	    return str;}
	    }
		static void solve(int[] arr, int n) {

			int[] t = new int[n];
			int j = 0;
			for(int i = 0;i<n;i++) {
				if(arr[i] == 1) {
					t[j++] = i;
				}
			}
			if(j == 0 ) {
				out.println(0);
				return;
			}
			long sum = 1;
			for(int i = 0;i<j-1;i++) {
				sum = sum * (t[i+1] - t[i]);
			}
			out.println(sum);
		}
		public static void main(String args[]) throws IOException {
	    FastReader sc = new FastReader();
	    long s1 = System.currentTimeMillis();
	    int n = sc.nextInt();
	    int[] arr = sc.readIntArray(n);
	    solve(arr, n);
	    flush();
	    long e = System.currentTimeMillis();
//	    run(s1,e);
	    }
	}