using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading;

// (づ°ω°)づﾐe★゜・。。・゜゜・。。・゜☆゜・。。・゜゜・。。・゜
public class Solver
{
    static List<List<int>> g;

    class Dsu
    {
        public readonly List<int> parent;

        public Dsu(int n)
        {
            parent = Enumerable.Range(0, n).ToList();
            g = Init<List<int>>(n).ToList();
        }

        public int FindSet(int v)
        {
            if (v == parent[v])
                return v;
            return parent[v] = FindSet(parent[v]);
        }

        public void UnionSets(int a, int b)
        {
            a = FindSet(a);
            b = FindSet(b);
            if (a != b)
            {
                parent[a] = parent[b] = parent.Count;
                g.Add(new List<int>());
                g[parent.Count].Add(a);
                g[parent.Count].Add(b);
                parent.Add(parent.Count);
            }
        }
    }

    int[] c;
    int[] tree;

    int Cmp(int l, int r)
    {
        return c2[l] > c2[r] ? l : r;
    }

    void Build(int x, int xl, int xr)
    {
        if (xl == xr)
        {
            tree[x] = xl;
            return;
        }
        int xm = (xl + xr) / 2;
        Build(x * 2, xl, xm);
        Build(x * 2 + 1, xm + 1, xr);
        tree[x] = Cmp(tree[2 * x], tree[2 * x + 1]);
    }

    void Set(int x, int xl, int xr, int idx)
    {
        if (xl == xr)
        {
            c2[xl] = 0;
            return;
        }

        int xm = (xl + xr) / 2;
        if (idx <= xm)
            Set(x * 2, xl, xm, idx);
        else
            Set(x * 2 + 1, xm + 1, xr, idx);
        tree[x] = Cmp(tree[2 * x], tree[2 * x + 1]);
    }

    int Query(int x, int xl, int xr, int l, int r)
    {
        if (l == xl && r == xr)
            return tree[x];
        int xm = (xl + xr) / 2;
        if (r <= xm)
            return Query(x * 2, xl, xm, l, r);
        if (l > xm)
            return Query(x * 2 + 1, xm + 1, xr, l, r);
        return Cmp(Query(x * 2, xl, xm, l, xm), Query(x * 2 + 1, xm + 1, xr, xm + 1, r));
    }

    int n;
    bool[] vis;
    int[] tin, tout, c2;
    int timer;
    void Dfs(int x)
    {
        if (x < n)
            c2[timer] = c[x];
        vis[x] = true;
        tin[x] = timer++;
        foreach (int e in g[x])
            Dfs(e);
        tout[x] = timer;
    }

    public void Solve()
    {
        n = ReadInt();
        int m = ReadInt();
        int q = ReadInt();
        c = ReadIntArray();
        var a = ReadIntMatrix(m);
        var b = ReadIntMatrix(q);

        //n = 200000;
        //m = 199999;
        //q = 500000;
        //c = new int[n];
        //var rnd = new Random(13);
        //for (int i = 0; i < n; i++)
        //    c[i] = rnd.Next(n) + 1;
        //a = new int[m][];
        //for (int i = 0; i < m; i++)
        //    a[i] = new[] { i + 1, i + 2 };
        //b = new int[q][];
        //int cnt = 1;
        //for (int i = 0; i < q; i++)
        //{
        //    b[i] = new int[2];
        //    b[i][0] = rnd.Next(2) + 1;
        //    if (cnt > m)
        //        b[i][0] = 1;
        //    if (b[i][0] == 1)
        //    {
        //        b[i][1] = rnd.Next(n) + 1;
        //    }
        //    else
        //    {
        //        b[i][1] = cnt++;
        //    }
        //}

        var f = new bool[m];
        for (int i = 0; i < q; i++)
        {
            b[i][1]--;
            if (b[i][0] == 2)
                f[b[i][1]] = true;
        }

        var dsu = new Dsu(n);
        for (int i = 0; i < m; i++)
        {
            a[i][0]--;
            a[i][1]--;
            if (!f[i])
                dsu.UnionSets(a[i][0], a[i][1]);
        }

        for (int i = q - 1; i >= 0; i--)
        {
            if (b[i][0] == 1)
            {
                b[i][1] = dsu.FindSet(b[i][1]);
            }
            else
            {
                dsu.UnionSets(a[b[i][1]][0], a[b[i][1]][1]);
            }
        }

        int n2 = dsu.parent.Count;
        tin = new int[n2];
        tout = new int[n2];
        vis = new bool[n2];
        c2 = new int[n2];
        for (int i = n2 - 1; i >= 0; i--)
            if (!vis[i])
                Dfs(i);

        tree = new int[4 * n2];
        Build(1, 0, n2 - 1);
        for (int i = 0; i < q; i++)
            if (b[i][0] == 1)
            {
                int x = Query(1, 0, n2 - 1, tin[b[i][1]], tout[b[i][1]] - 1);
                Write(c2[x]);
                Set(1, 0, n2 - 1, x);
            }
    }

    #region Main

    protected static TextReader reader;
    protected static TextWriter writer;
    static void Main()
    {
#if DEBUG
        reader = new StreamReader("..\\..\\input.txt");
        //reader = new StreamReader(Console.OpenStandardInput());
        writer = Console.Out;
        //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("input.txt");
        //writer = new StreamWriter("output.txt");
#endif
        try
        {
            //new Solver().Solve();
            var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
            thread.Start();
            thread.Join();
        }
        catch (Exception ex)
        {
#if DEBUG
            Console.WriteLine(ex);
#else
            throw;
#endif
        }
        reader.Close();
        writer.Close();
    }

    #endregion

    #region Read / Write
    private static Queue<string> currentLineTokens = new Queue<string>();
    private static string[] ReadAndSplitLine() { return reader.ReadLine().Split(new[] { ' ', '\t', }, StringSplitOptions.RemoveEmptyEntries); }
    public static string ReadToken() { while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine()); return currentLineTokens.Dequeue(); }
    public static int ReadInt() { return int.Parse(ReadToken()); }
    public static long ReadLong() { return long.Parse(ReadToken()); }
    public static double ReadDouble() { return double.Parse(ReadToken(), CultureInfo.InvariantCulture); }
    public static int[] ReadIntArray() { return ReadAndSplitLine().Select(int.Parse).ToArray(); }
    public static long[] ReadLongArray() { return ReadAndSplitLine().Select(long.Parse).ToArray(); }
    public static double[] ReadDoubleArray() { return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray(); }
    public static int[][] ReadIntMatrix(int numberOfRows) { int[][] matrix = new int[numberOfRows][]; for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray(); return matrix; }
    public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
    {
        int[][] matrix = ReadIntMatrix(numberOfRows); int[][] ret = new int[matrix[0].Length][];
        for (int i = 0; i < ret.Length; i++) { ret[i] = new int[numberOfRows]; for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i]; }
        return ret;
    }
    public static string[] ReadLines(int quantity) { string[] lines = new string[quantity]; for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim(); return lines; }
    public static void WriteArray<T>(IEnumerable<T> array) { writer.WriteLine(string.Join(" ", array)); }
    public static void Write(params object[] array) { WriteArray(array); }
    public static void WriteLines<T>(IEnumerable<T> array) { foreach (var a in array) writer.WriteLine(a); }
    private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get { return ContainsKey(key) ? base[key] : default(TValue); }
            set { base[key] = value; }
        }
    }
    private static T[] Init<T>(int size) where T : new() { var ret = new T[size]; for (int i = 0; i < size; i++) ret[i] = new T(); return ret; }
    #endregion
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Techno
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] nm = Console.ReadLine().Split();
            int n = Convert.ToInt32(nm[0]);
            int m = Convert.ToInt32(nm[1]);
            int min1 = int.MaxValue;
            int min2 = int.MaxValue;
            string[] s1 = Console.ReadLine().Split();
            string[] s2 = Console.ReadLine().Split();
            for (int i = 0; i < s1.Length; i++)
            {
                if (Convert.ToInt32(s1[i]) < min1)
                {
                    min1 = Convert.ToInt32(s1[i]);
                }
                if (Convert.ToInt32(s2[i]) < min2)
                {
                    min2 = Convert.ToInt32(s2[i]);
                }
            }
            if (min1 != min2)
            {
                Console.WriteLine(Math.Min(min1, min2) + "" + Math.Max(min1, min2));
            }
            else
            {
                Console.WriteLine(min1);
            }

        }
    }
}


using System;

namespace HW
{
    class Program
    {
        static void Main()
        {
            string[] s = Console.ReadLine().Split();
            int[] a = new int[int.Parse(s[0])];
            int[] b = new int[int.Parse(s[1])];

            string[] st = Console.ReadLine().Split();

            for (int i = 0; i<a.Length; i++)
            {
                a[i] = int.Parse(st[i]);
            }
            Array.Resize(ref st, b.Length);
            st = Console.ReadLine().Split();

            for (int i = 0; i < b.Length; i++)
            {
                b[i] = int.Parse(st[i]);
            }

            Array.Sort(b);
            int min = 10;
            int min1 = a[0];
            bool bo = false;
            for (int i = 0; i<a.Length;i++)
            {
                if (Array.BinarySearch(b, a[i]) >= 0 )
                {
                    if (min>a[i])
                    {
                        min = a[i];
                        bo = true;
                    }
                }
                else
                {
                    if (min1 > a[i])
                    {
                        min1 = a[i];
                    }
                }
            }

            if (bo == true)
            {
                Console.WriteLine(min);
            }
            else
            {
                Console.WriteLine(min1 * 10 + b[0]);
            }

            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Threading;

namespace Achill
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = Int32.Parse(Console.ReadLine());
            Console.WriteLine(n % 2 == 0 ? n + 1 : (n + 1) / 2);
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;

namespace contest1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetIn(new StreamReader("input.txt"));
            solve_482A();
        }

