# vars
s = input()
h = 0
# end_vars

# main.sys
l = s.split('>')
for _ in range(len(l)):
    l[_] += '>'
l = l[:-1]
for i in range(len(l)):
    if '/' in l[i]:
        h -= 2
    print(h * ' ' + l[i])
    if '/' not in l[i]:
        h += 2
# end_main.sys

&lt
  ;a&
    gt;
      &lt
        ;b&
          gt;
            &lt
              ;c&
                gt;
                  &lt
                  ;/c&
                  gt;
                    &lt
                    ;/b&
                    gt;
                      &lt
                      ;/a&
                      gt;

#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  long long h = -1;
  getline(cin, s);
  for (long long i = 0; i < s.size(); i++) {
    if (s[i] == '/') {
      for (long long j = 0; j < 2 * h; j++) {
        cout << ' ';
      }
      cout << "</" << s[i + 1] << ">";
      i += 2;
      h--;
      cout << "\n";
    } else if (s[i] - 'a' >= 0) {
      h++;
      for (long long j = 0; j < 2 * h; j++) {
        cout << ' ';
      }
      cout << "<" << s[i] << ">";
      i += 2;
      cout << "\n";
    }
  }
  return 0;
}


q = int(input())

def f(n):
 take = 0
 ret = 0
 while True:
   if n - take <= 0:
     break
   ret += (n - take) * (n - take + 1) // 2
   take = take * 10 + 9
 return ret

def g(n):
  take = 0
  ret = 0
  while True:
    if n - take <= 0:
      break
    ret += n - take
    take = take * 10 + 9
  return ret

for _ in range(q):
  k = int(input())
  low, high = 1, k
  ans = -1
  while low < high:
    mid = (low + high + 1) >> 1
    if f(mid) == k:
      ans = mid % 10
      break
    if f(mid) < k:
      low = mid
    else:
      high = mid - 1
  if f(low) == k:
    ans = low % 10
  if ans != -1:
    print(ans)
    continue
  k -= f(low)
  next = low + 1
  low, high = 1, next
  while low < high:
    mid = (low + high + 1) // 2
    if g(mid) == k:
      ans = mid % 10
      break
    if g(mid) < k:
      low = mid
    else:
      high = mid - 1
  if g(low) == k:
    ans = low % 10
  if ans != -1:
    print(ans)
    continue
  h = g(low)
  assert(h < k)
  m = str(low + 1)
  print(m[k - h - 1])

#include <bits/stdc++.h>
using namespace std;
long long k;
long long check(long long x, int tag) {
  long long res = 0;
  for (int i = 1; i <= x; i = i * 10) {
    if (tag)
      res += (x - i + 1) * (x - i + 2) / 2;
    else
      res += (x - i + 1);
  }
  return res;
}
long long bs(long long l, long long r, int tag) {
  while (l < r) {
    long long mid = (l + r + 1) >> 1;
    if (check(mid, tag) >= k)
      r = mid - 1;
    else
      l = mid;
  }
  return l;
}
int main() {
  int q;
  cin >> q;
  for (int i = 1; i <= q; i++) {
    cin >> k;
    long long x = bs(0, 2e9, 1);
    k -= check(x, 1);
    long long y = bs(0, x + 1, 0);
    k -= check(y, 0);
    cout << to_string(y + 1)[k - 1] << endl;
  }
}


def gcd(a, b):
  if a == 0:
    return b

  return gcd(b % a, a)

a, b,n = map(int,input().split(" "))

while True:
  n -= gcd(a, n)
  if n < 0:
    print("1")
    break

  n -= gcd(b,n)
  if n < 0:
    print("0")
    break

#include <bits/stdc++.h>
using namespace std;
int gcd(int first_number, int second_number) {
  int gcd;
  for (int i = 1; i <= first_number && i <= second_number; i++) {
    if (first_number % i == 0 && second_number % i == 0) {
      gcd = i;
    }
  }
  return gcd;
}
int main() {
  int a, b, n, i = 0;
  cin >> a >> b >> n;
  while (n != 0) {
    if (i % 2 == 0) {
      int r = gcd(a, n);
      n = n - r;
      i++;
    } else {
      int r = gcd(b, n);
      n = n - r;
      i++;
    }
  }
  if (i % 2 == 1) {
    cout << "0";
  } else {
    cout << "1";
  }
  return 0;
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class DMinimumTriangulation {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();

//        long[][] dp = new long[n + 1][n + 1];
//
//        for (int l = 3; l <= n; l++) {
//            for (int i = 1; i <= n - l + 1; i++) {
//                int j = i + l - 1;
//
//                if (l == 3) {
//                    long val = 1;
//                    for (int k = i; k <= j; k++) {
//                        val *= k;
//                    }
//                    dp[i][j] = val;
//                } else {
//
//                }
//            }
//        }

            long ans = 0;
            for (int i = 2; i <= n - 1; i++) {
                ans += (long) i * (i + 1);
            }

            out.println(ans);
        }

    }

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

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

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        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 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 boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

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

        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

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

        public void println(long i) {
            writer.println(i);
        }

    }
}


import java.util.Scanner;

public class Solve {

    public static void main(String[] args) {
        Scanner scan=new Scanner(System.in);
        long a=scan.nextLong();
        long b=scan.nextLong();

        if(a==b){
            System.out.println(a+" "+b);
            System.exit(0);
        }

        while(true){
            if(a==0 || b==0) break;

            if(a>=2*b){
                long x=b*2;
                long tmp=a/x;
                a-=tmp*x;
            }

            else if(b>=2*a){
                long x=a*2;
                long tmp=b/x;
                b-=tmp*x;
            }

            else break;
        }

        System.out.println(a+" "+b);

        System.exit(0);
    }
}

a, b = map(int, input().split())
while a != 0 and b != 0:
    if a >= 2 * b:
        a = a % (2 * b)
    elif b >= 2 * a:
        b = b % (2 * a)
    else:
        print(a, b)
        exit(0)
print(a, b)


n = int(input())
a = int(input())
b = int(input())
for i in range(n//a+1):
  if (n - i * a) % b == 0:
    print("YES")
    print(i, (n - i * a) // b)
    break
else: print("NO")

import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

/**
 */
public class MainB {
	public static void main(String[] args) {
		run(System.in, System.out);
	}

	public static void run(InputStream in, PrintStream out) {

		try (Scanner sc = new Scanner(in)) {
			int n = sc.nextInt();
			int a = sc.nextInt();
			int b = sc.nextInt();

			int r = n;
			while (r >= 0) {
				if (r % b == 0) {
					out.println("YES");
					out.print((n - r) / a + " " + r / b);
					return;
				}
				r -= a;
			}

			out.print("NO");
		}
	}

}


import java.util.Scanner;

public class ProblemD {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextInt();
		sc.nextLine();
		String input = sc.nextLine();
		int last = input.length();
		long res = 0;
		long power = 1;
		int max_length = String.valueOf(n).length();
		while (last > 0) {
			// System.out.println("Last=" + last);
			int first = last - 1;
			while (first > 0 && last-first <= max_length) {
				String temp = input.substring(first - 1, last);
				long value = Long.parseLong(temp);
				if (value < n) {
					first--;
				} else {

					break;
				}
			}
			while (first < last - 1 && input.charAt(first) == '0')
				first++;
			// System.out.println("Cal + " + cal);
			res += Long.parseLong(input.substring(first, last)) * power;
			// System.out.println(res);
			power *= n;
			last = first;
		}
		System.out.println(res);

	}

}

#include <bits/stdc++.h>
using namespace std;
int n;
string x;
int main() {
  cin >> n >> x;
  long long pn = 1;
  long long ans = 0;
  for (int i = x.size() - 1; i >= 0;) {
    long long val, up;
    val = x[i] - '0';
    up = 10;
    int j = i - 1;
    int lst = i;
    while (j >= 0 && (x[j] - '0') * up + val < n) {
      if (x[j] != '0') lst = j;
      val = (x[j--] - '0') * up + val, up *= 10;
      if (up > n) break;
    }
    ans += pn * val;
    pn *= n;
    i = lst - 1;
  }
  cout << ans << '\n';
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  long long l1, r1, l2, r2, k;
  cin >> l1 >> r1 >> l2 >> r2 >> k;
  long long start = max(l1, l2);
  long long end = min(r1, r2);
  long long ans = end - start + 1;
  if (ans < 0)
    cout << 0;
  else {
    if (k >= start && k <= end) ans -= 1;
    cout << ans;
  }
  return 0;
}

l1,r1,l2,r2,k=map(int,input().split())
ma=max(l1,l2)
mi=min(r1,r2)
if k<=mi and k>=ma:
	print(max(0,mi-ma))
else:
	print(max(0,mi-ma+1))


#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  string names[x * 2];
  for (int i = 0; i < x * 2; i++) cin >> names[i];
  for (int i = 0; i < x * 2; i++)
    if (names[i] == "rat") {
      cout << names[i - 1];
      cout << endl;
    }
  for (int i = 0; i < x * 2; i++)
    if (names[i] == "woman" || names[i] == "child") {
      cout << names[i - 1];
      cout << endl;
    }
  for (int i = 0; i < x * 2; i++)
    if (names[i] == "man") {
      cout << names[i - 1];
      cout << endl;
    }
  for (int i = 0; i < x * 2; i++)
    if (names[i] == "captain") {
      cout << names[i - 1];
      cout << endl;
    }
  return 0;
}

6
Jack captain
Alice woman
Charlie man
Teddy rat
Bob child
Julia woman

5
Joyxnkypf captain
Dxssgr woman
Keojmnpd rat
Gdv man
Hnw man

4 Harry captain Sam man Alice woman Tom rat

22
Wswwcvvm woman
Btmfats rat
I rat
Ocmtsnwx man
Urcqv rat
Yghnogt woman
Wtyfc man
Wqle child
Ujfrelpu rat
Dstixj man
Ahksnio woman
Khkvaap woman
Sjppvwm rat
Egdmsv rat
Dank rat
Nquicjnw rat
Lh captain
Tdyaqaqln rat
Qtj rat
Tfgwijvq rat
Nbiso child
Nqthvbf woman

Btmfats
I
Urcqv
Ujfrelpu
Sjppvwm
Egdmsv
Dank
Nquicjnw
Tdyaqaqln
Qtj
Tfgwijvq
Wswwcvvm
Yghnogt
Wqle
Ahksnio
Khkvaap
Nbiso
Nqthvbf
Ocmtsnwx
Wtyfc
Dstixj
Lh

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

public class Main {

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        Person[] arr = new Person[n];
        String  type = "";
         for (int i = 0; i < n; i++) {
             arr[i] = new Person();
            arr[i].name = input.next();
            type = input.next();
            if (type.equals("rat")) {
                arr[i].type = "a";
            } else if (type.equals("woman") || type.equals("child")) {
                  arr[i].type = "b";
            } else if (type.equals("man")) {
                 arr[i].type = "c";
            } else if (type.equals("captain")) {
                 arr[i].type = "d";
            }
        }

         Arrays.sort(arr);

         for (int i = 0; i < arr.length; i++) {
             System.out.println(arr[i].name);
        }
    }

}

class Person implements Comparable<Person>{

   public  String name;
    public String type;

    @Override
    public int compareTo(Person t) {
        return type.compareTo( t.type);
    }
}


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

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

public class cf598d {