        public static void solve_482A()
        {
            long n = Convert.ToInt64(Console.ReadLine());

            long pieces = 0;
            if (n > 0)
            {
                long pizza = n + 1;
                if (pizza % 2 == 0)
                {
                    pieces = pizza / 2;
                }
                else
                {
                    pieces = pizza;
                }
            }
            Console.WriteLine(pieces);
        }
    }
}


using System;
namespace PizzaPizzaPizza
{
    class PizzaPizzaPizza
    {
        static void Main()
        {
            long n = Console.ReadLine();

            n++;// Considering her share

            if (n == 1) {
                Console.WriteLine(0);
            }
            else if (n % 2 == 0)
            {// Even
                Console.WriteLine(n / 2);
            }
            else
            {// Odd and not 1
                Console.WriteLine(n);
            }
        }
    }
}


using System;

namespace zad_1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            n++;
            if (n % 2 == 1)
                Console.WriteLine(n);
            else
                Console.WriteLine(n / 2);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace pizza
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());
            int k = 0;

            n = n + 1;

            if (0 <= n && n <= Math.Pow(10,18))
            {
                if ((n % 2) == 0 )
                {
                    k = n / 2;
                }
                else
                {
                    k = n;
                }
            }
            Console.WriteLine(k);
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            if(str[str.Length-1]%2==1)
            {
                Console.WriteLine((int.Parse(str) + 1) / 2);
            }
            else
            {
                Console.WriteLine((int.Parse(str) + 1));
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ProblemSolving.CodeForces
{
    class Pizza_979_problem_A
    {
        public static void Main(string[] args)
        {
            long x = int.Parse(Console.ReadLine());
            if((x+1) % 2 == 0)
            {
                Console.WriteLine((x+1)/2);
            }
            else
            {
                Console.WriteLine(x + 1);
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace codeforces_cutpizza
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = NextInt();
            if((n + 1) % 2 == 0) {
                Console.WriteLine((n + 1) / 2);
            } else
            {
                Console.WriteLine(n+1);
            }
        }
    #region
        static int s_index = 0;
        static List<string> s_tokens;

        private static string Next()
        {
            while (s_tokens == null || s_index == s_tokens.Count)
            {
                s_tokens = Console.ReadLine().Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                s_index = 0;
            }
            return s_tokens[s_index++];
        }

        private static bool HasNext()
        {
            while (s_tokens == null || s_index == s_tokens.Count)
            {
                s_tokens = null;
                s_index = 0;
                var nextLine = Console.ReadLine();
                if (nextLine != null)
                {
                    s_tokens = nextLine.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).ToList();
                }
                else
                {
                    return false;
                }

            }
            return s_tokens.Count > 0;
        }

        private static int NextInt()
        {
            return Int32.Parse(Next());
        }

        private static long NextLong()
        {
            return Int64.Parse(Next());
        }
        #endregion

    }

}


namespace Melon
{
    class Program
    {
        static void Main(string[] args)
        {
            int input = 8;
            string comprueba = "YES";
            string comprueba2 = "NO";

            if(input % 2 == 0)
            {
                Console.WriteLine(comprueba);
            }
            else
            {
                Console.WriteLine(comprueba2);
            }

        }
    }


class DivideWatermelon{
		static string  Divide(float kg){
			if(kg%2 == 0){
				return "Yes";
			}
			else
				return "No";
		}
		public static void Main(String[] args){
			int n=9;
			int m=8;

			string print=DivideWatermelon.Divide(n);
			string print1=DivideWatermelon.Divide(m);
			Console.WriteLine(print);
			Console.WriteLine(print1);

			Console.ReadLine();
		}
	}


using System;

using namespace Watermelon;

public string Foo(int n)
{
    if (n % 2 == 0)
    {
        return "yes"
    }

    else
    {
        return "no"
    }
}


using System;

namespace CF_Watermelon
{
    class Program
    {
        static void Main(string[] args)
        {
            var w = Convert.ToInt32(Console.ReadLine());

            for (int i = 2; i < w; i += 2)
            {
                var j = w - i;
                if (j > 0 && j % 2 == 0)
                {
                    Console.WriteLine("YES");
                }
            }

            Console.WriteLine("NO");
        }

        //for (int j = 2; i + j <= w; j += 2)
        //{
        //    if (w == i + j)
        //    {
        //        Console.WriteLine("YES");
        //    }
        //}
    }


using System;

int x= Convert.ToInt32(Console.ReadLine());
if(x%2==0)

{
return "Yes"
}
else
{
return "No"
}


using System;
using System.IO;

class Watermelon
{
    static string Main(string[] args)
    {
        int number = Int16.Parse(Console.ReadLine());
        if (number % 2 == 1 || number == 2)
            return "NO";
        return "YES";
    }
}


class TestClass
{
    static void Main(string[] args)
    {
        int num = Convert.ToInt32(Console.ReadLine());
        if (num < 4)
        {
            Console.WriteLine("NO");
        }
        else
        {
            if ((num - 2) % 2 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30523.141
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "problem4a", "problem4a.csproj", "{C4F94F8D-4503-4238-82E8-2FB4AB5CB73B}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{C4F94F8D-4503-4238-82E8-2FB4AB5CB73B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{C4F94F8D-4503-4238-82E8-2FB4AB5CB73B}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{C4F94F8D-4503-4238-82E8-2FB4AB5CB73B}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{C4F94F8D-4503-4238-82E8-2FB4AB5CB73B}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {73CBAF83-E471-446B-B123-FF2F67D6DAB5}
	EndGlobalSection
EndGlobal


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> arr = Console.ReadLine().Split(' ').Select(x => Convert.ToInt32(x)).ToList();

            arr.Sort();

            Console.WriteLine($"{arr[2] - (arr[0] + arr[1]) + 1 }");
        }
    }
}


using System.Linq;
using System.Collections.Generic;
using System;

namespace MyApp
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = 0, b = 0, c = 0;
            var inp = Console.ReadLine().Split();
            a = Convert.ToInt32(inp[0]);
            b = Convert.ToInt32(inp[1]);
            c = Convert.ToInt32(inp[2]);
            if(a > c) {
              int temp = c;
              c = a;
              a = c;
            }
            if(b > c) {
              int temp = c;
              c = b;
              b = c;
            }
            int ans = 0;
            if(c - (a + b - 1) > ans) {
              ans = c - (a + b - 1);
            }
            Console.WriteLine(ans);
        }
    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26730.16
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp1", "ConsoleApp1\ConsoleApp1.csproj", "{ABB1C275-B0DD-4207-98C6-3E1AF08D4A7C}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{ABB1C275-B0DD-4207-98C6-3E1AF08D4A7C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{ABB1C275-B0DD-4207-98C6-3E1AF08D4A7C}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{ABB1C275-B0DD-4207-98C6-3E1AF08D4A7C}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{ABB1C275-B0DD-4207-98C6-3E1AF08D4A7C}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {1753EC7D-E288-4292-84B8-C1654AC04FA8}
	EndGlobalSection
EndGlobal


using System;

public static class TriangleSolution
{
	public static string Numbers = Console.ReadLine();
	public static int Length = Numbers.Length;
	public static int CurrentSide = 1;
	public static string[] separateNumbers = new string[3];
	public static int[] integerNumbers = new int[3];
	public static int numberOfMinutes = 1;
	public static int shortestSide1;
	public static int shortestSide2;
	public static int longestSide;
	public static void getSideLengths()
	{
		char letter = '0';
		for(int i = 0; i < Length; i++)
		{
			letter = Numbers[i];
			if(letter == ' ')
			{
				CurrentSide = CurrentSide + 1;

			}
			else
			{

				separateNumbers[CurrentSide - 1] = separateNumbers[CurrentSide - 1] + letter + "";

			}
		}
	}
	public static void convertArrayToInteger(string[] chosenArray, int[] targetArray)
	{
		for(int i = 0; i < chosenArray.Length; i++)
		{
			targetArray[i] = int.Parse(chosenArray[i]);
		}
	}
	public static void declareSides(int sideShorter, int sideShorter2, int sideLonger)
	{
		shortestSide1 = sideShorter;
		shortestSide2 = sideShorter2;
		longestSide = sideLonger;
	}
	public static void orderSides(int[] integerSideLengths)
	{
			if(integerSideLengths[0] > integerSideLengths[1])
			{
				if(integerSideLengths[0] > integerSideLengths[2])
				{
					if(integerSideLengths[1] > integerSideLengths[2])
						declareSides(integerSideLengths[2],integerSideLengths[1],integerSideLengths[0]);
					else declareSides(integerSideLengths[1],integerSideLengths[2],integerSideLengths[0]);
				}
				else
				{
					declareSides(integerSideLengths[1],integerSideLengths[0],integerSideLengths[2]);
				}
			}
			else if (integerSideLengths[0] > integerSideLengths[2])
				declareSides(integerSideLengths[0],integerSideLengths[2],integerSideLengths[1]);
			else
			{
				declareSides(integerSideLengths[0],integerSideLengths[1],integerSideLengths[2]);
			}
	}
	public static void Main()
	{
		getSideLengths();
		convertArrayToInteger(separateNumbers, integerNumbers);
		//Console.WriteLine(separateNumbers[2]);
		orderSides(integerNumbers);
		//Console.WriteLine(integerNumbers[2]);
		//Console.WriteLine(longestSide + "" + shortestSide1 + "" + shortestSide2);
		numberOfMinutes = (longestSide - shortestSide1) - shortestSide2;
		if(numberOfMinutes < 0)
		{
			numberOfMinutes = 0;
		}
		else numberOfMinutes++;
		/*Console.WriteLine(Numbers);
		Console.WriteLine(separateNumbers[1]);
		Console.WriteLine(integerNumbers[1]);
		Console.WriteLine(longestSide + " " + shortestSide1);*/
		Console.WriteLine(numberOfMinutes);
	}

}


using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
class Problem
{
    static void Main()
    {
        //--------------------------------input--------------------------------//

        var v = Array.ConvertAll( Console.ReadLine().Split(), Convert.ToInt32 );
        Array.Sort( v );
        int a = v[0];
        int b = v[1];
        int c = v[2];

        //--------------------------------solve--------------------------------//

        if(c > a + b)
            Console.WriteLine( c + 1 - a - b );
        else
            Console.WriteLine( 0 );

    }
}


int[] arr = Console.ReadLine().Split(new []{' '}, StringSplitOptions.RemoveEmptyEntries)
.Select(str => Convert.ToInt32(str)).ToArray();
int max= arr.Max();//MAX

int SumMins = 0;

int imax = Array.IndexOf(arr, arr.Max());
for (int i = 0; i < arr.Length; i++)
if (i != imax)
SumMins += arr[i];

if (max + 1 < SumMins)
Console.WriteLine(0);
else
Console.WriteLine(max+1-SumMins);


using System;

class Program
{
    static void Main(string[] args)
    {
        int[] colors = new int[26];

        string[] l1 = args[0].Split(' ');
        int baloons = l1[0].ToInt();
        int friends = l1[1].ToInt();

        foreach (char c in args[1])
            colors[c-97]++;

        foreach (int i in colors)
        {
            if (i > friends)
            {
                Console.WriteLine("NO");
                return;
            }
        }

        Console.WriteLine("YES");
    }
}

public static class StringExtension
{
    public static int ToInt(this string str)
    {
        return Convert.ToInt32(str);
    }

    public static void Print(this object str)
    {
        Console.WriteLine(str.ToString());
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            int n = int.Parse(a.Split(' ')[0]);
            int k = int.Parse(a.Split(' ')[1]);
            string s = Console.ReadLine();
            for ( int i = 0; i<k; i++)
            {
                for (int j = 1; j<s.Length; j++)
                {
                    if (s[0] != s[j])
                    {
                        s = s.Remove(j, 1).Remove(0, 1);

                        break;
                    }
                }
            }
            if (s.Length == 0)
                Console.WriteLine("YES");
            else
                Console.Write("NO");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _841A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = int.Parse(s[0].ToString());
            int k = int.Parse(s[2].ToString());
            string a = Console.ReadLine();
            int lenght = a.Length;
            string a1 = new string(a.Distinct().ToArray());
            int lenght1 = a1.Length;
            if(lenght1 ==2)
            {
                if ((lenght - lenght1) <= k)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");
            }
            else
            {
                if ((lenght - lenght1) <= k - 1)
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");

            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B.Pasha_and_String
{
    class Program
    {
        static void Main(string[] args)
        {

            int n = int.Parse(Console.ReadLine());

            int k = int.Parse(Console.ReadLine());

            string input = Console.ReadLine();

            int[] counter = new int[n];

            for (int i = 0; i < input.Length -1 ; i++)
            {
                for (int j = i+1; j < input.Length; j++)
                {
                    if (input[i] == input[j])
                    {
                        counter[i]++;
                    }

                }
            }

           // Console.WriteLine(counter.Max()+1);

                Console.WriteLine(counter.Max() + 1 <= k ? "YES" : "NO");

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Actual_Shit_2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, k, maxamount = 0;
            string[] input = Console.ReadLine().Split(' ');
            n = int.Parse(input[0]);
            k = int.Parse(input[1]);
            string input2;
            input2 = Console.ReadLine();
            int[] a = new int[n];
            for (int i = 0; i < a.Length; i++)
            {
                a[input2[i] - 97]++;
                if (a[input2[i] - 97] > maxamount)
                    maxamount = a[input2[i] - 97];
            }
            if (maxamount > k)
                Console.WriteLine("NO");
            else
                Console.WriteLine("YES");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;
using System.Threading;

public class Program
{
    private long X, Y, L, R;

    public void Solve()
    {
        var sc = new Scanner();
        X = sc.NextLong();
        Y = sc.NextLong();
        L = sc.NextLong();
        R = sc.NextLong();

        /*
         * n = xa + yb
         * n年は不幸
         *
         * [l,r]内の不幸じゃない最大の区間
         */

        // 可能
        // 2 3
        // 5 6
        // 5 6 10 11 12 15 16 17 18 20
        // 10 11 12 13 14 15

        var hs = new HashSet<long>();
        long xa = 1;
        for (int a = 0;; a++)
        {
            long yb = 1;
            for (int b = 0;; b++)
            {
                hs.Add(xa + yb);
                // xa + yb * y <= R
                if ((double) yb * Y > R - xa) break;
                yb *= Y;
            }

            if ((double) xa * X > R) break;
            xa *= X;
        }

        hs.Add(L - 1);
        hs.Add(R + 1);
        var ar = hs.ToArray();
        Array.Sort(ar);

        long ans = 0;
        for (int i = 1; i < ar.Length; i++)
        {
            if (ar[i] <= R + 1)
            {
                ans = Math.Max(ans, ar[i] - ar[i - 1] - 1);
            }
        }

        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;
using System.Linq;
using System.IO;
using System.Collections.Generic;
// Powered by caide (code generator, tester, and library code inliner)

class Solution {
    public void solve(TextReader input, TextWriter output) {
        var inp = input.ReadLine().Split(' ').Select(i => ulong.Parse(i)).ToArray();
        ulong x = inp[0];
        ulong y = inp[1];
        ulong l = inp[2];
        ulong r = inp[3];

        int maxa = 0;
        while(Math.Pow(x, maxa) <= r)
            maxa++;

        int maxb = 0;
        while (Math.Pow(y, maxb) <= r)
            maxb++;

        var shits = new SortedSet<ulong>();
        var xi = new ulong[maxa + 1];
        xi[0] = 1;
        for (int i = 1; i <= maxa; i++)
        {
            xi[i] = xi[i - 1] * x;
        }
        var yj = new ulong[maxb + 1];
        yj[0] = 1;
        for (int j = 1; j <= maxb; j++)
        {
            yj[j] = yj[j - 1] * y;
        }

        for (int i = 0; i <= maxa; i++)
        {
            for (int j = 0; j <= maxb; j++)
            {
                ulong n = xi[i] + yj[j];
                if(l <= n && n <= r)
                    shits.Add(n);
            }
        }

        ulong res = 0;
        if (shits.Count == 0)
            res = r - l + 1;
        else
        {
            var shitArray = shits.ToArray();
            ulong shitLength;
            for (int i = 0; i < shitArray.Count() - 1; i++)
            {
                shitLength = shitArray[i + 1] - shitArray[i] - 1;
                if (shitLength > res)
                    res = shitLength;
            }

            shitLength = shitArray[0] - l;
            if (shitLength > res)
                res = shitLength;

            shitLength = r - shitArray[shitArray.Count() - 1];
            if (shitLength > res)
                res = shitLength;
        }

        output.WriteLine(res);
    }
}

class CaideConstants {
    public const string InputFile = null;
    public const string OutputFile = null;
}
public class Program {
    public static void Main(string[] args) {
        Solution solution = new Solution();
        using (System.IO.TextReader input =
                CaideConstants.InputFile == null ? System.Console.In :
                        new System.IO.StreamReader(CaideConstants.InputFile))
        using (System.IO.TextWriter output =
                CaideConstants.OutputFile == null ? System.Console.Out:
                        new System.IO.StreamWriter(CaideConstants.OutputFile))

            solution.solve(input, output);
    }
}


using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NSproul //A
{
    static class Program
    {
        static void Main()
        {
            double x = Int32.Parse(Console.ReadLine());
            int a = 0;
			int b = 0;
            for (int i = Int32.Parse(Math.Floor(Math.Sqrt(x))); i > 0; i--)
            {
                if(x%i == 0) {
					a = i;
					b = Int32.Parse(x)/i;
				}
            }
            Console.WriteLine(a + " " + b);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace CP_CS
{

    class Task
    {

        static void Solve()
        {
            int n = ReadInt();
            for (int i = (int)Math.Ceiling(Math.Sqrt(n)); i >= 1; i--)
            {
                if (n % i == 0)
                {
                    Write($"{i} {n/i}");
                    return;
                    ;
                }
            }
        }

        static string[] Split(string str, int chunkSize)
        {
            return Enumerable.Range(0, str.Length / chunkSize)
                .Select(i => str.Substring(i * chunkSize, chunkSize)).ToArray();
        }

        #region -- Main --

        private static TextReader reader;
        private static TextWriter writer;

        static void Main()
        {
#if DEBUG
            //reader = new StreamReader("..\\..\\input.txt");
            reader = new StreamReader(Console.OpenStandardInput());
            writer = Console.Out;
            //writer = new StreamWriter("..\\..\\output.txt");
#else
        reader = new StreamReader(Console.OpenStandardInput());
        writer = new StreamWriter(Console.OpenStandardOutput());
        //reader = new StreamReader("pluses.in");
        //writer = new StreamWriter("pluses.out");
#endif
            try
            {
                //var thread = new Thread(new Solver().Solve, 1024 * 1024 * 128);
                //thread.Start();
                //thread.Join();
                Solve();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
#if DEBUG
#else
            throw;
#endif
            }
            reader.Close();
            writer.Close();
        }

        #endregion
        #region -- Read / Write --

        private static Queue<string> currentLineTokens = new Queue<string>();

        private static string[] ReadAndSplitLine()
        {
            return reader.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }

        private static string[] ReadAndSplitLine(char divisor)
        {
            return reader.ReadLine().Split(new[] { divisor }, StringSplitOptions.RemoveEmptyEntries);
        }

        public static string ReadToken()
        {
            while (currentLineTokens.Count == 0) currentLineTokens = new Queue<string>(ReadAndSplitLine());
            return currentLineTokens.Dequeue();
        }

        public static int ReadInt()
        {
            return int.Parse(ReadToken());
        }

        public static long ReadLong()
        {
            return long.Parse(ReadToken());
        }

        //public static BigInteger ReadBigInteger()
        //{
        //    return BigInteger.Parse(ReadToken());
        //}

        public static double ReadDouble()
        {
            return double.Parse(ReadToken(), CultureInfo.InvariantCulture);
        }

        public static int[] ReadIntArray()
        {
            return ReadAndSplitLine().Select(int.Parse).ToArray();
        }

        public static bool[] ReadBoolArray()
        {
            return ReadAndSplitLine().ToString().ToCharArray().Select(chr => chr == '1').ToArray();
        }

        public static long[] ReadLongArray()
        {
            return ReadAndSplitLine().Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            return ReadAndSplitLine().Select(s => double.Parse(s, CultureInfo.InvariantCulture)).ToArray();
        }

        public static int[][] ReadIntMatrix(int numberOfRows)
        {
            int[][] matrix = new int[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++) matrix[i] = ReadIntArray();
            return matrix;
        }

        public static bool[][] ReadBoolMatrix(int numberOfRows)
        {
            bool[][] matrix = new bool[numberOfRows][];
            for (int i = 0; i < numberOfRows; i++)
                matrix[i] = ReadBoolArray();
            return matrix;
        }

        public static bool[][] TransposeBoolMatrix(bool[][] array, int numberOfRows)
        {
            bool[][] matrix = array;
            bool[][] ret = new bool[matrix[0].Length][];
            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = new bool[numberOfRows];
                for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i];
            }
            return ret;
        }

        public static int[][] ReadAndTransposeIntMatrix(int numberOfRows)
        {
            int[][] matrix = ReadIntMatrix(numberOfRows);
            int[][] ret = new int[matrix[0].Length][];
            for (int i = 0; i < ret.Length; i++)
            {
                ret[i] = new int[numberOfRows];
                for (int j = 0; j < numberOfRows; j++) ret[i][j] = matrix[j][i];
            }
            return ret;
        }

        public static string[] ReadLines(int quantity)
        {
            string[] lines = new string[quantity];
            for (int i = 0; i < quantity; i++) lines[i] = reader.ReadLine().Trim();
            return lines;
        }

        public static void WriteArray<T>(IEnumerable<T> array)
        {
            writer.WriteLine(string.Join(" ", array));
        }

        public static void Write(params object[] array)
        {
            WriteArray(array);
        }
        public static void WriteLines<T>(IEnumerable<T> array)
        {
            foreach (var a in array) writer.WriteLine(a);
        }
        private class SDictionary<TKey, TValue> : Dictionary<TKey, TValue>
        {
            public new TValue this[TKey key]
            {
                get { return ContainsKey(key) ? base[key] : default(TValue); }
                set { base[key] = value; }
            }
        }
        private static T[] Init<T>(int size) where T : new()
        {
            var ret = new T[size];
            for (int i = 0; i < size; i++) ret[i] = new T();
            return ret;
        }
        #endregion
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Pixels
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(System.Console.ReadLine());
            int min = Int32.MaxValue;

            int start = n / 2;
            int a = start, b = start;

            for(int i = n; i > 0; i--)
            {
                int j = i;
                while (i * j <= n)
                {
                    if (i * j == n)
                    {
                        if (min > b - a)
                        {
                            a = i;
                            b = j;
                            min = b - a;
                        }
                    }
                    j++;
                }
            }

            Console.WriteLine(String.Format("{0} {1}", a, b));
        }
    }
}


using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        var tokens = Console.ReadLine().Split(' ');
        Console.WriteLine(Solve(int.Parse(tokens[0]), int.Parse(tokens[1])));
    }

    static string Solve(int a, int k)
    {
        var stra = a.ToString().Select(c => c - '0').ToList();
        var b = "";

        while (stra.Count > 0)
        {
            var e = stra.Take(k + 1).Max();
            var ind = stra.IndexOf(e);
            b += e;
            k -= ind;
            stra.RemoveAt(ind);
        }
        return b;
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Pasha_Maximizes
{
    class Program
    {
        static void Main(string[] args)
        {
            IO io = new IO();
            string[] arr_Inputs = io.ReadStrArr();
            int[] arr_A = Array.ConvertAll<char, int>(arr_Inputs[0].ToCharArray(), s => int.Parse(s.ToString()));
            int i_K = int.Parse(arr_Inputs[1]);
            int i_Count =0;
            for (int i = 0; i_Count < i_K&&i<arr_A.Length-1; i++)
            {
                if (arr_A[i] < arr_A[i + 1])
                {
                    arr_A = Swap(arr_A, i, i + 1);
                    i_Count++;
                    i--;
                    i--;
                }
            }

            for (int i = 0; i < arr_A.Length; i++)
            {
                Console.Write(arr_A[i]);
            }
                io.ReadInt();

        }

        static int[] Swap(int[] arr, int i, int j)
        {
            int temp = arr[i];
            arr[i] = arr[j];
            arr[j] = temp;
            return arr;
        }
    }

    class IO
    {
        private static Queue<string> currentLineTokens = new Queue<string>();
        private static string[] ReadAndSplitLine()
        {
            return Console.ReadLine().Split(new[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
        }
        public int ReadNextInt()
        {
            return int.Parse(ReadToken());
        }
        public long ReadNextLong()
        {
            return long.Parse(ReadToken());
        }

        public int ReadInt()
        {
            return Convert.ToInt32(Console.ReadLine());
        }
        public long ReadLong()
        {
            return Convert.ToInt64(Console.ReadLine());
        }
        public string ReadStr()
        {
            return Console.ReadLine();
        }
        public string[] ReadStrArr()
        {
            return Console.ReadLine().Split(' ');
        }
        public int[] ReadIntArr()
        {
            return Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), s => int.Parse(s));
        }
        public long[] ReadLongArr()
        {
            return Array.ConvertAll<string, long>(Console.ReadLine().Split(' '), s => long.Parse(s));
        }
        public void PutStr(string str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(int str)
        {
            Console.WriteLine(str);
        }
        public void PutStr(long str)
        {
            Console.WriteLine(str);
        }

        public static string ReadToken()
        {
            while (currentLineTokens.Count == 0)
                currentLineTokens = new Queue<string>(ReadAndSplitLine());
            return currentLineTokens.Dequeue();
        }
    }
}


using System;
using System.IO;

namespace A
{
    class Program
    {
        private static void Main(string[] args)
        {
            using (var inputStream = Console.OpenStandardInput())
            using (var streamReader = new StreamReader(inputStream))
            {
                var firstLine = streamReader.ReadLine();
                var separator = new char[] {' '};
                var n = int.Parse(firstLine.Split(separator)[0]);
                var m = int.Parse(firstLine.Split(separator)[1]);

                var groups = new int[n];
                var strings = streamReader.ReadLine().Split(separator);
                if (strings.Length != n)
                {
                    throw new ArgumentException("Wrong group count");
                }

                for (int i = 0; i < strings.Length; i++)
                {
                    groups[i] = int.Parse(strings[i]);

                    if (groups[i] > m)
                    {
                        throw new ArgumentException("Invalid group size");
                    }
                }

                int busIndex = 0;
                int currentFreeSeats = m;
                int groupIndex = 0;
                while (groupIndex < groups.Length)
                {
                    var passengers = groups[groupIndex];

                    if (currentFreeSeats == 0)
                    {
                        currentFreeSeats = m;
                        busIndex++;
                    }

                    if (passengers <= currentFreeSeats)
                    {
                        currentFreeSeats -= passengers;
                        groupIndex++;
                    }
                    else
                    {
                        busIndex++;
                        currentFreeSeats = m;
                    }
                }

                using (var outputStream = Console.OpenStandardOutput())
                using (var streamWriter = new StreamWriter(outputStream))
                {
                    streamWriter.Write(busIndex + 1);
                }
            }
        }
    }
}


using System;

public class Test
{
    public static void Main()
    {
        // your code goes here
        string[] str = Console.ReadLine().Trim().Split();
        int k = int.Parse(str[1]);
        char[] chr = str[0].ToCharArray();

        {
        bool change =  false;

        for(int i = 0 ; i < chr.Length ; i++){
                if(k == 0)
                    break;
                int current = (int)chr[i] - (int)'0';
                int max = -1;
                int idx = -1;
                for(int j = 0 ; j < k && j + i + 1 < chr.Length; j++){
                    int m = (int)chr[i + j + 1] - (int)'0';
                if(m > current){
                    max = Math.Max(max,m);
                    if(max == m)
                         idx = j +i + 1;
                }
             }
             if(max != -1){
                int swap = idx - i;
                --Console.WriteLine(idx);
                if(swap <= k)

                    k = k - swap;
                    while(idx > i){
                    char tmp = chr[idx - 1];
                    //Console.WriteLine(tmp);
                    chr[idx - 1] = chr[idx];
                    chr[idx] = tmp;
                    idx--;
                    }
             }
          }

        }
        Console.WriteLine(new string(chr));
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Numerics;

namespace codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            var sa = Console.ReadLine().Split(' ').ToArray();
            var s = sa[0].ToCharArray();
            int k = int.Parse(sa[1]);
            int i = 0;
            while (k > 0 || i==s.Length-1)
            {
                int max = s[i], swap = i;
                for (int j = 1; j <= k; j++)
                {
                    if (max < s[i + j])
                    {
                        max = s[i + j];
                        swap = i + j;
                    }
                }
                if (max != s[i])
                {
                    Swap(ref s, i, swap);
                    k -= swap - i;
                }
                i++;
            }
            foreach (var a in s)
                Console.Write(a);
            //Console.ReadKey();
        }
        static void Swap(ref char[] s, int i, int j)
        {
            for (int x = j; x > i; x--)
            {
                char temp = s[x];
                s[x] = s[x - 1];
                s[x - 1] = temp;
            }
        }
        static bool isPrime(int n)
        {
            for (int i = 2; i <= Math.Sqrt(n); i++)
            {
                if (n % i == 0)
                    return false;
            }
            return true;
        }
        static int ReadInt()
        {
            return int.Parse(Console.ReadLine());
        }
        static int[] ReadIntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }
        static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
        static long[] ReadLongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }
        static int[][] ReadIntMatrix(int rows)
        {
            int[][] result = new int[rows][];
            for (int i = 0; i < rows; i++)
            {
                result[i] = ReadIntArray();
            }
            return result;
        }
        static int GCD(int a, int b)
        {
            if (Max(a, b) % Min(a, b) == 0)
                return Min(a, b);
            return GCD(Min(a, b), Max(a, b) % Min(a, b));
        }
        static int Min(int a, int b)
        {
            return a <= b ? a : b;
        }
        static int Max(int a, int b)
        {
            return a >= b ? a : b;
        }
        static double Distance(Point a, Point b)
        {
            return Math.Sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y));
        }
    }
    struct Point
    {
        public double x, y;
        public Point(int x, int y)
        {
            this.x = x;
            this.y = y;
        }
    }
}


using System;
using System.Linq;
using Helpers;

namespace Solution
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            //A435();

            var input = new InputPair<string>(Console.ReadLine());
            var b435 = new B435(input);
            Console.WriteLine(b435.Process());

            Console.ReadLine();
            Console.ReadLine();
        }

        private static void A435()
        {
            var firstRow = new InputPair<int>(Console.ReadLine());
            var secdRow = new InputList<int>(Console.ReadLine());

            int n = firstRow.Pair.Item1;
            int m = firstRow.Pair.Item2;

            int busNumber = 0;

            for (int i = 0; i < n; i++)
            {
                int total = secdRow.Items.ElementAt(i);

                int j = i;
                while (total < m)
                {
                    j++;
                    total += secdRow.Items.ElementAt(j);
                    if (total <= m)
                    {
                        i++;
                    }
                }
                busNumber += 1;
            }

            Console.WriteLine(busNumber);

            Console.ReadLine();
            Console.ReadLine();
        }
    }
}

namespace Solution
{
    public class B435
    {
        private readonly InputPair<string> _firstRow;

        public B435(InputPair<string> firstRow)
        {
            _firstRow = firstRow;
        }

        public string Process()
        {
            char[] itemArray = _firstRow.Pair.Item1.ToCharArray();
            int totalSwap = int.Parse(_firstRow.Pair.Item2);

            for (int i = 1; i < itemArray.Length; i++)
            {
                char currentItem = itemArray[i];
                for (int j = totalSwap; j > 0 && totalSwap > 0; j--)
                {
                    int swapToIndex = i - j;
                    if (swapToIndex < 0) continue;

                    char swapToItem = itemArray[swapToIndex];
                    if (currentItem > swapToItem)
                    {
                        itemArray = Shift(itemArray, i, swapToIndex);

                        totalSwap -= j;
                        break;
                    }
                }

                if (totalSwap == 0) break;
            }

            return new string(itemArray);
        }

        public char[] Shift(char[] array, int fromIndex, int toIndex)
        {
            char shifItem = array[fromIndex];
            for (int i = fromIndex; i > toIndex; i--)
                array[i] = array[i - 1];

            array[toIndex] = shifItem;

            return array;
        }
    }
}
namespace Helpers
{
    public class InputPair<T>
    {
        private readonly string _line;
        public Tuple<T, T> Pair;

        public InputPair(string line)
        {
            _line = line;
            //Items = new Tuple<T, T>(null,null);
            Process();
        }

        private void Process()
        {
            if (string.IsNullOrWhiteSpace(_line)) return;

            string[] items = _line.Split();
            Pair = new Tuple<T, T>(ConvertType(items[0]), ConvertType(items[1]));
        }

        private T ConvertType(string input)
        {
            return (T) Convert.ChangeType(input, typeof (T));
        }
    }
}


using System;
using System.Linq;
class Program
{
    public static void Swap<T>(ref T a, ref T b)
    {
        T temp = a;
        a = b;
        b = temp;
    }
    static void Main()
    {
        var a = Console.ReadLine().Split().Select(ulong.Parse).ToArray();
        var k = (int)a[1];
        var s = a[0].ToString().ToCharArray();
        int i;
        for (i = 0; k > 0 && i < s.Length; i++)
        {
            var id = Array.IndexOf(s, s.Max(), i, k);
            if (id > -1)
            {
                k -= id;
                Swap(ref s[i], ref s[id]);
            }
            else
            {
                break;
            }
        }
        var tmp = s.Skip(i).FirstOrDefault(c => c != '0');
        if (tmp != default(char))
        {
            var id = Array.IndexOf(s, tmp, i);
            while (k > 0)
            {
                if (s[id] > s[id - 1])
                {
                    Swap(ref s[id], ref s[id - 1]);
                    k--;
                    id--;
                }
                else
                {
                    break;
                }
            }
        }
        foreach (var item in s)
        {
            Console.Write(item);
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace lab11_1
{
    class Program
    {
        static string a = null;
        static int[] aa = new int[20];

        static void Main(string[] args)
        {
            int i, k;

            FillChar<int>(aa, 0);
            int f=1;

            int[] input = Console.ReadLine().Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(p => int.Parse(p)).ToArray<int>();
            a = input[0].ToString();
            k = input[1];

            int len = a.Length;
            for (i = 1; i <= len; i++) aa[i] = a[i - 1] - '0';

            while(k > 0)
            {
                int max = -1;
                int flag = 0;
                for(i = f; i <= f + k && i <= len; i++)
                {
                    if(max < aa[i])
                    {
                        max = aa[i];
                        flag = i;
                    }
                }
                for(i = flag; i > f; i--)
                {
                    int c = aa[i];
                    aa[i] = aa[i-1];
                    aa[i-1] = c;
                }
                k = k - flag + f;
                f++;
                if(f > len) break;
            }
            for(i = 1; i <= len; i++)
                Console.Write(aa[i]);
            Console.WriteLine();
        }
        public static void FillChar<T>(T[] array, T value)
        {
            for (int i = 0; i < array.Length; i++)
                array[i] = value;
        }
    }
}


using System;

namespace TestFSharpTranslation
{
    public class Program
    {
        public static int Main(string args)
        {
            int num = int.Parse(Console.ReadLine());
            object value;
            switch (num)
            {
                default:
                    value = ((num % 2 != 1) ? "YES" : "NO");
                    break;
                case 2:
                    value = "NO";
                    break;
            }
            Console.WriteLine((string)value);
            return 0;
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int w = Convert.ToInt32(Console.read());
            if (w <= 2)
            {
                Console.Write("NO");
            }
            else if (w % 2 == 0)
            {
                Console.Write("YES");
            }
            else
            {
                Console.Write("NO");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            bool anw;
            int w = Convert.ToInt16(Console.ReadLine());
            if (w < 4)
            {
                Console.WriteLine("NO");
            }
            else if (w%2 == 0)
            {
                Console.WriteLine("YES")
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Skrotowanie
{
    class Program
    {
        static void Main(string[] args)
        {
            var liczby = Console.ReadLine();
            var numbers = liczby.Split(' ');

            var m = double.Parse(numbers[0]);
            var n = double.Parse(numbers[1]);
            var a = double.Parse(numbers[2]);

            var liczba1 = Math.Ceiling(m / a);
            var liczba2 = Math.Ceiling(n / a);

            var wynik = liczba1 * liczba2;

            Console.WriteLine(Convert.ToInt64(wynik));
        }
    }
}


using System;
class watermelone
{
    void main()
    {
        sbyte w;
        w = Convert.ToSByte(Console.ReadLine());
        if (w % 2 == 0)
            Console.Write("Yes\n");
        else
            Console.Write("No\n");
        Console.ReadKey();
    }
}


using System;

namespace CodeForces
{
    class A4
    {
        static void Main()
        {
            Console.WriteLine(((float)weigh/2));
            if(((float)weigh/2)%2 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


using System;
class program
{
     Public static void Main()
     {
          int x = Convert.ToInt32(Console.ReadLine());
          if(x==2) Console.WriteLine("NO");
          else if(x%2==0) Console.WriteLine("YES");
          else Console.WriteLine("NO");
     }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CodeForcesTrain
{
    class Program
    {
        static void Main(string[] args)
        {
            int w;

            w = Convert.ToInt32(Console.ReadLine());
            w = w % 2;

            if (w != 0 || w = 2)
            {
                Console.WriteLine("NO");
            }
            else
            {
               Console.WriteLine("YES");
            }
        }
    }
}


class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("enter the weight of the watermelon : ");
            int n = int.Parse( Console.ReadLine());
            string res = (n % 4 == 0) ? " YES " :  " NO ";
            Console.WriteLine(res);
            Console.ReadLine();

        }
    }


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp114
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine()), otv= 0, i = 1;
            string name = "";
            while (n > 0)
            {
                if (i % 2 == 0)
                {
                    n -= 2;
                    name = "Mahmoud";
                }
                else
                {
                    n--;
                    name = "Ehab";
                }
                i++;
            }
            Console.WriteLine(name);
        }
    }
}


using System;
using System.Linq;
using System.Collections.Generic;

namespace AlgoTasks
{
    class Program
    {
        static void Main(string[] args)
        {
            //---------------------------------------------------------------------
            long n = long.Parse(Console.ReadLine());
            bool turn = false /*Махмуд*/;
            while(true)
            {
                if (!turn)
                {
                    if (n - 2 >= 0) n -= 2;
                    else
                    {
                        Console.WriteLine("Ehab");
                        return;
                    }
                    turn = true;
                }
                else
                {
                    if (n - 1 >= 0) n--;
                    else
                    {
                        Console.WriteLine("Mahmoud");
                        return;
                    }
                    turn = false;
                }
            }
            //---------------------------------------------------------------------
            /*int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

            //5
            //3 10 8 6 11
            //4
            //1
            //10
            //3
            //11

            //0
            //4
            //1
            //5

            x = new SortedSet<int>(x).ToArray();
            int maxPrice = x[n - 1];
            n = x.Length;
            int[] dp = new int[maxPrice + 1];
            int c = 1;
            for (int i = 0; i < n; i++)
                dp[x[i]] = c++;

            for (int i = 1; i <= maxPrice; i++)
                dp[i] = Math.Max(dp[i], dp[i - 1]);

            int q = int.Parse(Console.ReadLine());
            for (int i = 0; i < q; i++)
            {
                long m = long.Parse(Console.ReadLine());
                if (m >= maxPrice)
                    Console.WriteLine(dp[maxPrice]);
                else
                    Console.WriteLine(dp[m]);
            }*/
            //---------------------------------------------------------------------
        }
    }
}


using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace ConsoleApp1
{

    class Program
    {
        static void Main(string[] args)
        {
            //int numberOfFig = Convert.ToInt32(Console.ReadLine());
            //var figures = new string[numberOfFig];
            //for (int i = 0; i < numberOfFig; i++)
            //{
            //    figures[i] = Console.ReadLine();
            //}
            //var nums = Console.ReadLine().Split(' ');
            var num = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine(Check(Array.ConvertAll(nums, int.Parse)));
            Console.WriteLine(Check(num));
        }

        static string Check(int num)
        {

            if (num % 2 == 0)
            {
                return "Maxmoud";
            }

            return "Ehab";
            //bool maxmud = true;
            //while (true)
            //{
            //    if (maxmud && num >= 2)
            //    {
            //        num %= 2;
            //        maxmud = !maxmud;
            //    }
            //    else
            //    {
            //        return "Ehab";
            //    }

            //    if (!maxmud && num >= 1)
            //    {
            //        num -= 1;
            //        maxmud = !maxmud;
            //    }
            //    else
            //    {
            //        return "Mahmoud";
            //    }

            //}
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using System.Diagnostics;
using System.Numerics;
using static System.Console;
using static System.Convert;
using static System.Math;
using static Template;
using Pi = Pair<int, int>;

class Solver
{
    public void Solve(Scanner sc)
    {
        int a, ta, b, tb;
        sc.Make(out a, out ta, out b, out tb);
        var T = sc.Str.Split(':').Select(int.Parse).ToArray();
        int s = 60 * T[0] + T[1], t = 60 * T[0] + T[1] + ta;
        int st = 300, en = 24 * 60;
        var res = 0;
        for (int i = st; i < en; i += b)
        {
            if ((s <= i && i < t) || (s < i + tb && i + tb <= t)) res++;
        }
        WriteLine(res);
    }
}

#region Template
public static class Template
{
    static void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Solver().Solve(new Scanner());
        Console.Out.Flush();
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) > 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(ref T a, ref T b) { var t = b; b = a; a = t; }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public static void swap<T>(this IList<T> A, int i, int j) { var t = A[i]; A[i] = A[j]; A[j] = t; }
    public static T[] Create<T>(int n, Func<T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(); return rt; }
    public static T[] Create<T>(int n, Func<int, T> f) { var rt = new T[n]; for (var i = 0; i < rt.Length; ++i) rt[i] = f(i); return rt; }
    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> A) => A.OrderBy(v => Guid.NewGuid());
    public static int CompareTo<T>(this T[] A, T[] B, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; for (var i = 0; i < Min(A.Length, B.Length); i++) { int c = cmp(A[i], B[i]); if (c > 0) return 1; else if (c < 0) return -1; } if (A.Length == B.Length) return 0; if (A.Length > B.Length) return 1; else return -1; }
    public static int MaxElement<T>(this IList<T> A, Comparison<T> cmp = null) { cmp = cmp ?? Comparer<T>.Default.Compare; T max = A[0]; int rt = 0; for (int i = 1; i < A.Count; i++) if (cmp(max, A[i]) < 0) { max = A[i]; rt = i; } return rt; }
    public static T PopBack<T>(this List<T> A) { var v = A[A.Count - 1]; A.RemoveAt(A.Count - 1); return v; }
    public static void Fail<T>(T s) { Console.WriteLine(s); Console.Out.Close(); Environment.Exit(0); }
}
public class Scanner
{
    public string Str => Console.ReadLine().Trim();
    public int Int => int.Parse(Str);
    public long Long => long.Parse(Str);
    public double Double => double.Parse(Str);
    public int[] ArrInt => Str.Split(' ').Select(int.Parse).ToArray();
    public long[] ArrLong => Str.Split(' ').Select(long.Parse).ToArray();
    public char[][] Grid(int n) => Create(n, () => Str.ToCharArray());
    public int[] ArrInt1D(int n) => Create(n, () => Int);
    public long[] ArrLong1D(int n) => Create(n, () => Long);
    public int[][] ArrInt2D(int n) => Create(n, () => ArrInt);
    public long[][] ArrLong2D(int n) => Create(n, () => ArrLong);
    private Queue<string> q = new Queue<string>();
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public T Next<T>() { if (q.Count == 0) foreach (var item in Str.Split(' ')) q.Enqueue(item); return (T)Convert.ChangeType(q.Dequeue(), typeof(T)); }
    public void Make<T1>(out T1 v1) => v1 = Next<T1>();
    public void Make<T1, T2>(out T1 v1, out T2 v2) { v1 = Next<T1>(); v2 = Next<T2>(); }
    public void Make<T1, T2, T3>(out T1 v1, out T2 v2, out T3 v3) { Make(out v1, out v2); v3 = Next<T3>(); }
    public void Make<T1, T2, T3, T4>(out T1 v1, out T2 v2, out T3 v3, out T4 v4) { Make(out v1, out v2, out v3); v4 = Next<T4>(); }
    public void Make<T1, T2, T3, T4, T5>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5) { Make(out v1, out v2, out v3, out v4); v5 = Next<T5>(); }
    public void Make<T1, T2, T3, T4, T5, T6>(out T1 v1, out T2 v2, out T3 v3, out T4 v4, out T5 v5, out T6 v6) { Make(out v1, out v2, out v3, out v4, out v5); v6 = Next<T6>(); }
    //public (T1, T2) Make<T1, T2>() { Make(out T1 v1, out T2 v2); return (v1, v2); }
    //public (T1, T2, T3) Make<T1, T2, T3>() { Make(out T1 v1, out T2 v2, out T3 v3); return (v1, v2, v3); }
    //public (T1, T2, T3, T4) Make<T1, T2, T3, T4>() { Make(out T1 v1, out T2 v2, out T3 v3, out T4 v4); return (v1, v2, v3, v4); }
}
public class Pair<T1, T2> : IComparable<Pair<T1, T2>>
{
    public T1 v1;
    public T2 v2;
    public Pair() { }
    public Pair(T1 v1, T2 v2)
    { this.v1 = v1; this.v2 = v2; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2> p)
    {
        var c = Comparer<T1>.Default.Compare(v1, p.v1);
        if (c == 0)
            c = Comparer<T2>.Default.Compare(v2, p.v2);
        return c;
    }
    public override string ToString() => $"{v1.ToString()} {v2.ToString()}";
    public void Deconstruct(out T1 a, out T2 b) { a = v1; b = v2; }
}

public class Pair<T1, T2, T3> : Pair<T1, T2>, IComparable<Pair<T1, T2, T3>>
{
    public T3 v3;
    public Pair() : base() { }
    public Pair(T1 v1, T2 v2, T3 v3) : base(v1, v2)
    { this.v3 = v3; }

    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int CompareTo(Pair<T1, T2, T3> p)
    {
        var c = base.CompareTo(p);
        if (c == 0)
            c = Comparer<T3>.Default.Compare(v3, p.v3);
        return c;
    }
    public override string ToString() => $"{base.ToString()} {v3.ToString()}";
    public void Deconstruct(out T1 a, out T2 b, out T3 c) { Deconstruct(out a, out b); c = v3; }
}
#endregion


using System;

namespace _391A
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            char current = input[0];
            int count = 1;
            int res = 0;
            for (int i =1; i< input.Length; i++)
            {
                if(input[i] == current)
                {
                    count++;
                }
                else
                {
                    if(count % 2 == 0)
                    {
                        res++;
                    }
                    count = 1;
                }
                current = input[i];
            }
            Console.WriteLine(res);
        }
    }
}


using System;

namespace ConsoleApplication1
{
    public static class Problem391A
    {
        private static int Solve(string s)
        {
            var a = s[0];
            var b = 0;
            var d = 0;
            foreach (var c in s)
            {
                if (a == c)
                {
                    b++;
                }
                else
                {
                    if (b % 2 == 0) d++;
                    b = 1;
                }
                a = c;
            }

            return d;
        }

        private static void Run()
        {
            var a = Console.ReadLine();
            Console.WriteLine(Solve(a));
        }

        public static void Main(string[] args)
        {
            Problem391A.Run();
        }

    }
}


using System;

namespace Watermelon
{
    class Program
    {
        static void Main(string[] args)
        {
          Int64 input = Convert.ToInt64(Console.ReadLine());
          Int64 evenOdd = Convert.ToInt64(Math.Ceiling(input / 2));
          if((evenOdd % 2) == 0){
            Console.WriteLine("YES");
          }else{
            Console.WriteLine("NO");
          }
        }
    }
}


int input = Convert.ToInt32(Console.ReadLine());
Console.WriteLine(((input % 2 == 0) ? "YES" : "NO"));


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication13
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("enter w");
            int w = int.Parse(Console.ReadLine());
           if(w%2==0)
               Console.WriteLine("yes");
           else if(w==2)
               Console.WriteLine("no");
           else Console.WriteLine("no");
           console.read();
        }
    }
}


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {

           var a= Convert.ToInt32(textBox1.Text);
           var n = a % 2;
            if (n==0)
            {
                MessageBox.Show("Yes");
            }
            else
            {
                MessageBox.Show("NO");

            }

        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Watermelon
{
    class Program
    {
        static void Main(string[] args)
        {
            byte weight = short.Parse(Console.ReadLine());
            if (weight % 2 == 0)
            {
                Console.WriteLine("yes");
            }
            else
            {
                Console.WriteLine("no");
            }
        }
    }
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication6", "ConsoleApplication6\ConsoleApplication6.csproj", "{BF7F7577-72CC-48A4-92C5-021896A0A334}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{BF7F7577-72CC-48A4-92C5-021896A0A334}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{BF7F7577-72CC-48A4-92C5-021896A0A334}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{BF7F7577-72CC-48A4-92C5-021896A0A334}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{BF7F7577-72CC-48A4-92C5-021896A0A334}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
EndGlobal


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("enter the melon weight");
            string weight = Console.ReadLine();
            int w = Convert.ToInt16 (weight);
            while ( 1 <= w && w <= 100) {
            w = w % 2;
            if ( w == 0 ) {
                Console.WriteLine ("YES");

            }
            else {
                Console.WriteLine ("NO");
            }
            Console.ReadKey();
            }
        }
    }
}


    class Program
    {
        static void Main()
        {
            float x = Convert.ToInt32(Console.ReadLine());

            if (x%4==0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
            Console.ReadKey();
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace Learning
{
    class Program
    {
        static bool s_multiTest = false;
        static void Main(string[] args)
        {
            var o = Console.Out;
            var nTest = 1;
            if (s_multiTest)
            {
                nTest = NextInt();
            }

            for (int testId = 1; testId <= nTest; testId++)
            {
                Solve(testId, o);
            }
            Console.ReadLine();
        }
        static int MOD = (int)1e6 + 3;
        private static void Solve(int testId, TextWriter o)
        {
            var n = NextInt();
            long ans = recur(n);
            o.WriteLine(ans % MOD);
        }

        private static long recur(int n)
        {
            if (n == 1)
                return 1;
            long ans = 0;
            ans += ((recur(n - 1) % MOD) * 3) % MOD;
            return ans;
        }

        static int s_index = 0;
        static string[] s_tokens;
        private static string Next()
        {
            while (s_tokens == null || s_index == s_tokens.Length)
            {
                s_tokens = Console.ReadLine().Split(' ').ToArray();
                s_index = 0;
            }
            return s_tokens[s_index++];
        }

        private static int NextInt()
        {
            return Int32.Parse(Next());
        }

        private static long NextLong()
        {
            return Int64.Parse(Next());
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using CompLib.Util;
using System.Threading;
using CompLib.Mathematics;

public class Program
{
    private int N, X, Pos;

    public void Solve()
    {
        var sc = new Scanner();
        N = sc.NextInt();
        X = sc.NextInt();
        Pos = sc.NextInt();

        List<int> g = new List<int>();
        List<int> l = new List<int>();
        int left = 0;
        int right = N;
        while (left < right)
        {
            int middle = (left + right) / 2;
            if (middle <= Pos)
            {
                l.Add(middle);
                left = middle + 1;
            }
            else
            {
                g.Add(middle);
                right = middle;
            }
        }

        // x未満 len(l)-1個
        // x超過 len(g)個

        // のこりてきとう

        var c = new BinomialCoefficient(5000);
        ModInt ans = c.fact[X - 1] * c.ifact[(X - 1) - (l.Count - 1)];
        ans *= c.fact[N - X] * c.ifact[(N - X) - g.Count];
        ans *= c.fact[N - (l.Count + g.Count)];
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
    // public static void Main(string[] args) => new Thread(new Program().Solve, 1 << 27).Start();
}

// https://bitbucket.org/camypaper/complib
namespace CompLib.Mathematics
{
    #region ModInt

    /// <summary>
    /// [0,<see cref="Mod"/>) までの値を取るような数
    /// </summary>
    public struct ModInt
    {
        /// <summary>
        /// 剰余を取る値．
        /// </summary>
        public const long Mod = (int) 1e9 + 7;
        // public const long Mod = 998244353;

        /// <summary>
        /// 実際の数値．
        /// </summary>
        public long num;

        /// <summary>
        /// 値が <paramref name="n"/> であるようなインスタンスを構築します．
        /// </summary>
        /// <param name="n">インスタンスが持つ値</param>
        /// <remarks>パフォーマンスの問題上，コンストラクタ内では剰余を取りません．そのため，<paramref name="n"/> ∈ [0,<see cref="Mod"/>) を満たすような <paramref name="n"/> を渡してください．このコンストラクタは O(1) で実行されます．</remarks>
        public ModInt(long n)
        {
            num = n;
        }

        /// <summary>
        /// このインスタンスの数値を文字列に変換します．
        /// </summary>
        /// <returns>[0,<see cref="Mod"/>) の範囲内の整数を 10 進表記したもの．</returns>
        public override string ToString()
        {
            return num.ToString();
        }

        public static ModInt operator +(ModInt l, ModInt r)
        {
            l.num += r.num;
            if (l.num >= Mod) l.num -= Mod;
            return l;
        }

        public static ModInt operator -(ModInt l, ModInt r)
        {
            l.num -= r.num;
            if (l.num < 0) l.num += Mod;
            return l;
        }

        public static ModInt operator *(ModInt l, ModInt r)
        {
            return new ModInt(l.num * r.num % Mod);
        }

        public static implicit operator ModInt(long n)
        {
            n %= Mod;
            if (n < 0) n += Mod;
            return new ModInt(n);
        }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(ModInt v, long k)
        {
            return Pow(v.num, k);
        }

        /// <summary>
        /// 与えられた 2 つの数値からべき剰余を計算します．
        /// </summary>
        /// <param name="v">べき乗の底</param>
        /// <param name="k">べき指数</param>
        /// <returns>繰り返し二乗法により O(N log N) で実行されます．</returns>
        public static ModInt Pow(long v, long k)
        {
            long ret = 1;
            for (k %= Mod - 1; k > 0; k >>= 1, v = v * v % Mod)
                if ((k & 1) == 1)
                    ret = ret * v % Mod;
            return new ModInt(ret);
        }

        /// <summary>
        /// 与えられた数の逆元を計算します．
        /// </summary>
        /// <param name="v">逆元を取る対象となる数</param>
        /// <returns>逆元となるような値</returns>
        /// <remarks>法が素数であることを仮定して，フェルマーの小定理に従って逆元を O(log N) で計算します．</remarks>
        public static ModInt Inverse(ModInt v)
        {
            return Pow(v, Mod - 2);
        }
    }

    #endregion

    #region Binomial Coefficient

    public class BinomialCoefficient
    {
        public ModInt[] fact, ifact;

        public BinomialCoefficient(int n)
        {
            fact = new ModInt[n + 1];
            ifact = new ModInt[n + 1];
            fact[0] = 1;
            for (int i = 1; i <= n; i++)
                fact[i] = fact[i - 1] * i;
            ifact[n] = ModInt.Inverse(fact[n]);
            for (int i = n - 1; i >= 0; i--)
                ifact[i] = ifact[i + 1] * (i + 1);
            ifact[0] = ifact[1];
        }

        public ModInt this[int n, int r]
        {
            get
            {
                if (n < 0 || n >= fact.Length || r < 0 || r > n) return 0;
                return fact[n] * ifact[n - r] * ifact[r];
            }
        }

        public ModInt RepeatedCombination(int n, int k)
        {
            if (k == 0) return 1;
            return this[n + k - 1, k];
        }
    }

    #endregion
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            if (_index >= _line.Length)
            {
                string s;
                do
                {
                    s = Console.ReadLine();
                } while (s.Length == 0);

                _line = s.Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public string ReadLine()
        {
            _index = _line.Length;
            return Console.ReadLine();
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            string s = Console.ReadLine();
            _line = s.Length == 0 ? new string[0] : s.Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


using System;

namespace Arbuz
{
    class Program
    {
        static void Main(string[] args)
        {

            int a;
            Console.WriteLine("Арбус: ");
            a = int.Parse (Console.ReadLine());

            if (a % 2 == 0)
            {
                Console.WriteLine("YES");
            }
            else

            {
                Console.WriteLine("NO");
            }
            Console.ReadKey();

            int b;
            Console.WriteLine("Любая половина: ");
            b = int.Parse (Console.ReadLine());

            if (( b % 4 == 0) )
            {
                Console.WriteLine("YES");
            }
            else

            {
                Console.WriteLine("NO");
            }
            Console.ReadKey();
        }
    }
}


using System;

namespace Arbuz
{
    class Program
    {
        static void Main(string[] args)
        {

            int a;
            a = 7;
            a = int.Parse (Console.ReadLine());

            if (( a-4 % 2 == 0), a > 1)
            {
                Console.WriteLine("YES");
            }

            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


using System;
class Watermelon{
    static public void Main(){
        string tmp = Console.ReadLine();
        int n=int.parse(tmp);
        if(n%2==0)Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}


using System;
class Watermelon{
    static public void Main(){
        //string tmp = Console.ReadLine();
        int n=Console.ReadLine();//int.Parse(tmp);
        if(n%2==0&&n>2)Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}


using System;
class Watermelon{
    static public void Main(){
        string tmp;
        Console.ReadLine(tmp);
        int n=int.Parse(tmp);
        if(n%2==0&&n>2)Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}


Public string IsEvenNumber(int weight)
{
    if(weight % ==0)
    {
       return "YES";
    }

    else
    {
        return "NO";
    }
}


using System;
class Program{
    static void Main(string[] args){
        var mass = int.Parse(Console.ReadLine());
        if (mass < 4 || (mass-2)%2 !=0)) Console.Write("NO");
        else Console.Write("YES");
    }
}


using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;

namespace CSharp_Shell
{

    public static class Program
    {
        public static void Main()
        {
           int i = int.Parse(Console.ReadLine());
           if(i=!0)
           {
              if(i % 2==0)
              {
            	Console.WriteLine("yes");
              }
              else
              {
            	Console.WriteLine("no");
              }
           }
           else
           {
           	Console.WriteLine("yes");
           }
        }
    }
}


using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {

        static void Main(String[] args)
        {
            int w;

            w = Convert.ToInt32(Console.ReadLine());

            if (w % 2 == 0 && w>2)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}


using System;
using System.Text;

class Program
{
    static void Main(string[] args)
    {

        int weight = Convert.ToInt32(Console.ReadLine());

        if ( (weight % 2 == 0) && weight != 2)
        {0
            Console.Write("YES");
        }
        else
        {
            Console.Write("NO");
        }

        //Console.ReadKey();
    }
}


using System;
using System.IO;

class Program
{
    static void Main()
    {
        StreamReader sr = new StreamReader("input.txt");
        StreamWriter sw = new StreamWriter("output.txt");

        int a = Convert.ToInt32(sr.ReadLine());

        Algoritm instance = new Algoritm(a);

        sw.WriteLine(instance.Field);

        sw.Close();
        sw.Close();
    }
}

class Algoritm
{
    public string Field { get; set; }

    int c = 0;
    public Algoritm(int a)
    {
        if ((a % 2) == 0)
        {
            c = a / 2;
            if ((a % 2) == 0)
                Field = "YES";
            else
                Field = "NO";
        }
        else
            Field = "NO";
    }
}


class Program
    {

        static void Main(string[] args)
        {
            int input = int.Parse(Console.ReadLine());
            if(input%2 == 0)
            {
                Console.WriteLine("YES");
            }
            else{
                Console.WriteLine("NO");
            }

        }
    }


using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.IO;
using System.Net;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            string test = Console.ReadLine();
            if (Convert.ToInt32(test)%2 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


using System;

class Program
{
    static void Main()
    {
        int w=Convert.ToInt32(Console.ReadLine());
        if (w%2==1)
        {
            Console.WriteLine("NO");
        }
        else
        {
            if ((w/2)%2==0)
            {
                Console.WriteLine("YES");
            }
            else if ((((w-2)/2)%2==0)$$((w-2)!=0))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


using System;
using System.Data.SqlTypes;
using System.Net.Http;

namespace codeForces
{
    class Program
    {
        static void Main()
        {
            for (int i=0; i < 1 ; i++)
            {
                Watermelon();
            }
        }

        public static void Watermelon()
        {
            int w = Convert.ToInt32(Console.ReadLine());
            int x = w % 2;

            if (w == 2)
            {
                Console.Write("NO");
                goto next;
            }
            if (x == 0)
            {
                Console.Write("YES");
            }
            if (x != 0)
            {
                Console.Write("NO");
            }
            next:
        }
    }
}


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var a = Convert.ToInt32(Console.ReadLine());
			if(a%2==)
				Console.WriteLine("YES");
			else Console.WriteLine("NO");
		}
	}
}


int k = int.Parse(Console.Readline());
while(true){
	if(k%2==0){
		k/=2
	}
	else
		break;
}


Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30413.136
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "cf", "cf\cf.csproj", "{5D3406DD-5F03-4E9B-B861-254E453ED509}"
EndProject
Global
	GlobalSection(SolutionConfigurationPlatforms) = preSolution
		Debug|Any CPU = Debug|Any CPU
		Release|Any CPU = Release|Any CPU
	EndGlobalSection
	GlobalSection(ProjectConfigurationPlatforms) = postSolution
		{5D3406DD-5F03-4E9B-B861-254E453ED509}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
		{5D3406DD-5F03-4E9B-B861-254E453ED509}.Debug|Any CPU.Build.0 = Debug|Any CPU
		{5D3406DD-5F03-4E9B-B861-254E453ED509}.Release|Any CPU.ActiveCfg = Release|Any CPU
		{5D3406DD-5F03-4E9B-B861-254E453ED509}.Release|Any CPU.Build.0 = Release|Any CPU
	EndGlobalSection
	GlobalSection(SolutionProperties) = preSolution
		HideSolutionNode = FALSE
	EndGlobalSection
	GlobalSection(ExtensibilityGlobals) = postSolution
		SolutionGuid = {BFA2A156-5B5E-403B-BEBD-FA4972E0C310}
	EndGlobalSection
EndGlobal


using System;

namespace Watermelon800
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(w);
        }

        public static bool IsDividable(double w)
        {
            return ((w % 2) == 0) && (w / 2) % 2 == 0;
        }
    }
}


using System;

namespace Watermelon800
{
    class Program
    {
        static void Main(string[] args)
        {
            IsDividable(Convert.ToInt32(args[0]));
        }

        public static bool IsDividable(int w)
        {
            return ((w % 2) == 0) && (w / 2) % 2 == 0;
        }
    }
}


 static void Main(string[] args)
        {
            int w = int.Parse(Console.ReadLine());

                if (w % 2 == 0)
                {
                    Console.WriteLine("yes");
                }
                else
                {
                    Console.WriteLine("no");
                }

            }


using System;

class Program{
	static void Main(){
		string input = Console.ReadLine();
		int[] box = new int[10];
		int mul = 10;
		int ans = 1;

		for(int i = 0; i < input.Length; i++){
			if(i == 0)
				mul--;
			if(input[i] == '?'){
				ans *= 10;
			}
			if(input[i] >= 'A' && input[i] <= 'J'){
				if(box[input[i] - 'A'] == 0){
					ans *= mul;
					box[input[i] - 'A']++;
					mul--;
				}
			}
			if(i == 0)
				mul++;
		}

		Console.WriteLine(ans);
	}
}


using System;
using System.Collections.Generic;
using System.Linq;

namespace CodeForce
{
    class Program
    {
        static void Main(string[] args)
        {
            string helpString = args[0];
            //string helpString = "1?AA";

            string letters = "ABCDFGJ";

            List<int> counts = new List<int>();

             int max = 10;

            var first = helpString[0];

            if (letters.Contains(first))
            {
                if (helpString.Count(x => x == first) == 1)
                {
                    max -= 1;
                    counts.Add(max);
                    letters = letters.Replace(first, 'Y');
                }
                else
                {
                    max -= 1;
                    counts.Add(max);
                    letters = letters.Replace(first, 'Y');
                }

            }

            if (first == '?')
            {
                counts.Add(10);
            }

            for (int index = 1; index < helpString.Length; index++)
            {
                var symbol = helpString[index];
                if (symbol == '?')
                {
                    counts.Add(10);
                }
            }

            foreach (var symbol in letters)
            {
                if (letters.Contains(symbol) && helpString.Count(x => x == symbol) >= 1)
                {
                    counts.Add(max);
                    helpString = helpString.Replace(symbol, 'Z');
                    max -= 1;
                }
            }

            int output = counts.Aggregate(1, (current, count) => current*count);

            Console.WriteLine(output);

        }
    }
}