    public static void main(String[] args) throws IOException {
        int n = rni(), m = ni(), k = ni(), ans[][] = new int[n][m];
        boolean map[][] = new boolean[n][m], visited[][] = new boolean[n][m];
        for (int i = 0; i < n; ++i) {
            char[] row = rcha();
            for (int j = 0; j < m; ++j) {
                map[i][j] = row[j] == '*';
            }
        }
        for (int i = 1; i < n - 1; ++i) {
            for (int j = 1; j < m - 1; ++j) {
                if (!map[i][j] && !visited[i][j]) {
                    fill(i, j, solve(i, j, map, visited), map, ans);
                }
            }
        }
        while (k --> 0) {
            int x = rni() - 1, y = ni() - 1;
            prln(ans[x][y]);
        }
        close();
    }

    static int dx[] = {0, 1, 0, -1}, dy[] = {-1, 0, 1, 0};

    static int solve(int i, int j, boolean[][] map, boolean[][] visited) {
        int ans = 0;
        Queue<int[]> bfs = new LinkedList<>();
        bfs.offer(new int[] {i ,j});
        visited[i][j] = true;
        while (!bfs.isEmpty()) {
            int pos[] = bfs.poll(), x = pos[0], y = pos[1];
            for (int k = 0; k < 4; ++k) {
                int nx = x + dx[k], ny = y + dy[k];
                if (map[nx][ny]) {
                    ++ans;
                } else if (!visited[nx][ny]) {
                    visited[nx][ny] = true;
                    bfs.offer(new int[] {nx, ny});
                }
            }
        }
        return ans;
    }

    static void fill(int i, int j, int val, boolean[][] map, int[][] ans) {
        Queue<int[]> bfs = new LinkedList<>();
        bfs.offer(new int[] {i, j});
        ans[i][j] = val;
        while (!bfs.isEmpty()) {
            int pos[] = bfs.poll(), x = pos[0], y = pos[1];
            for (int k = 0; k < 4; ++k) {
                int nx = x + dx[k], ny = y + dy[k];
                if (!map[nx][ny] && ans[nx][ny] == 0) {
                    ans[nx][ny] = val;
                    bfs.offer(new int[] {nx, ny});
                }
            }
        }
    }

    /* static boolean oob(int i, int j, int n, int m) {
        return i < 0 || i >= n || j < 0 || j >= m;
    } */

    // stack overflow
    /* static int solve(int i, int j, boolean[][] map, boolean[][] visited, int n, int m) {
        int ans = 0;
        visited[i][j] = true;
        for (int k = 0; k < 4; ++k) {
            int ni = i + dx[k], nj = j + dy[k];
            if (!oob(ni, nj, n, m)) {
                if (map[ni][nj]) {
                    ++ans;
                } else if (!visited[ni][nj]) {
                    ans += solve(ni, nj, map, visited, n, m);
                }
            }
        }
        return ans;
    } */

    /* static void fill(int i, int j, int x, boolean[][] map, int[][] ans, int n, int m) {
        ans[i][j] = x;
        for (int k = 0; k < 4; ++k) {
            int ni = i + dx[k], nj = j + dy[k];
            if (!oob(ni, nj, n, m) && !map[ni][nj] && ans[ni][nj] == 0) {
                fill(ni, nj, x, map, ans, n, m);
            }
        }
    } */

    static BufferedReader __in = new BufferedReader(new InputStreamReader(System.in));
    static PrintWriter __out = new PrintWriter(new OutputStreamWriter(System.out));
    static StringTokenizer input;
    static Random __rand = new Random();

    // references
    // IBIG = 1e9 + 7
    // IMAX ~= 2e9
    // LMAX ~= 9e18

    // constants
    static final int IBIG = 1000000007;
    static final int IMAX = 2147483647;
    static final int IMIN = -2147483648;
    static final long LMAX = 9223372036854775807L;
    static final long LMIN = -9223372036854775808L;
    // math util
    static int minof(int a, int b, int c) {return min(a, min(b, c));}
    static int minof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); int min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static long minof(long a, long b, long c) {return min(a, min(b, c));}
    static long minof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return min(x[0], x[1]); if (x.length == 3) return min(x[0], min(x[1], x[2])); long min = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] < min) min = x[i]; return min;}
    static int maxof(int a, int b, int c) {return max(a, max(b, c));}
    static int maxof(int... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); int max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static long maxof(long a, long b, long c) {return max(a, max(b, c));}
    static long maxof(long... x) {if (x.length == 1) return x[0]; if (x.length == 2) return max(x[0], x[1]); if (x.length == 3) return max(x[0], max(x[1], x[2])); long max = x[0]; for (int i = 1; i < x.length; ++i) if (x[i] > max) max = x[i]; return max;}
    static int powi(int a, int b) {if (a == 0) return 0; int ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static long powl(long a, int b) {if (a == 0) return 0; long ans = 1; while (b > 0) {if ((b & 1) > 0) ans *= a; a *= a; b >>= 1;} return ans;}
    static int fli(double d) {return (int) d;}
    static int cei(double d) {return (int) ceil(d);}
    static long fll(double d) {return (long) d;}
    static long cel(double d) {return (long) ceil(d);}
    static int gcf(int a, int b) {return b == 0 ? a : gcf(b, a % b);}
    static long gcf(long a, long b) {return b == 0 ? a : gcf(b, a % b);}
    static int lcm(int a, int b) {return a * b / gcf(a, b);}
    static long lcm(long a, long b) {return a * b / gcf(a, b);}
    static int randInt(int min, int max) {return __rand.nextInt(max - min + 1) + min;}
    static long mix(long x) {x += 0x9e3779b97f4a7c15L; x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9L; x = (x ^ (x >> 27)) * 0x94d049bb133111ebL; return x ^ (x >> 31);}
    // array util
    static void reverse(int[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {int swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(long[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {long swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(double[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {double swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void reverse(char[] a) {for (int i = 0, n = a.length, half = n / 2; i < half; ++i) {char swap = a[i]; a[i] = a[n - i - 1]; a[n - i - 1] = swap;}}
    static void shuffle(int[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); int swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(long[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); long swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void shuffle(double[] a) {int n = a.length - 1; for (int i = 0; i < n; ++i) {int ind = randInt(i, n); double swap = a[i]; a[i] = a[ind]; a[ind] = swap;}}
    static void rsort(int[] a) {shuffle(a); sort(a);}
    static void rsort(long[] a) {shuffle(a); sort(a);}
    static void rsort(double[] a) {shuffle(a); sort(a);}
    static int[] copy(int[] a) {int[] ans = new int[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static long[] copy(long[] a) {long[] ans = new long[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static double[] copy(double[] a) {double[] ans = new double[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    static char[] copy(char[] a) {char[] ans = new char[a.length]; for (int i = 0; i < a.length; ++i) ans[i] = a[i]; return ans;}
    // input
    static void r() throws IOException {input = new StringTokenizer(rline());}
    static int ri() throws IOException {return Integer.parseInt(rline());}
    static long rl() throws IOException {return Long.parseLong(rline());}
    static double rd() throws IOException {return Double.parseDouble(rline());}
    static int[] ria(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni(); return a;}
    static int[] riam1(int n) throws IOException {int[] a = new int[n]; r(); for (int i = 0; i < n; ++i) a[i] = ni() - 1; return a;}
    static long[] rla(int n) throws IOException {long[] a = new long[n]; r(); for (int i = 0; i < n; ++i) a[i] = nl(); return a;}
    static double[] rda(int n) throws IOException {double[] a = new double[n]; r(); for (int i = 0; i < n; ++i) a[i] = nd(); return a;}
    static char[] rcha() throws IOException {return rline().toCharArray();}
    static String rline() throws IOException {return __in.readLine();}
    static String n() {return input.nextToken();}
    static int rni() throws IOException {r(); return ni();}
    static int ni() {return Integer.parseInt(n());}
    static long rnl() throws IOException {r(); return nl();}
    static long nl() {return Long.parseLong(n());}
    static double rnd() throws IOException {r(); return nd();}
    static double nd() {return Double.parseDouble(n());}
    // output
    static void pr(int i) {__out.print(i);}
    static void prln(int i) {__out.println(i);}
    static void pr(long l) {__out.print(l);}
    static void prln(long l) {__out.println(l);}
    static void pr(double d) {__out.print(d);}
    static void prln(double d) {__out.println(d);}
    static void pr(char c) {__out.print(c);}
    static void prln(char c) {__out.println(c);}
    static void pr(char[] s) {__out.print(new String(s));}
    static void prln(char[] s) {__out.println(new String(s));}
    static void pr(String s) {__out.print(s);}
    static void prln(String s) {__out.println(s);}
    static void pr(Object o) {__out.print(o);}
    static void prln(Object o) {__out.println(o);}
    static void prln() {__out.println();}
    static void pryes() {prln("yes");}
    static void pry() {prln("Yes");}
    static void prY() {prln("YES");}
    static void prno() {prln("no");}
    static void prn() {prln("No");}
    static void prN() {prln("NO");}
    static boolean pryesno(boolean b) {prln(b ? "yes" : "no"); return b;};
    static boolean pryn(boolean b) {prln(b ? "Yes" : "No"); return b;}
    static boolean prYN(boolean b) {prln(b ? "YES" : "NO"); return b;}
    static void prln(int... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(long... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static void prln(double... a) {for (int i = 0, len = a.length - 1; i < len; pr(a[i]), pr(' '), ++i); if (a.length > 0) prln(a[a.length - 1]); else prln();}
    static <T> void prln(Collection<T> c) {int n = c.size() - 1; Iterator<T> iter = c.iterator(); for (int i = 0; i < n; pr(iter.next()), pr(' '), ++i); if (n >= 0) prln(iter.next()); else prln();}
    static void h() {prln("hlfd"); flush();}
    static void flush() {__out.flush();}
    static void close() {__out.close();}
}

import sys
from queue import deque

# sys.stdin = open('ivo.in')

move = [(0, 1), (1, 0), (0, -1), (-1, 0)]
n, m, k = map(int, sys.stdin.readline().split())

a = []
for i in range(n):
    a.append(sys.stdin.readline().rstrip())

visited = []
values = []
for x in range(n):
    visited.append([])
    values.append([])
    for y in range(m):
        visited[x].append(False)
        values[x].append(0)

for x in range(n):
    for y in range(m):
        if a[x][y] == '*' or visited[x][y]:
            continue
        q = deque()
        visited[x][y] = True
        q.append((x, y))
        sum = 0
        connected = [(x, y)]
        while len(q) != 0:
            cur = q.pop()
            for l in move:
                tx = cur[0] + l[0]
                ty = cur[1] + l[1]
                if tx < 0 or tx >= n or ty < 0 or ty >= m:
                    continue
                if a[tx][ty] == '.' and visited[tx][ty]:
                    continue
                if a[tx][ty] == '*':
                    sum += 1
                    continue
                q.append((tx, ty))
                visited[tx][ty] = True
                connected.append((tx, ty))
        for c in connected:
            values[c[0]][c[1]] = sum

for i in range(k):
    x, y = map(int, sys.stdin.readline().split())
    print(values[x - 1][y - 1])


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

public class Main {
	  public static void main(String[] args) {
	        InputStream inputStream = System.in;
	        OutputStream outputStream = System.out;
	        InputReader in = new InputReader(inputStream);
	            try (PrintWriter out = new PrintWriter(outputStream)) {
	            	TaskG solver = new TaskG();
	                solver.solve(in, out);
	            }
	    }
}
class InputReader {
    public BufferedReader reader;
    public StringTokenizer tokenizer;

    public InputReader(InputStream inputstream) {
      reader = new BufferedReader(new InputStreamReader(inputstream));
      tokenizer = null;
    }

    public String nextLine(){
    	String fullLine=null;
    	while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
              fullLine=reader.readLine();
            } catch (IOException e) {
              throw new RuntimeException(e);
            }
            return fullLine;
          }
          return fullLine;
    }
	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 long nextLong() {
	      return Long.parseLong(next());
	    }
    public int nextInt() {
      return Integer.parseInt(next());
    }
  }
class TaskG {
	void solve(InputReader in,PrintWriter out){
		int n=in.nextInt();
		int arr[]=new int[n];
		for(int i=0;i<n;i++){
			arr[i]=in.nextInt();
			arr[i]+=i;
		}
		Arrays.sort(arr);
		for(int i=0;i<n;i++){
			arr[i]-=i;
		}
		for(int i=0;i<n-1;i++){
			if(arr[i+1]<arr[i]){
				out.println(":(");
				return;
			}
		}
		for(int x:arr){
			out.print(x+" ");
		}
	}
}

#include <bits/stdc++.h>
using namespace std;
using namespace std;
vector<pair<int, int> > a;
int main() {
  ios_base::sync_with_stdio(0);
  int n;
  cin >> n;
  for (int i = 0; i < (n); ++i) {
    pair<int, int> b;
    cin >> b.first;
    b.first += i;
    b.second = i;
    a.push_back(b);
  }
  sort(a.begin(), a.end());
  for (int i = 0; i < (n); ++i) {
    a[i].first -= i;
  }
  for (int i = 0; i < (n - 1); ++i) {
    if (a[i].first > a[i + 1].first) {
      cout << ":(";
      return 0;
    }
  }
  for (int i = 0; i < (n); ++i) {
    cout << a[i].first << " ";
  }
}


I=input
R=range
w,h=map(int,I().split())
t=[I()for _ in R(h)]
for r in[[t[i][j]*2for i in R(h)]for j in R(w)]:s=''.join(r);print(s+'\n'+s)

#include <bits/stdc++.h>
using namespace std;
const int N = 210;
char s[N][N];
char str[3][N][N];
int main() {
  int n, m;
  scanf("%d%d", &m, &n);
  for (int i = 1; i <= n; i++) scanf("%s", s[i] + 1);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) str[0][j][n - i + 1] = s[i][j];
  swap(n, m);
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= m; j++) str[1][i][m - j + 1] = str[0][i][j];
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) printf("%c%c", str[1][i][j], str[1][i][j]);
    printf("\n");
    for (int j = 1; j <= m; j++) printf("%c%c", str[1][i][j], str[1][i][j]);
    printf("\n");
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 5005;
int n, T;
int p[maxn], t[maxn];
double dp[maxn][maxn];
double pp, p1, tmp, ans;
int main() {
  while (scanf("%d%d", &n, &T) != EOF) {
    for (int i = 1; i <= n; i++) scanf("%d%d", &p[i], &t[i]);
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;
    ans = 0;
    for (int i = 1; i <= n; i++) {
      pp = 0.01 * p[i];
      p1 = 1;
      for (int j = 1; j < t[i]; j++) p1 *= 1 - pp;
      for (int j = 1; j <= T; j++) {
        if (j < t[i])
          dp[i][j] = dp[i][j - 1] * (1 - pp) + dp[i - 1][j - 1] * pp;
        else {
          if (j > t[i])
            tmp = dp[i][j - 1] - p1 * dp[i - 1][j - 1 - t[i]];
          else
            tmp = dp[i][j - 1];
          dp[i][j] = tmp * (1 - pp) + dp[i - 1][j - 1] * pp +
                     dp[i - 1][j - t[i]] * p1 * (1 - pp);
        }
        ans += dp[i][j];
      }
    }
    printf("%.7lf\n", ans);
  }
  return 0;
}

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

public class D {
    class FastReader {
        BufferedReader br;
        StringTokenizer tokenizer;

        FastReader(InputStream inputStream) throws IOException {
            br = new BufferedReader(new InputStreamReader(inputStream));
            tokenizer = new StringTokenizer(br.readLine());
        }

        FastReader(File file) throws IOException {
            this(new FileInputStream(file));
        }

        String next() throws IOException {
            while (!tokenizer.hasMoreTokens()) {
                String line = br.readLine();
                if (line == null) {
                    return null;
                }
                tokenizer = new StringTokenizer(line);
            }
            return tokenizer.nextToken();
        }

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

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

    double sumProb(double p, int n) {
        double s = 0;
        for (int i = 0; i < n; i++) {
            s += Math.pow(1 - p, i) * p;
        }
        return s;
    }

    void solve() throws IOException {
        FastReader reader = new FastReader(System.in);
        PrintWriter writer = new PrintWriter(System.out);
        int n = reader.nextInt();
        int t = reader.nextInt();
        double[] prev = new double[t + 1];
        double[] cur = new double[t + 1];
        Arrays.fill(prev, 0.);
        prev[0] = 1;
        double e = 0;
        for (int i = 1; i <= n; i++) {
            double p = reader.nextInt() / 100.;
            int q = reader.nextInt();
            double factor = Math.pow(1 - p, q - 1);
            Arrays.fill(cur, 0.);
            double b = 0;
            for (int j = i; j <= t; j++) {
                b *= 1 - p;
                if (q <= j) {
                    cur[j] += prev[j - q] * factor;
                    b -= cur[j] * p;
                }
                b += prev[j - 1] * p;
                cur[j] += b;
                e += cur[j];
            }
            double[] temp = cur;
            cur = prev;
            prev = temp;
        }
        writer.println(e);
        writer.close();
    }
}


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

public class workship4{

    static class Node{
        int id, parentId, par, impar, altura;
        List<Integer> children = new ArrayList<>();
        Node(int id, int parent){
            this.id = id;
            this.parentId = parent;
        }
    }

    public static boolean checkNode(Node[] a, int c, Integer[] g, int n){
        //metodo que verifica el valor actual del nodo con respecto a la salida
        if(a[c].id != g[c])
            //si el valor del nodo es diferente al de goal, entra
            return true;
        return false;
    }

     public static void flip(Node[] a, int c){
        if(a[c].id == 0) //si el nodo es 0, se convierte en 1
            a[c].id = 1;
        else
            a[c].id = 0;//en caso contrario, se convierte en 0
    }

    public static boolean finish(Node[] a, Integer[] g, int n){
        //metodo para comprobar si los valores de el arbol conciden con los finales
        for(int i = 0; i<n; i++) //recorre el arreglo
            if ( a[i].id != g[i] ) //compara elemento a elemento el arreglo con los valores finales
                return false; //si al menos un elemento es diferente al valor esperado, retorna falso
        return true; // si termina el ciclo, indica que todos los nodos son iguales, y devuelve verdadero
    }

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

        Scanner sc = new Scanner( System.in );
        int n = sc.nextInt();
        // se inicializa arreglo de n nodos, o el aarbol en si
        Node[] nodes = new Node[n];
        // el nodo 1 siempre es la raiz del arbol
        nodes[0] = new Node(1,-1);
        //nodo raiz es la altura 0 del arbol
        nodes[0].altura = 0;

        int numeroMovimientos = 0; //contador para num de flips utilizados

        for (int i = 0; i < n-1; i++) {
            //lectura de datos iniciales como datos finales
            int a = sc.nextInt();
            int b = sc.nextInt();
            if(nodes[a-1] != null) {
                //asignacion de a como padre de b
                nodes[b-1] = new Node(b-1, a-1);
                //la altura del nuevo nodo es 1 mas que la altura de su padre
                nodes[b-1].altura = nodes[a-1].altura + 1;
                //se añade b en la lista de hijos de a
                nodes[a-1].children.add(b-1);
            } else if(nodes[b-1] != null){
                //asignacion de b como padre de a
                nodes[a-1] = new Node(a-1, b-1);
                //la altura del nuevo nodo es 1 mas que la altura de su padre
                nodes[a-1].altura = nodes[b-1].altura + 1;
                //se añade a en la lista de hijos de b
                nodes[b-1].children.add(a-1);
            } else {
                throw new RuntimeException();
            }
        }

        for(int i = 0; i < n; i++){
            //asignar estado inicial para cada nodo
            nodes[i].id = sc.nextInt();
        }

        Integer[] finishValues = new Integer[n];
        for(int i=0; i<n; i++){
            //asignar estado final para cada nodo
            finishValues[i] = sc.nextInt();
        }

        //lista para almacenar nodos que hayan cambiado
        List<Integer> flippedNodes = new ArrayList<Integer>();
        //cola para almacenar nodos temporalmente
        Queue queue = new LinkedList();
        //se agregan la lista de hijos del nodo raiz
        queue.add(nodes[0].children);

        if( checkNode(nodes,0, finishValues, n) ){ //si el valor de la raiz es diferente al valor deseado, cambia su valor
                flip(nodes,0);
                nodes[0].par = 1;
                nodes[0].impar = 0;
                //incrementa contador del num de movimientos
                numeroMovimientos++;
                //añade el nodo intercambiado a la cola de respuesta
                flippedNodes.add(1);
        }
        else{
                nodes[0].par = 0;
                nodes[0].impar = 0;
        }

        // si la cola NO esta vacia
        while ( !queue.isEmpty() ){
            //lista de enteros para recorrer los hijos de cada nodo
            List<Integer> child = (List)queue.remove();
                for(int i=0; i < child.size(); i++){ //recorre la lista de hijos obtenida de la cola.
                    //si el nodo i tiene hijos, entra
                    if(nodes[child.get(i)].children.size() > 0)
                        //añade la lista de hijos del nodo i a la cola
                        queue.add(nodes[child.get(i)].children);

                    //hereda variable control de cambios en los niveles pares
                    nodes[child.get(i)].par = nodes[nodes[child.get(i)].parentId].par;
                    //hereda variable control de cambios en los niveles impares
                    nodes[child.get(i)].impar = nodes[nodes[child.get(i)].parentId].impar;

                    //nodo de altura par && NO hay un numero par de cambios, el nodo SI necesita "flip"
                    if( nodes[child.get(i)].altura% 2 == 0 && nodes[child.get(i)].par%2 == 1)
                        flip(nodes,child.get(i));

                    else if( nodes[child.get(i)].altura% 2 == 1 && nodes[child.get(i)].impar%2 == 1)
                        flip(nodes,child.get(i));

                    if( checkNode(nodes,child.get(i),finishValues,n) ){
                        if(nodes[child.get(i)].altura% 2 == 0){ //Nivel par
                            nodes[child.get(i)].par++;
                            flip(nodes,child.get(i));
                        }
                        else{ //Nivel impar
                            nodes[child.get(i)].impar++;
                            flip(nodes,child.get(i));
                        }
                        numeroMovimientos++;
                        flippedNodes.add(child.get(i)+1);
                    }
                }
        }
        System.out.println(numeroMovimientos);
        StringBuilder sb = new StringBuilder();
        for (Integer ansNode : flippedNodes) {
            sb.append(ansNode).append("\n");
        }
        System.out.println(sb);
    }

}

#include <bits/stdc++.h>
using namespace std;
const int N = 100001;
int n;
vector<int> g[N];
int a[N];
int b[N];
vector<int> ans;
void dfs(int now, int fa, int depth, int k[2]) {
  a[now] ^= k[depth & 1];
  if (a[now] != b[now]) {
    ans.push_back(now);
    k[depth & 1] ^= 1;
  }
  for (int i = 0; i < g[now].size(); ++i)
    if (g[now][i] != fa) {
      int kk[2];
      kk[0] = k[0];
      kk[1] = k[1];
      dfs(g[now][i], now, depth + 1, kk);
    }
}
int main() {
  scanf("%d", &n);
  int u, v;
  for (int i = 0; i < n - 1; ++i) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  for (int i = 1; i <= n; ++i) scanf("%d", &a[i]);
  for (int i = 1; i <= n; ++i) scanf("%d", &b[i]);
  int k[2] = {0, 0};
  dfs(1, 0, 0, k);
  printf("%d\n", ans.size());
  for (int i = 0; i < ans.size(); ++i) printf("%d\n", ans[i]);
  return 0;
}


from sys import stdin,stdout
nmbr = lambda: int(stdin.readline())
lst = lambda: list(map(int,stdin.readline().split()))
for _ in range(1):#nmbr()):
    n=nmbr()
    a=lst()
    bits=[[0 for _ in range(34)] for _ in range(n)]
    for i in range(n):
        for j in range(34):
            bits[i][33-j]=(a[i]>>j)&1
    # print(*bits,sep='\n')
    bit=-1
    x=(1<<32)-1
    for bp in range(34):
        nd=x
        for i in range(n):
            if bits[i][33-bp]:
                nd&=a[i]
        if nd%(1<<bp)==0:
            bit=bp
    if bit==-1:
        print(-1)
    else:
        ans=[]
        for i in range(n):
            if bits[i][33-bit]:
                ans+=[a[i]]
        print(len(ans))
        print(*ans)

import java.io.DataInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.TreeSet;

public class ProblemA1 {

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

        Parserdoubt7777121233 s = new Parserdoubt7777121233(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int n = s.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = s.nextInt();
//          System.out.println(Integer.toBinaryString(a[i]));
        }

        for (int i = 30; i >= 0; i--) {
            TreeSet<Integer> tree = new TreeSet<Integer>();
            int bit = 1 << i;
            int mask = bit - 1;

            for (int j = 0; j < a.length; j++) {
                if((a[j] & bit) > 0){
                    mask &= a[j];
                    tree.add(a[j]);
                }
            }
            if(mask == 0){
                out.println(tree.size());
                for(int v : tree){
                    out.print(v + " ");
                }
                out.close();
                return ;
            }
        }

        out.println("-1");
        out.close();
    }

}

class Parserdoubt7777121233
{
   final private int BUFFER_SIZE = 1 << 17;

   private DataInputStream din;
   private byte[] buffer;
   private int bufferPointer, bytesRead;

   public Parserdoubt7777121233(InputStream in)
   {
      din = new DataInputStream(in);
      buffer = new byte[BUFFER_SIZE];
      bufferPointer = bytesRead = 0;
   }
   public String nextString() throws Exception
   {
       StringBuffer sb=new StringBuffer("");
       byte c = read();
       while (c <= ' ') c = read();
       do
       {
           sb.append((char)c);
           c=read();
       }while(c>' ');
       return sb.toString();
   }
   public char nextChar() throws Exception
   {
       byte c=read();
       while(c<=' ') c= read();
       return (char)c;
   }
   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';
         c = read();
      } while (c > ' ');
      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';
         c = read();
      } while (c > ' ');
      if (neg) return -ret;
      return 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++];
   }
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k, s = 0;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    int x, y;
    cin >> x >> y;
    s = s + y - x + 1;
  }
  if (s % k != 0)
    cout << k - s % k << endl;
  else
    cout << 0 << endl;
  return 0;
}

import java.io.*;
import java.util.Arrays;
import java.util.Random;
import java.util.StringTokenizer;

public class Main {
    FastScanner in;
    PrintWriter out;

    public void solve() throws IOException {

        int result = 0;
        int n = in.nextInt();
        int k = in.nextInt();
        int[] array = new int[n];
        Random rng = new Random();
        int count = 0;
        for (int i=0; i<n; i++){
            count += (in.nextInt() - in.nextInt()) * (-1) + 1;
        }
        result = (k - count%k)%k;
//        for (int i=0; i<n; i++){
//            int j = rng.nextInt(i + 1);
//            long tmp = array[j];
//            array[j] = array[i];
//            array[i] = tmp;
//        }
//        Arrays.sort(array);

        out.print(result);

//        out.flush();
    }

    private boolean check(int turns, int x, int y, int x0, int y0) {
        if (x0==x && y0==y){
            out.println(turns);
            return true;
        }
        return false;
    }

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

            solve();

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

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

        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 Main().run();
    }
}


import java.util.Scanner;

/**
 *
 * @author HP
 */
public class LilystoneCodef {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
         Scanner sc= new Scanner(System.in);
         String s= sc.next();
         String s1= sc.next();
         int c=0;
         //int c1=1;

         for(int i=0;i<s1.length();i++)
         {
             if(s1.charAt(i)==s.charAt(c))
             {
                 c++;
             }

         }

        System.out.println(c+1);

    }

}

stones = list(input())
instructions = list(input())
position = 0
i=0

for j in range(len(instructions)):
    if instructions[j] == stones[i]:
        i+=1

print(i+1)


from collections import *

def add(n):
    for i in range(len(n) - 1, -1, -1):
        if n[i] == '1':
            n[i] = '0'
        else:
            n[i] = '1'
            return n
    n.appendleft('1')
    return n

def main():
    n, ans = deque(input()), 0

    while (len(n) != 1):
        if n[-1] == '1':
            n = add(n)
        else:
            n.pop()
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()

#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  int z = 0, on = 0, fl = 0;
  for (int i = str.size() - 1; i >= 0; i--) {
    if (str[i] == '0' && fl == 1) {
      z++;
    } else if (str[i] == '1') {
      on++;
      fl = 1;
    }
  }
  if (on > 1) {
    cout << str.size() + 1 + z << endl;
  } else if (on == 1) {
    cout << str.size() - 1 << endl;
  }
  return 0;
}


import java.util.Scanner;

public class BookReading {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		String s[]=in.nextLine().split(" ");
		int t=Integer.parseInt(s[0]);
		int n=Integer.parseInt(s[1]);
		int a[]=new int[t];
		String ss[]=in.nextLine().split(" ");
		int count=0,count11=0;
		for(int i=0;i<t;i++) {
			a[i]=86400-Integer.parseInt(ss[i]);
			if(count11<n) {
				count11+=a[i];
				count+=1;
			}
			else {
				break;
			}
		}
		System.out.println(count);
	}

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  int d = 0, t = 0, c = 0;
  cin >> d >> t;
  int arr[d];
  for (int i = 0; i < d; i++) cin >> arr[i];
  for (int i = 0; i < d; i++) {
    if (arr[i] + t <= 86400) {
      c++;
      t -= (86400 - arr[i]);
      break;
    } else {
      t -= (86400 - arr[i]);
      c++;
    }
  }
  cout << c;
}


import java.util.*;
import java.io.*;
public class LazySecurityGuard {

    /************************ SOLUTION STARTS HERE ************************/

    private static void solve() {

        int N = nextInt();
        int block = (int) Math.sqrt(N);

        long peri = (N % block == 0 ? 0 : 2) + 2L * (block + N / block);

        println(peri);

    }

    /************************ SOLUTION ENDS HERE ************************/

    /************************ TEMPLATE STARTS HERE **********************/

    public static void main(String[] args) throws IOException {
        reader = new BufferedReader(new InputStreamReader(System.in));
        writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
        st     = null;
        solve();
        reader.close();
        writer.close();
    }

    static BufferedReader reader;
    static PrintWriter    writer;
    static StringTokenizer st;

    static String next()
    {while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
    st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
    static String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
    static int    nextInt()   {return Integer.parseInt(next());}
    static long   nextLong()  {return Long.parseLong(next());}
    static double nextDouble(){return Double.parseDouble(next());}
    static char   nextChar()  {return next().charAt(0);}
    static int[]  nextIntArray(int n)         {int[] a= new int[n];   int i=0;while(i<n){a[i++]=nextInt();}  return a;}
    static long[] nextLongArray(int n)        {long[]a= new long[n];  int i=0;while(i<n){a[i++]=nextLong();} return a;}
    static int[]  nextIntArrayOneBased(int n) {int[] a= new int[n+1]; int i=1;while(i<=n){a[i++]=nextInt();} return a;}
    static long[] nextLongArrayOneBased(int n){long[]a= new long[n+1];int i=1;while(i<=n){a[i++]=nextLong();}return a;}
    static void   print(Object o)  { writer.print(o);  }
    static void   println(Object o){ writer.println(o);}

    /************************ TEMPLATE ENDS HERE ************************/

}

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  cin >> n;
  long long f, suma, l = sqrt(n);
  suma = 4 * l;
  f = n - l * l;
  suma += (f / l) * 2;
  f -= (f / l) * l;
  if (f > 0) {
    suma += 2;
  }
  cout << suma;
  return 0;
}


import java.io.*;
import java.util.*;
public class CF838_D12_E {
	public static void main(String[] args)throws Throwable {
		MyScanner sc=new MyScanner();
		PrintWriter pw=new PrintWriter(System.out);

		n=sc.nextInt();
		x=new long [n];
		y=new long [n];
		for(int i=0;i<n;i++){
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
		}
		mem=new Double [2][n+1][n+1];
		double max=0;
		for(int i=0;i<n;i++){
			int nxt=nxt(i);
			max=Math.max(max, dis(i, nxt)+Math.max(dp(0, i, nxt), dp(1, i, nxt)));
		}

		pw.println(max);
		pw.flush();
		pw.close();
	}
	static int n;
	static long [] x,y;
	static Double [][][] mem;

	static double dp(int c, int i,int j){
		if(i==nxt(j))
			return 0;
		if(mem[c][i][j]!=null)
			return mem[c][i][j];
		double ans=0;
		int pre=pre(i);
		int nxt=nxt(j);
		if(c==0){
			double op1=dis(i, pre)+dp(0, pre, j);
			double op2=dis(i, nxt)+dp(1, i, nxt);
			ans=Math.max(op1, op2);
		}else{
			double op2=dis(j, nxt)+dp(1, i, nxt);
			double op1=dis(j, pre)+dp(0, pre, j);
			ans=Math.max(op1, op2);
		}
		return mem[c][i][j]=ans;
	}

	static double dis(int i,int j){
		return Math.sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
	}

	static int nxt(int i){
		return (i+1)%n;
	}
	static int pre(int i){
		return (i-1+n)%n;
	}

	static class MyScanner {
		BufferedReader br;
		StringTokenizer st;
		public MyScanner() {
			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;}
	}
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 2005;
double dp[10005][maxn];
int ans[maxn];
const double eps = 1e-7;
int main() {
  int q, k;
  scanf("%d %d", &k, &q);
  dp[0][0] = 1;
  for (int i = 1; i < 10005; i++) {
    for (int j = 1; j <= k; j++) {
      dp[i][j] += dp[i - 1][j] * double(j) / k;
      dp[i][j] += dp[i - 1][j - 1] * (double(k - j + 1) / k);
    }
  }
  for (int j = 1; j <= 1000; j++) {
    for (int i = 10000; i >= 1; i--) {
      if (2000 * dp[i][k] >= j - eps) ans[j] = i;
    }
  }
  while (q--) {
    int p;
    scanf("%d", &p);
    printf("%d\n", ans[p]);
  }
  return 0;
}

//import java.util.Scanner;
//
//
//public class JonandOrbs {
//
//	public static void main(String[] args) {
//		Scanner in = new Scanner(System.in);
//		int n = in.nextInt(), q = in.nextInt();
//		double t1[] = new double[n+1], t2[] = new double[n+1];
//		double probs[] = new double[100000];
//		t1[0] = 1;
//		for(int i = 0; i < 30; i++) {
//			for(int j = 0; j <= n; j++) {
//				t2[j] += t1[j] * ((double)(n - j)/(double)n);
//				if(j != 0) {
//					t1[j-1] += t2[j] * ((double)j/ (double)n);
//				}
//			}
//			double[i+1]
//		}
//
//		for(int i = 0; i < q; i++) {
//			double qq = (in.nextDouble() - (1e-7))/2000.0;
//			int idx = 0;
//			while(memo[idx][0] < qq) {
//				idx++;
//			}
//			System.out.println(idx);
//		}
//	}
//}

 import java.util.Scanner;

public class JonandOrbs {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt(), q = in.nextInt();
		double memo[][] = new double[10000][n+1];
		memo[0][n] = 1;
		for(int i = 0; i < 10000-1; i++) {
			for(int j = 0; j <= n; j++) {
				memo[i+1][j] += memo[i][j] * ((double)(n - j)/(double)n);
				if(j != 0) {
					memo[i+1][j-1] += memo[i][j] * ((double)j/ (double)n);
				}
			}
		}
		for(int i = 0; i < q; i++) {
			double qq = (in.nextDouble() - (1e-7))/2000.0;
			int idx = 0;
			while(memo[idx][0] < qq) {
				idx++;
			}
			System.out.println(idx);
		}
	}
}


#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, k;
  cin >> n >> k;
  set<long long> x, y;
  int m = n;
  long long ans[k];
  for (int i = 0, a, b; i < k; i++) {
    cin >> a >> b;
    if (x.count(a - 1) == 0) n--;
    if (y.count(b - 1) == 0) m--;
    x.insert(a - 1);
    y.insert(b - 1);
    ans[i] = n * m;
  }
  for (int i = 0; i < k; i++) {
    cout << ans[i] << " ";
  }
  return 0;
}

n, m = map(int, input().strip().split())

remains = n*n
deleted_rows = set()
deleted_cols = set()
answer = []
for _ in range(m):
    c, r = map(int, input().strip().split())
    col_deleted = c in deleted_cols
    row_deleted = r in deleted_rows
    if not (col_deleted and row_deleted):
        if col_deleted:
            remains -= (n - len(deleted_cols))
        elif row_deleted:
            remains -= (n - len(deleted_rows))
        else:  # not x_in and not y_in
            remains -= (2*n - len(deleted_cols) - len(deleted_rows) - 1)

    deleted_cols.add(c)
    deleted_rows.add(r)

    answer.append(str(remains))

print(' '.join(answer))


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

public class Main {

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

		Reader reader = new Reader();

		reader.readLine();
		int n = reader.readInt(0);

		int sum[][] = new int[2][370];

		for (int i = 0; i < n; i++) {

			reader.readLine();
			int gender = reader.readString(0).charAt(0) == 'M' ? 0 : 1;
			int st = reader.readInt(1);
			int ed = reader.readInt(2);

			++sum[gender][st];
			--sum[gender][ed+1];

		}
		reader.close();

		int ans = 0;
		for (int i = 1; i < 367; i++) {
			sum[0][i] += sum[0][i - 1];
			sum[1][i] += sum[1][i - 1];
			int res = Math.min(sum[0][i], sum[1][i]) * 2;

			if (res > ans)
				ans = res;

		}
		System.out.println(ans);

	}
}

class Reader {
	private BufferedReader reader;
	private String line[];

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

	public String[] getLine() {
		return line;
	}

	public boolean readLine() throws IOException {
		String str = reader.readLine();
		if (str == null || str.isEmpty())
			return false;
		line = str.split(" ");
		return true;
	}

	public List<Integer> getIntegersList() {
		List<Integer> res = new ArrayList<>();
		for (String str : line)
			res.add(Integer.parseInt(str));
		return res;

	}

	public int readInt(int pos) throws IOException {
		return Integer.parseInt(line[pos]);
	}

	public double readDouble(int pos) throws IOException {
		return Double.parseDouble(line[pos]);
	}

	public long readLong(int pos) throws IOException {
		return Long.parseLong(line[pos]);
	}

	public String readString(int pos) throws IOException {
		return line[pos];
	}

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


#include <bits/stdc++.h>
using namespace std;
const int inft = 1000000009;
const int mod = 1000000007;
const int MAXN = 1000006;
int n;
bool kmp(string P) {
  P = "#" + P;
  int pi[P.size()], m = P.size() - 1, q = 0;
  pi[0] = pi[1] = 0;
  for (int i = 2; i <= m; ++i) {
    while (q && P[i] != P[q + 1]) q = pi[q];
    if (P[i] == P[q + 1]) ++q;
    pi[i] = q;
  }
  return !pi[m];
}
map<char, char> M;
string rev(string A) {
  reverse((A).begin(), (A).end());
  for (int i = 0; i < (A.size()); ++i) A[i] = M[A[i]];
  return A;
}
void solve() {
  M['W'] = 'E';
  M['E'] = 'W';
  M['S'] = 'N';
  M['N'] = 'S';
  scanf("%d", &n);
  string A, B;
  cin >> A >> B;
  puts(kmp(rev(A) + B) ? "YES" : "NO");
}
int main() {
  int te = 1;
  for (int ti = 0; ti < (te); ++ti) solve();
  return 0;
}

NO YES NO NO NO NO NO NO NO NO NO NO NO YES NO NO NO NO YES NO NO NO NO YES NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO NO YES

import java.util.*;

public class C {
/*
9
NNSESENN
NNSSWNWN

9
NNSESENN
SNSSWNWN

9
NNSESENN
NNSSWNEN
*/

	public static void main(String[] args) {

		Scanner qwe = new Scanner(System.in);

		int n = qwe.nextInt();
		StringBuilder needle = new StringBuilder(qwe.next()).reverse();
		char[] tocomp = qwe.next().toCharArray();

		StringBuilder hay = new StringBuilder();

		String dirs = "NSEW";
		String dc =   "SNWE";

		for (int i = 0; i < tocomp.length; i++) {
			hay.append(dc.charAt(dirs.indexOf(tocomp[i])));
		}

		if(n == 2){
			if(hay.toString().equals(needle.toString())){
				System.out.println("NO");
			}
			else System.out.println("YES");
		}
		else if(new KMP().KMPSearch(needle.toString(), hay.toString())){
			System.out.println("YES");
		}
		else System.out.println("NO");

		qwe.close();
	}

	static class KMP {
		/**
		 * Generates the table used by KMP. Not really useful on its own :( O(m)
		 * [m=length of needle]
		 */
		public int[] KMPTableGen(String needle) {
			int[] T = new int[needle.length()];
			int pos = 2;
			int cnd = 0;
			T[0] = -1;
			T[1] = 0;
			while (pos < needle.length()) {
				if (needle.charAt(pos - 1) == needle.charAt(cnd)) {
					cnd++;
					T[pos] = cnd;
					pos++;
				} else if (cnd > 0)
					cnd = T[cnd];
				else {
					T[pos] = 0;
					pos++;
				}
			}
			return T;
		}

		/**
		 * KMP - String Searching
		 *
		 * O(n+m) [n=length of haystack, m=length of needle] Searches for the string
		 * needle in the string haystack Requires: KMPTableGen(String)
		 */
		public boolean KMPSearch(String needle, String haystack) {
			int m = 0;
			int i = 0;
			int[] T = KMPTableGen(needle);
			while (m + i < haystack.length()) {
				if (needle.charAt(i) == haystack.charAt(m + i)) {
//					if (i == needle.length() - 1)
//						return m;
					i++;
				} else {
					m = m + i - T[i];
					if (T[i] > -1)
						i = T[i];
					else
						i = 0;
				}
			}
			//return haystack.length();
			return  i ==0;
		}
	}

}


#include <bits/stdc++.h>
using namespace std;
vector<long long> ans;
long long gcd(long long x, long long y) {
  while (true) {
    if (x == y) return x;
    if (x < y) {
      long long p = (y - 1) / x;
      ans.push_back(-p);
      y -= x * p;
    } else {
      long long p = (x - 1) / y;
      ans.push_back(p);
      x -= y * p;
    }
  }
  throw;
}
int main() {
  long long x, y;
  cin >> x >> y;
  if (gcd(x, y) != 1) {
    printf("Impossible\n");
    return 0;
  }
  for (int i = 0; i < (int)ans.size(); i++)
    printf("%lld%c", abs(ans[i]), (ans[i] > 0 ? 'A' : 'B'));
  printf("\n");
  return 0;
}

import fractions
def solve(x, y):
    if fractions.gcd(x, y) > 1: return 'Impossible'
    turn = x > y
    if not turn: x, y = y, x
    ans = []
    while x != 0 and y != 0:
        ans.append((x//y, 'A' if turn else 'B'))
        x, y = y, x%y
        turn = not turn
    ans[-1] = (ans[-1][0]-1, ans[-1][1])
    return ''.join(str(n) + l for n, l in ans)

x, y = [int(x) for x in input().split()]
print(solve(x, y))


#include <bits/stdc++.h>
using namespace std;
const int N = 2e3 + 5;
const int MOD = 1e9 + 7;
int d, n;
int a[N], root;
vector<vector<int>> g(N);
int dp(int u, int f) {
  int ret = 1;
  for (int v : g[u]) {
    if (f == v or a[v] < a[root] or a[v] > a[root] + d or
        (a[v] == a[root] and v > root))
      continue;
    ret = 1ll * ret * (dp(v, u) + 1) % MOD;
  }
  return ret;
}
int main() {
  scanf("%d%d", &d, &n);
  for (int i = 1; i <= n; i++) scanf("%d", a + i);
  for (int i = 1, u, v; i < n; i++) {
    scanf("%d%d", &u, &v);
    g[u].push_back(v);
    g[v].push_back(u);
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    root = i;
    (ans += dp(i, -1)) %= MOD;
  }
  printf("%d\n", ans);
}

import sys

def readInts(): return [int(x) for x in sys.stdin.readline().split()]

def readInt(): return int(sys.stdin.readline())

# def print(x):
    # sys.stdout.write(str(x) + '\n')

def solve():
    MOD = int(1e9 + 7)
    d, n = readInts()
    a = readInts()
    adj: list = [[] for _ in range(n)]
    for _ in range(n - 1):
        u, v = readInts()
        adj[u - 1].append(v - 1)
        adj[v - 1].append(u - 1)

    vis = [False for _ in range(n)]
    f = [0 for _ in range(n)]

    def dfs(cur, root):
        vis[cur] = True

        f[cur] = 1
        for neigh in adj[cur]:
            if vis[neigh]:
                continue
            if not (a[root] <= a[neigh] <= a[root] + d):
                continue
            if a[neigh] == a[root] and neigh < root:
                continue
            dfs(neigh, root)
            f[cur] *= f[neigh] + 1
            f[cur] %= MOD

    ans = 0
    for i in range(0, n):
        vis = [False for _ in range(n)]
        f = [0 for _ in range(n)]
        dfs(i, i)
        ans += f[i]
        ans %= MOD
    print(ans)

def main():
    t = 1
    # t = readInt()
    for _ in range(t):
        solve()

main()


#include <bits/stdc++.h>
using namespace std;
long long n, a[16];
long long solve(long long n, int step) {
  long long ans = (step + 1LL) * (n / a[step]);
  n %= a[step];
  if (n == 0) return ans;
  return ans + min(solve(n, step - 1), step + 1 + solve(a[step] - n, step - 1));
}
int main() {
  a[0] = 1;
  for (int i = 1; i < 16; ++i) a[i] = a[i - 1] * 10 + 1;
  cin >> n;
  cout << solve(n, 15);
}

import java.util.Scanner;

public class Main {
    static long [] en=new long[] {1, 11, 111, 1111, 11111, 111111, 1111111, 11111111, 111111111, 1111111111,
            11111111111L, 111111111111L, 1111111111111L, 11111111111111L, 111111111111111L, 1111111111111111L,11111111111111111L};

    public static void main(String[] args) {
        System.out.println(solve(new Scanner(System.in).nextLong()));
    }
    static long solve(long s){
        if(s<=11){
            return Math.min(s, 2+11-s);
        }
        int dolzina = (int) (Math.log10(s)+1);
        if (Math.abs((en[dolzina])-s)<s ){
            return (Math.min((solve(Math.abs(s-en[dolzina-1]))+ dolzina),(solve((en[dolzina])-s))+(dolzina+1)));
        }

        return solve(Math.abs(s-en[dolzina-1]))+ dolzina;
    }

}


from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

def main():
    n, k = [ int(x) for x in input().split() ]

    x = k - (n // 2 - 1)

    if x < 1 or (n < 2 and k > 0):
        print(-1)
        return

    sequence = [0] * n
    sequence[0] = x

    if n > 1:
        sequence[1] = 2*x

    if n >= 3:
        newValue = 1

        while newValue == x or newValue == 2*x \
        or newValue + 1 == x or newValue + 1 == 2*x:
            newValue += 1

        sequence[2] = newValue

    for i in range(3, n):
        newValue = sequence[i-1] + 1

        if not(i & 1):
            while newValue == x or newValue == 2*x \
            or newValue + 1 == x or newValue + 1 == 2*x:
                newValue += 1

        sequence[i] = newValue

    print(' '.join(map(lambda x: str(x), sequence)))

BUFFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)

class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")

input = lambda: sys.stdin.readline().rstrip("\r\n")

def print(*args, **kwargs):
    sep = kwargs.pop("sep", " ")
    file = kwargs.pop("file", sys.stdout)

    atStart = True
    for x in args:
        if not atStart:
            file.write(sep)
        file.write(str(x))
        atStart = False
    file.write(kwargs.pop("end", "\n"))

    if kwargs.pop("flush", False):
        file.flush()

sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

main()

#include <bits/stdc++.h>
using namespace std;
const int inf = 0x7fffffff;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int n, k;
  cin >> n >> k;
  int x = n / 2;
  if (x == 0 && k == 0)
    cout << "1"
         << "\n";
  else if (x > k || x == 0)
    cout << "-1"
         << "\n";
  else {
    int y = k - x + 1;
    cout << y << " " << 2 * y;
    y = 2 * y + 1;
    n -= 2;
    while (n--) cout << " " << y++;
    cout << "\n";
  }
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
const int maxn = 1000 + 5;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int main() {
  int n, a, b;
  vector<int> v;
  cin >> n;
  cin >> a;
  v.push_back(a);
  for (int i = 1; i < n; i++) {
    cin >> b;
    v.push_back(b);
    if (a < b) swap(a, b);
    a = gcd(a, b);
  }
  sort(v.begin(), v.end());
  if (*(lower_bound(v.begin(), v.end(), a)) == a)
    cout << a;
  else
    cout << -1;
  return 0;
}

input()
line = list(map(int, input().split()))
line.sort()
for i in line:
    if i % line[0] != 0:
        print(-1)
        break
else:
    print(line[0])


#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  int n, k;
  cin >> n >> k;
  int a[n];
  for (int i = 0; i < n; ++i) cin >> a[i];
  int m = unique(a, a + n) - a;
  int cont[k + 1];
  memset(cont, 0, sizeof cont);
  for (int i = 0; i < m; ++i) ++cont[a[i]];
  for (int i = 1; i + 1 < m; ++i)
    if (a[i - 1] == a[i + 1]) ++cont[a[i]];
  int best = n + 1, ans = -1;
  for (int i = 1; i <= k; ++i) {
    int aux = m - 1 - cont[i];
    if (aux < best) {
      best = aux;
      ans = i;
    }
  }
  cout << ans << endl;
  return 0;
}

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

public class P250C {

  private static void solve() {
    int n = nextInt();
    int k = nextInt();

    int[] s = new int[k + 1];

    int last = -1;
    int lastToLast = -1;
    for (int i = 0; i < n; i++) {
      int cur = nextInt();

      if (last != -1 && last != cur) {
        s[cur]++;
        if (lastToLast == -1 || cur == lastToLast) {
          s[last]++;
        }
      }
      if (last != -1 && last != cur) {
        lastToLast = last;
      }
      last = cur;
    }

    int max = s[1];
    int maxK = 1;

    for (int i = 1; i <= k; i++) {
      if (max < s[i]) {
        maxK = i;
        max = s[i];
      }
    }

    System.out.println(maxK);
  }

  private static void run() {
    br = new BufferedReader(new InputStreamReader(System.in));
    out = new PrintWriter(System.out);

    solve();

    out.close();
  }

  private static StringTokenizer st;
  private static BufferedReader br;
  private static PrintWriter out;

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

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

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

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


R = lambda: map(int, input().split())
n,k = R()
s = input()
p = [s]
ans = 0
d= set()
while p:
    q = p.pop(0)
    if q not in d:
        k -= 1
        ans += (n-len(q))
        if k == 0:
            print(ans)
            quit()
        d.add(q)
        for i in range(len(q)):
            t = q[:i]+q[i+1:]
            if t not in p:p.append(t)
print(-1)

import java.util.*;

public class Main {

    public static void allSubstrings(String x) {

        Queue<String> q = new LinkedList<>();
        q.add(x);

        while (!q.isEmpty()) {

            String temp = q.remove();
            System.out.println(temp);

            if (temp.length() > 1) {
                for (int i = 0; i < temp.length(); i++) {
                    q.add(temp.substring(0, i) + temp.substring(i+1));
                }
            }
        }

    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        if (k == 1) {
            System.out.println(0);
            return;
        }

        int cost = 0;
        int num = 1;

        HashSet<String> set = new HashSet<>();

        Queue<String> q = new LinkedList<>();
        String initial = sc.next();
        q.add(initial);
        set.add(initial);

        while (!q.isEmpty()) {

            String temp = q.remove();

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

                String t = temp.substring(0, i) + temp.substring(i+1);
                if (!set.contains(t)) {
                    q.add(t);
                    set.add(t);
                    num += 1;
                    cost += n - t.length();
                }

                if (num == k) {
                    System.out.println(cost);
                    return;
                }
            }
        }

        System.out.println(-1);
    }
}


#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
long long qpow(long long n, long long k) {
  long long ans = 1;
  assert(k >= 0);
  n %= mod;
  while (k > 0) {
    if (k & 1) ans = (ans * n) % mod;
    n = (n * n) % mod;
    k >>= 1;
  }
  return ans % mod;
}
long long n, b;
vector<pair<long long, long long> > di;
int main() {
  cin >> n >> b;
  long long rem = b;
  for (long long i = 2; i * i <= b; i++) {
    long long x = i;
    int cnt = 0;
    while (rem % x == 0) {
      rem /= x;
      cnt++;
    }
    if (cnt) di.push_back({i, cnt});
  }
  if (rem > 1) di.push_back({rem, 1});
  long long ret = -1;
  for (int i = 0; i < di.size(); i++) {
    long long curr = 0;
    long long tmp = n / di[i].first;
    while (tmp) {
      curr += tmp;
      tmp /= di[i].first;
    }
    curr /= di[i].second;
    if (ret == -1 or curr < ret) ret = curr;
  }
  cout << ret << endl;
  return 0;
}

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

public class B{

	static int N=(int)1e6+10;
	static ArrayList<Integer> primes;
	static void sieve() {
		boolean []isPrime=new boolean[N];
		primes=new ArrayList();
		Arrays.fill(isPrime, true);
		for(int i=2;i<N;i++)
			if(isPrime[i]) {
				primes.add(i);
				for(int j=i+i;j<N;j+=i)
					isPrime[j]=false;
			}
	}
	public static void main(String[] args) throws IOException {
		Scanner sc=new Scanner();
		PrintWriter out=new PrintWriter(System.out);
		long n=sc.nextLong(),b=sc.nextLong();
		long ans=(long)1e18;;
		sieve();

		for(int p:primes) {
			if(b%p!=0)
				continue;

			int cnt=0;
			while(b%p==0) {
				b/=p;
				cnt++;
			}
			long curr=0;
			for(long d=p;d<=n;) {
				curr+=n/d;
				if(d>n/p)
					break;
				else
					d*=p;

			}

			ans=Math.min(ans, curr/cnt);
		}
		if(b!=1) {
			int cnt=0;
			long p=b;
			while(b%p==0) {
				b/=p;
				cnt++;
			}
			long curr=0;
			for(long d=p;d<=n;) {
				curr+=n/d;
				if(d>n/p)
					break;
				else
					d*=p;

			}
			ans=Math.min(ans, curr/cnt);
		}
		out.println(ans);

		out.close();

	}
	static class Scanner
	{
		BufferedReader br;
		StringTokenizer st;
		Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		Scanner(String fileName) throws FileNotFoundException{
			br=new BufferedReader(new FileReader(fileName));
		}
		String next() throws IOException {
			while(st==null || !st.hasMoreTokens())
				st=new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		String nextLine() throws IOException {
			return br.readLine();
		}
		int nextInt() throws IOException{
			return Integer.parseInt(next());
		}
		long nextLong()  throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}
		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}
	}
}


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

public class Main {
	public static void main(String args[]) throws NumberFormatException, IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		Integer []nums = new Integer[n];
		StringTokenizer st = new StringTokenizer(br.readLine());
		for(int i=0; i<n; ++i) {
			nums[i] = Integer.parseInt(st.nextToken());
		}

		Arrays.sort(nums);

		System.out.print(Math.min(nums[n-2] - nums[0], nums[n-1] - nums[1]));
	}
}

input()

sequence = [int(i) for i in input().split(' ')]
sequence.sort()
a, b = sequence[-2] - sequence[0], sequence[-1] - sequence[1]
print(a) if a < b else print(b)


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.io.BufferedOutputStream;
import java.util.StringTokenizer;
import java.io.Closeable;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.Flushable;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
	static class TaskAdapter implements Runnable {
		@Override
		public void run() {
			InputStream inputStream = System.in;
			OutputStream outputStream = System.out;
			Input in = new Input(inputStream);
			Output out = new Output(outputStream);
			AClothes solver = new AClothes();
			solver.solve(1, in, out);
			out.close();
		}
	}

	public static void main(String[] args) throws Exception {
		Thread thread = new Thread(null, new TaskAdapter(), "", 1<<29);
		thread.start();
		thread.join();
	}
	static class AClothes {
		public AClothes() {
		}

		public void solve(int testNumber, Input in, Output pw) {
			int n = in.nextInt(), m = in.nextInt();
			int[] costs = new int[n];
			boolean[][] matches = new boolean[n][n];
			for(int i = 0; i<n; i++) {
				costs[i] = in.nextInt();
			}
			for(int i = 0; i<m; i++) {
				int u = in.nextInt()-1, v = in.nextInt()-1;
				matches[u][v] = matches[v][u] = true;
			}
			int ans = Integer.MAX_VALUE;
			for(int i = 0; i<n; i++) {
				for(int j = i+1; j<n; j++) {
					for(int k = j+1; k<n; k++) {
						if(matches[i][j]&&matches[j][k]&&matches[i][k]) {
							ans = Math.min(ans, costs[i]+costs[j]+costs[k]);
						}
					}
				}
			}
			if(ans==Integer.MAX_VALUE) {
				pw.println(-1);
			}else {
				pw.println(ans);
			}
		}

	}

	static class Output implements Closeable, Flushable {
		public StringBuilder sb;
		public OutputStream os;
		public int BUFFER_SIZE;
		public boolean autoFlush;
		public String LineSeparator;

		public Output(OutputStream os) {
			this(os, 1<<16);
		}

		public Output(OutputStream os, int bs) {
			BUFFER_SIZE = bs;
			sb = new StringBuilder(BUFFER_SIZE);
			this.os = new BufferedOutputStream(os, 1<<17);
			autoFlush = false;
			LineSeparator = System.lineSeparator();
		}

		public void println(int i) {
			println(String.valueOf(i));
		}

		public void println(String s) {
			sb.append(s);
			println();
			if(autoFlush) {
				flush();
			}else if(sb.length()>BUFFER_SIZE >> 1) {
				flushToBuffer();
			}
		}

		public void println() {
			sb.append(LineSeparator);
		}

		private void flushToBuffer() {
			try {
				os.write(sb.toString().getBytes());
			}catch(IOException e) {
				e.printStackTrace();
			}
			sb = new StringBuilder(BUFFER_SIZE);
		}

		public void flush() {
			try {
				flushToBuffer();
				os.flush();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

		public void close() {
			flush();
			try {
				os.close();
			}catch(IOException e) {
				e.printStackTrace();
			}
		}

	}

	static class Input {
		BufferedReader br;
		StringTokenizer st;

		public Input(InputStream is) {
			this(is, 1<<20);
		}

		public Input(InputStream is, int bs) {
			br = new BufferedReader(new InputStreamReader(is), bs);
			st = null;
		}

		public boolean hasNext() {
			try {
				while(st==null||!st.hasMoreTokens()) {
					String s = br.readLine();
					if(s==null) {
						return false;
					}
					st = new StringTokenizer(s);
				}
				return true;
			}catch(Exception e) {
				return false;
			}
		}

		public String next() {
			if(!hasNext()) {
				throw new InputMismatchException();
			}
			return st.nextToken();
		}

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

	}
}


import java.util.*;
public class A
{
	public static void main ( String args[] )
	{
		Scanner scan = new Scanner ( System.in ) ;
		int n = scan.nextInt() ;
		int a[] = new int[n] ;
		Set < Integer > s = new HashSet<Integer>() ;
		for ( int i = 0 ; i < n ; i++) {
		a[i] = scan.nextInt() ;
                if ( a[i] != 0 )
		s.add(a[i] ) ;
		}
		System.out.print ( s.size() ) ;

	}
}

n=int(input())
l=list(map(int,input().split()))
l=set(l)
if 0 in l:
	print(len(l)-1)
else:
	print(len(l))


k, n, s, p = map(int, input().split())

one = (n + s - 1) // s
print((one * k + p - 1) // p)

#include <bits/stdc++.h>
using namespace std;
int main() {
  float k, n, s, p;
  cin >> k >> n >> s >> p;
  int reqSheet = ceil(n / s);
  int total = reqSheet * k;
  int ans = ceil(total / p);
  cout << ans;
}


import java.util.*;
import java.io.*;
public class q2
{
  static int mat[][]=new int[27][27];
  static int visited[]=new int[27];
  static int st=0;
  static int end=0;
  static int fff=0;
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    PrintWriter pw=new PrintWriter(System.out, true);
    int n=in.nextInt();
    String s1=in.next();
    String s2=in.next();
    int c=0;
    String ans[]=new String[1000001];
    for(int i=0;i<s1.length();i++)
    {
      char c1=s1.charAt(i);
      char c2=s2.charAt(i);
      st=(int)c1-96;
      end=(int)c2-96;
      Arrays.fill(visited,0);
      fff=0;
      if(!dfs(st,end))
      {
        mat[st][end]=1;
        mat[end][st]=1;
        ans[c]=""+c1+c2;
        c++;
      }
    }
    pw.println(c);
    for (int i=0;i<c;i++)
    {
      pw.println(ans[i].charAt(0)+" "+ans[i].charAt(1));
   }
    pw.close();
  }
  public static boolean dfs(int st, int end)
	{
    visited[st]=1;
    if(st==end)
    fff=1;
    for(int j=0;j<27;j++)
    {
      if(visited[j]==0 && mat[st][j]==1)
      dfs(j,end);
    }
    if(fff==0)
    return false;
    return true;
  }
}

42
abcdefghijklmnopqrstuvwxyz
zp
```

Each sample input consists of 3 lines, where the first line is an integer `n` representing the length of the letterings, the second line is a string with length `n` representing the lettering on Valya's pullover, and the third line is a string with length `n` representing the lettering on Tolya's t-shirt.

13
a n
b o
c p
d q
e r
f s
g t
h u
i v
j w
k n
l n
m n

25
a z
b f
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

22
a w
b x
c z
d y
e w
f w
g w
h w
i w
j w
k w
l w
m w
n w
o w
p w
q w
r w
s w
t w
u w
v w

25
a z
b z
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

20
a u
b v
c w
d x
e z
f y
g u
h u
i u
j u
k u
l u
m u
n u
o u
p u
q u
r u
s u
t u

24
a y
b z
c y
d y
e y
f y
g y
h y
i y
j y
k y
l y
m y
n y
o y
p y
q y
r y
s y
t y
u y
v y
w y
x y

19
a t
b u
c v
d w
e x
f z
g y
h t
i t
j t
k t
l t
m t
n t
o t
p t
q t
r t
s t

25
a z
b l
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

25
a z
b g
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

23
a x
b y
c x
d x
e x
f x
g x
h x
i x
j x
k x
l x
m x
n x
o x
p x
q x
r x
s x
t x
u x
v x
w x

25
a z
b d
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

12
a m
b n
c o
d p
e q
f r
g s
h t
i u
j v
k m
l m

25
p a
f k
k v
s z
v m
d b
m o
n x
o l
b c
x l
l w
z c
w c
c a
q a
a r
i r
g h
y r
t r
j r
h r
r e
u e

17
a r
b s
c t
d u
e v
f w
g x
h y
i z
j r
k r
l r
m r
n r
o r
p r
q r

25
a z
b k
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

14
a o
b p
c q
d r
e s
f t
g u
h v
i w
j x
k o
l o
m o
n o

15
a p
b q
c r
d s
e t
f u
g v
h w
i x
j y
k p
l p
m p
n p
o p

21
a v
b w
c x
d y
e z
f v
g v
h v
i v
j v
k v
l v
m v
n v
o v
p v
q v
r v
s v
t v
u v

25
a z
b h
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

25
a z
b i
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

24
a z
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

18
a s
b t
c u
d v
e w
f x
g z
h y
i s
j s
k s
l s
m s
n s
o s
p s
q s
r s

25
a z
b m
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

25
a z
b p
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

10
a k
b l
c m
d n
e o
f p
g q
h r
i k
j k

11
a l
b m
c n
d o
e p
f q
g r
h s
i t
j l
k l

25
a z
b n
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

16
a q
b r
c s
d t
e u
f v
g w
h x
i z
j y
k q
l q
m q
n q
o q
p q

25
a z
b e
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

25
a z
b j
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

25
a z
b o
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

25
a z
b c
c z
d z
e z
f z
g z
h z
i z
j z
k z
l z
m z
n z
o z
p z
q z
r z
s z
t z
u z
v z
w z
x z
y z

25
b j
l m
t g
m i
u i
k z
v x
r z
h z
a x
z n
n g
y x
g q
d p
x s
q e
j i
i e
s e
w e
p e
e o
o f
f c

#include <bits/stdc++.h>
using namespace std;
const int MX = 1147483646;
const long long MX2 = 9223372036854775800;
const int MOD = 1000000007;
int p[30];
int find(int n) {
  if (p[n] < 0) return n;
  return p[n] = find(p[n]);
}
void uni(int e1, int e2) {
  e1 = find(e1);
  e2 = find(e2);
  if (e1 == e2) return;
  p[e1] = e2;
  return;
}
int main() {
  int n;
  scanf("%d", &n);
  char s1[100011], s2[100011];
  vector<pair<int, int> > ans;
  fill(p, p + 30, -1);
  scanf("%s %s", s1, s2);
  int a1, a2;
  for (int i = 0; i < n; i++) {
    a1 = find(int(s1[i] - 'a'));
    a2 = find(int(s2[i] - 'a'));
    if (a1 != a2) {
      ans.push_back({a1, a2});
      uni(a1, a2);
    }
  }
  printf("%d\n", ans.size());
  for (pair<int, int> x : ans) {
    printf("%c %c\n", x.first + 'a', x.second + 'a');
  }
  return 0;
}


INF = 1000000
erast = [1] * INF
erast[1] = 0

primes = []
for i in range(2, INF):
    if erast[i] == 1:
        for j in range(i * 2, INF, i):
            erast[j] = 0
        primes.append(i)
# print(primes)
lastp = primes[-1]
n, m = map(int, input().split())
edges = set()
print(lastp, lastp)
for i in range(n - 2):
    print(i + 1, i + 2, 1)
    edges.add((i, i + 1))
    edges.add((i + 1, i))

print(n - 1, n, lastp - n + 2)
edges.add((n - 1, n))
edges.add((n, n - 1))

m -= n - 1
for i in range(0, n):
    for j in range(0, n):
        if i == j: continue
        if m == 0: break
        if not (i, j) in edges:
            m -= 1
            print(i + 1, j + 1, INF)
            edges.add((i, j))
            edges.add((j, i))


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

public class CodeForces {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(
                new InputStreamReader(System.in));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = Integer.parseInt(st.nextToken());
        long x = Long.parseLong(st.nextToken());
        long k = Long.parseLong(st.nextToken());

        long[] a=new long[n];
        st = new StringTokenizer(br.readLine());
        for (int i = 0; i < n; i++) {
            long element=Long.parseLong(st.nextToken());
            a[i]=element;
        }

        Arrays.sort(a);

        long ans=0;
        for (int i = 0; i < n; i++) {
            long l,r;
            if (a[i]%x!=0){
                l=Math.max(x*(a[i]/x) + (k*x),a[i]);
                r=x*(a[i]/x) + (((k+1)*x)-1);
            }else{
                l=Math.max(x*(a[i]/x) + ((k-1)*x),a[i]);
                r=x*(a[i]/x) + ((k*x)-1);
            }
            if (r>=l){
                ans+=findIndexOfNumbersInTheRange(l,r,a);
            }
        }
        System.out.println(ans);
    }

    private static int findIndexOfNumbersInTheRange(long l, long r, long[] a){

        //find the first occurrence of number greater than equal to l
        int indexL=binarySearchFindFirstOccurrence(a,l);
        //find the last occurrence of number less than equal to r
        int indexR=binarySearchFindLastOccurrence(a,r);

        if (indexL!=-1 && indexR!=-1 && (indexR-indexL+1)>0){
            return (indexR-indexL+1);
        }
        return 0;
    }

    private static int binarySearchFindFirstOccurrence(long[] a,long element){
        int l=0;
        int h=a.length-1;

        while(l<h){
            int m=(h+l)/2;
            if (a[m]<element){
                l=m+1;
            }else{
                h=m;
            }
        }

        if (a[h]<element){
            return -1;
        }
        return h;
    }
    private static int binarySearchFindLastOccurrence(long[] a,long element){
        int l=0;
        int h=a.length-1;

        while(l<=h){
            int m=(h+l)/2;
            if (a[m]<element){
                l=m+1;
            }else if (a[m]==element){
                if (m==a.length-1){
                    return m;
                }
                if (element<a[m+1]) {
                    return m;
                }else{
                    l=m+1;
                }
            }else{
                h=m-1;
            }
        }

        if (h>=0 && h<=a.length-1 && a[h]<element){
            return h;
        }else{
            return -1;
        }
    }
}

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int l, r, n, x, k, p, i, q, m;
  cin >> n >> x >> k;
  long long int arr[n];
  for (i = 0; i < n; i++) cin >> arr[i];
  sort(arr, arr + n);
  long long int cnt = 0, ind1, ind2;
  for (i = 0; i < n; i++) {
    l = (ceil((double)arr[i] / x) + (k - 1)) * x;
    r = l + (x - 1);
    if (k == 0) {
      l = arr[i];
      r = ceil((double)arr[i] / x) * x - 1;
    }
    ind1 = lower_bound(arr, arr + n, l) - arr;
    ind2 = upper_bound(arr, arr + n, r) - arr;
    cnt += (ind2 - ind1);
  }
  cout << cnt << endl;
  return 0;
}


a,b,c = list(map(int, input().split(' ')))

MOD = 998244353

def d(a, b):
	s = 1
	for i in range(a, b+1):
		s*=i
		s%=MOD
	return s

def cnk(n,k):
	s = 1
	for i in range(n-k+1, n+1):
		s*=i
	for i in range(1,k+1):
		s/=i
	return s

def factorial(n):
	s = 1
	for i in range(1, n+1):
		s*=i
	return s

def pow(a, b):
	c = 1

	while b>0:
		if b%2==0:
			b//=2
			a *=a
			a%=MOD
		else:
			b-=1
			c*=a
			c%=MOD
	return c

def inv(i):
	return pow(i, MOD-2)
"""
def factinv(i):

	return 1.0/factorial(i)

"""
fi = [1, 1]
def sp(n, m):
	s = 1
	d1 = 1
	d2 = 1
	#print(d1,d2,"!")
	for i in range(1, n+1):
		d1*=n-i+1
		d2*=m-i+1

		#print(i, d1,d2)
		d1%=MOD
		d2%=MOD
		s+= d1*d2 *(fi[i]%MOD)
		#print(d1*d2 *(fi[i]%MOD))
		s%= MOD

	return s

s = 1
for i in range(2, max(a,max(b,c))+1):
	s *=i
	s %= MOD
	fi.append(inv(s))

print((sp(a,b)*sp(a,c)*sp(b,c))%MOD)
#print(sp(1,2))
#print(sp(2,2))
#print()


#include <bits/stdc++.h>
using namespace std;
int arr[100001], nxt[100001], pos[100001], have[100001];
set<pair<int, int> > s;
int main() {
  ios::sync_with_stdio(false);
  ;
  cin.tie(0);
  ;
  int i, j, n, k, x, y, cost = 0, which, have_ctr = 0;
  cin >> n >> k;
  for (i = 1; i <= n; i++) cin >> arr[i];
  for (i = n; i >= 1; i--) {
    if (!pos[arr[i]])
      nxt[i] = n + 1;
    else
      nxt[i] = pos[arr[i]];
    pos[arr[i]] = i;
  }
  for (i = 1; i <= n; i++) {
    if (have[arr[i]]) {
      assert(s.find({i, arr[i]}) != s.end());
      s.erase(s.find({i, arr[i]}));
      s.insert({nxt[i], arr[i]});
      continue;
    }
    cost++;
    if (have_ctr < k) {
      have_ctr++;
      have[arr[i]] = 1;
      s.insert({nxt[i], arr[i]});
      continue;
    }
    which = (*(--s.end())).second;
    have[which] = 0;
    s.erase(--s.end());
    have[arr[i]] = 1;
    s.insert({nxt[i], arr[i]});
  }
  cout << cost;
  return 0;
}

n,k=map(int,input().split())
a=list(map(int,input().split()))
z=[0]*81
kz,ans=0,0
for i in range(n):
    if z[a[i]]: continue
    ans+=1
    if k>kz:
        z[a[i]]=1; kz+=1
    else:
        h=-1
        for j in range(1,n+1):
            if z[j]:
                m=n+1
                for p in range(i,n):
                    if j==a[p]:
                        m=p
                        break
                if m>h:
                    h=m;
                    t=j
        z[t]=0
        z[a[i]]=1
print(ans)


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;

//        try {
//            inputStream = new FileInputStream("input.txt");
//        } catch (FileNotFoundException e) {
//            System.exit(13);
//        }

        Scanner in = new Scanner(inputStream);
        int n = Integer.valueOf(in.nextLine());
        boolean good = false;
        List<String> answer = new ArrayList<>();
        for (int i = 0; i < n; ++i) {
            String line = in.nextLine();
            if (good) {
                answer.add(line);
            } else {
                if (line.substring(0, 2).equals("OO")) {
                    String answerLine = "++" + line.substring(2);
                    answer.add(answerLine);
                    good = true;
                } else if (line.substring(3).equals("OO")) {
                    String answerLine = line.substring(0, 3) + "++";
                    answer.add(answerLine);
                    good = true;
                } else {
                    answer.add(line);
                }
            }
        }

        if (good) {
            System.out.println("YES");
            for (String line : answer) {
                System.out.println(line);
            }
        } else {
            System.out.println("NO");
        }
    }
}

7
XO|XO
XO|XX
OX|XO
XX|XO
OX|OX
XX|XX
OX|OX

9
XO|XO
XO|XX
OX|XO
XX|XO
OX|OX
XX|XX
OX|OX
XX|OX

10
XO|XO
XO|XX
OX|XO
XX|XO
OX|OX
XX|XX
OX|OX
XX|OX

8
XO|XO
XO|XX
OX|XO
XX|XO
OX|OX
XX|XX
OX|OX
XX|OX

61
OX|XX
OX|XX
OX|XX
XO|XO
XX|XO
XX|XX
XX|XX
OX|XX
XO|XO
OX|XO
XO|OX
XX|XX
XX|XX
OX|OX
XX|OX
OX|XO
OX|XO
XO|OX
XO|XX
OX|XX
OX|XX
XO|OX
XO|XX
XO|XX
OX|XX
XX|XX
XX|XO
XO|XX
XX|XX
XO|OX
XX|XO
XO|XX
XO|XO
XO|OX
XX|OX
XO|OX
OX|XX
XX|OX
XX|XX
OX|XO
OX|XX
XO|OX
OX|XX
OX|XX
XO|XO
XO|XX
OX|XX
XO|XO
OX|XX
XX|XX
OX|XO
XO|XO
XO|XO
OX|OX
XX|OX
XX|OX
OX|XO
OX|XX
OX|OX
XO|XX
OX|XX

10
OO|XX
XO|OX
XO|OX
XO|OX
XO|OX
XO|OX
XO|OX
XO|OX
XO|OX
XX|XX

YES
++|XX
XO|OX
XO|OX
XO|OX
XO|OX
XO|OX
XO|OX
XO|OX
XO|OX
XX|XX

#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n;
  while (cin >> n) {
    getchar();
    string s[n + 5];
    for (int i = 0; i < n; i++) cin >> s[i];
    long long l = 0, g = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j += 3) {
        if (s[i][j] == 'O' && s[i][j + 1] == 'O') {
          s[i][j] = '+', s[i][j + 1] = '+';
          l = 1, g = 1;
          break;
        }
      }
      if (g == 1) break;
    }
    if (l == 1) {
      cout << "YES" << endl;
      for (int i = 0; i < n; i++) {
        cout << s[i] << endl;
      }
    } else if (l == 0)
      cout << "NO" << endl;
  }
  return 0;
}


def main():
    m = int(input())
    if m < 1000000:
        lo = m*4
        hi = m*8
    else:
        lo = int(4.949 * m)
        hi = int(4.9492 * m)
    while lo < hi - 1:
        mid = (lo + hi)//2
        nposs = countposs(mid)
        if nposs < m:
            lo = mid
        else:
            hi = mid
    if m == countposs(hi):
        print(hi)
    else:
        print(-1)

def countposs(maxtake):
    k = 2
    ans = 0
    while True:
        term = maxtake//(k*k*k)
        if term == 0:
            return ans
        ans += term
        k += 1

main()

#include <bits/stdc++.h>
using namespace std;
long long c[1000005], m;
long long val(long long i) {
  long long moo = 0;
  for (long long j = 2; j <= 1000002; ++j) {
    if (c[j] > i) break;
    moo += (i / c[j]);
  }
  return moo;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> m;
  for (long long i = 1; i <= 1000003; ++i) c[i] = i * i * i;
  long long l = 1, r = 1000000000000000005, mid = (l + r) / 2, v, ans = 0;
  while (l < r) {
    v = val(mid);
    if (v == m) ans = mid;
    if (v >= m)
      r = mid;
    else
      l = mid + 1;
    mid = (l + r) / 2;
  }
  if (v == m || ans != 0)
    cout << mid << endl;
  else
    cout << -1 << endl;
  return 0;
}


#include <bits/stdc++.h>
using namespace std;
int md = 1e9 + 7;
int s(long long l, long long r) {
  if (l > r) return 0;
  long long z = l - 1;
  int a, b;
  if (z & 1)
    a = z % md * ((z + 1) / 2 % md) % md;
  else
    a = z / 2 % md * ((z + 1) % md) % md;
  z = r;
  if (z & 1)
    b = z % md * ((z + 1) / 2 % md) % md;
  else
    b = z / 2 % md * ((z + 1) % md) % md;
  b -= a;
  if (b < 0) b += md;
  return b;
}
int main() {
  long long n, m;
  scanf("%I64d%I64d", &n, &m);
  int an = n % md * (m % md) % md, mn = 0;
  long long z = sqrt(n), q = z;
  int lm = n / z;
  lm = min((long long)lm, m + 1);
  for (int i = 1; i < lm; ++i) mn = (mn + n / i * i) % md;
  ++z;
  while (z) {
    long long l = n / z, r = n / (z + 1);
    l = min(l, m);
    r = max(r, (long long)lm - 1);
    mn = (mn + s(r + 1, l) * z) % md;
    --z;
  }
  an -= mn;
  if (an < 0) an += md;
  printf("%d", an);
}

from math import floor

def range_sum(low, up):
    return (up * (up + 1)) // 2 - (low * (low + 1)) // 2

# for _ in range(int(input())):
mod = int(1e9 + 7)
n,m=map(int,input().split())
ans, sqrt_n = m*n, int(floor(n**0.5))
temp = 0
for i in range(1, sqrt_n + 1):
    up = n // i
    low = n // (i + 1)
    up = min(up, m)
    if(up < low):
        continue
    temp1 = range_sum(low, up)
    temp += (temp1 * i)

for i in range(1, sqrt_n + 1):
    if m < i:
        break;
    if n // i != i:
        temp += (n // i) * i
print((ans-temp)%mod)


import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Locale;
import java.util.Scanner;

public class Codeforces {
	static long gcd(long a, long b){
		return (b>0)?gcd(b,a%b):a;
	}
	static long ond(long a){
		return (a==0)?1:((a%2==0)?(ond(a/2)*ond(a/2)):ond(a-1)*10);
	}

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s=br.readLine();
		String[] tokens=s.trim().split("\\s+");
		int n=Integer.parseInt(tokens[0]);
		int k=Integer.parseInt(tokens[1]);
		int soni=n/k;
		long[] a=new long[soni];
		long[] b=new long[soni];
		long[] c=new long[soni];
		s=br.readLine();
		tokens=s.trim().split("\\s+");
		for(int i=0;i<soni;i++){
			a[i]=Long.parseLong(tokens[i]);
			c[i]=0;
		}
		s=br.readLine();
		tokens=s.trim().split("\\s+");

		for(int i=0;i<soni;i++){
			b[i]=Long.parseLong(tokens[i]);
		}
		for(int i=0;i<soni;i++){
			c[i]=(ond(k)-1)/a[i]+1-(((b[i]+1)*ond(k-1)-1)/a[i]-(b[i]>0?(b[i]*ond(k-1)-1)/a[i]:-1));
			//System.out.println((ond(k)-1)/a[i]+1+" "+((b[i]+1)*ond(k-1)-1)/a[i]+" "+(b[i]>0?(b[i]*ond(k-1)-1)/a[i]:-1));
		}
		long javob=c[0];
		for(int i=1;i<soni;i++){
			javob*=c[i];
			if(javob>1000000007){
				javob%=1000000007;
			}
		}
		System.out.println(javob);
		br.close();
	}

}