using System;
using System.Linq;

class Program
{
    private static void Main()
    {
        int result = 0;

        string n = Console.ReadLine() + Console.ReadLine();
        string p = Console.ReadLine();

        var nn = n.ToCharArray();
        var pp = p.ToCharArray();

        if (pp.Legnth < nn.Length)
        {
            Console.WriteLine("NO");
            return;
        }

        for(int i = 0; i < nn.Length; i++)
            for(int j = 0; j < pp.Length; j++)
                if (nn[i] == pp[j])
                {
                    pp[j] = '0';
                    break;
                }

        for(int i = 0; i < pp.Length; i++)
            if (pp[i] != '0')
            {
                Console.WriteLine("NO");
                return;
            }

        Console.WriteLine("YES");
    }

    private static int[] ConsoleReadLineAsArrayOfIntegers()
    {
        return Console.ReadLine().Split(' ').Select(n => Convert.ToInt32(n)).ToArray();
    }

    private static int ConsoleReadLineAsInteger()
    {
        return Convert.ToInt32(Console.ReadLine());
    }

    private static void ConsoleWriteLine(string line)
    {
        Console.WriteLine(line);
    }
}


using System;
using System.Linq;

namespace CF_141A
{
    class Program
    {
        static void Main()
        {
            var s = Console.ReadLine();
            s += Console.ReadLine();
            var sRes = Console.ReadLine();
            Console.WriteLine(string.Compare(string.Join("", s.OrderBy(x => x)), string.Join("", sRes.OrderBy(x => x))) == 0 ? "YES" : "NO");
        }
    }
}


import java.util.*;

public class JavaTutorial1 {

    public static void main(String[] args) {
     Scanner sc = new Scanner(System.in);
StringBuffer a = new StringBuffer(sc.nextLine());
StringBuffer b = new StringBuffer(sc.nextLine());
StringBuffer c = new StringBuffer(sc.nextLine());
    for(int i=0; i<a.length();i++) {
        for(int j=0; j<c.length();j++){
        if(a.charAt(i)==c.charAt(j)) {
        c.deleteCharAt(j);
        continue;
        }
            }
                }
    for(int i=0;i < b.length();i++) {
        for(int j=0;j<c.length();j++){
        if(b.charAt(i)==c.charAt(j)) {
        c.deleteCharAt(j);
        continue;
        }
            }
                }
    if(c.length()==0){
    System.out.println("YES");
    }
    else
    System.out.println("NO");
}
}


using System;
using System.Linq;

class Program {
  static void Main() {
    var s1 = Console.ReadLine() + Console.ReadLine().ToCharArray();
    var s2 = Console.ReadLine() + Console.ReadLine().ToCharArray();
    Console.WriteLine(s1.OrderBy(c => c).SequenceEquals(s2.OrderBy(c => c)) ?
          "YES" : "NO");
  }
}


using System;

public class Program
{
	public static void Main()
	{
		var name = new string[2];
		for (int i = 0; i < 2; i++)
		{
			name[i] = Console.ReadLine();
		}
		var door = Console.ReadLine();
		var dic = new Dictionary<char, int>();
		var letters = new int[26];
		for (int i = 0; i < 26; i++)
		{
			letters[i] = 0;
		}
		foreach (var item in name)
		{
			for (int i = 0; i < item.Length; i++)
			{
				++letters[item[i] - 'A'];
			}
		}
		for (int i = 0; i < door.Length; i++)
		{
			--letters[door[i] - 'A'];
		}
		Console.WriteLine(letters.Any(i => i != 0) ? "NO" : "YES");
	}
}


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

namespace HappyThing
{
    class Program
    {
        static void Main(string[] args)
        {
            string s1 = Console.ReadLine()+Console.ReadLine();
            string s2 = Console.ReadLine();
            bool ok = String.Join("", s1.OrderBy(o => o).ToArray()).Equals(String.Join("", s2.OrderBy(o => o).ToArray()), StringComparison.OrdinalIgnoreCase);
            if (ok == true)
            {
                Console.WriteLine("YES");
            }
            else { Console.WriteLine("NO"); }
        }
    }
}


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

namespace AmusingJoke
{
    class Program
    {
        static void Main(string[] args)
        {
            string name1 = Console.ReadLine();
            string name2 = Console.ReadLine();
            List<string> letters = Console.ReadLine().Select(x => x.ToString()).ToList<string>();
            foreach (char n in name1)
            {
                if (letters.Contains(n.ToString()))
                    letters.RemoveAt(letters.IndexOf(n.ToString()));
            }
            foreach (char n in name2)
            {
                if (letters.Contains(n.ToString()))
                    letters.RemoveAt(letters.IndexOf(n.ToString()));
            }
            Console.WriteLine(letters.Count == 0 ? "YES" : "NO");
            Console.ReadLine();
        }
    }
}


using System;
using System.Collections;
using System.Text;
namespace p2
{
    class Program
    {
        public static int Main(string[] args)
        {  string[] line =Console.ReadLine().Split();
            int x1,x2,x3,y1,y2,y3;
            x1=int.Parse(line[0]);
            x2=int.Parse(line[2]);
            x3=int.Parse(line[4]);
            y1=int.Parse(line[1]);
            y2=int.Parse(line[3]);
            y3=int.Parse(line[5]);
            double a,b,c;
            bool f=false
            ini(x1, x2, x3, y1, y2, y3,out a,out b,out c);
            if (pif(a,b,c)==true){Console.WriteLine("RIGHT");return 0;}

            Almost(x1, x2, x3, y1, y2, y3, a, b, c, f,out f);
            if(f==true){return 0;}
            Console.WriteLine( "NEITHER");
            //Console.ReadKey();
            return 0;
        }

        static void Almost(int x1, int x2, int x3, int y1, int y2, int y3, double a, double b, double c,out bool f)
        {
            ini(x1 + 1, x2, x3, y1, y2, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1 - 1, x2, x3, y1, y2, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2 + 1, x3, y1, y2, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2 - 1, x3, y1, y2, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2, x3 + 1, y1, y2, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2, x3 - 1, y1, y2, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2, x3, y1 + 1, y2, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2, x3, y1 - 1, y2, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2, x3, y1, y2 + 1, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2, x3, y1, y2 - 1, y3, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2, x3, y1, y2, y3 + 1, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            ini(x1, x2, x3, y1, y2, y3 - 1, out a, out b, out c);
            if (pif(a, b, c) == true) {
                Console.WriteLine("ALMOST");f=true;
                return 0;
            }
            return 0;
        }

        static void ini(int x1, int x2, int x3, int y1, int y2, int y3,out double a,out double b,out double c)
        {
            a = otr(x1, y1, x2, y2);
            b = otr(x2, y2, x3, y3);
            c = otr(x1, y1, x3, y3);
        }
        public static double otr(int a1,int b1,int a2,int b2){
            return ((a2-a1)*(a2-a1)+(b2-b1)*(b2-b1));
        }
        public static bool pif(double a,double b,double c){
            if(a+b-c==0) {return true;}
            if(a-b+c==0) {return true;}
            if(-a+b+c==0) {return true;}
            return false;}
    }
    }


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

namespace CodeForces1
{
    class Program
    {
        static bool isright(int[] x, int[] y)
        {
            if (x[0] == x[1] && y[0] == y[1]) return false;
            if (x[0] == x[2] && y[0] == y[2]) return false;
            if (x[2] == x[1] && y[2] == y[1]) return false;
            int a, b, c;
            a = (x[0] - x[1]) * (x[0] - x[1]) + (y[0] - y[1]) * (y[0] - y[1]);
            b = (x[2] - x[1]) * (x[2] - x[1]) + (y[2] - y[1]) * (y[2] - y[1]);
            c = (x[0] - x[2]) * (x[0] - x[2]) + (y[0] - y[2]) * (y[0] - y[2]);

            return (a + b == c || b + c == a || c + a == b);
        }
        static bool isalmostright(int[] x, int[] y)
        {
            int[] dx = { -1, 1, 0, 0 };
            int[] dy = { 0, 0, -1, 1 };
            for (int i = 0; i < 3; ++i)
            {
                for (int j = 0; j < 4; ++j)
                {
                    x[i] += dx[j];
                    y[i] += dy[j];
                    if (isright(x, y)) return true;
                    x[i] -= dx[j];
                    y[i] -= dy[j];
                }
            }
            return false;
        }
        public static void Main()
        {
            string[] t = Console.ReadLine().Split();
            int[] x = new int[3];
            int[] y = new int[3];
            for (int i = 0; i < 3; ++i)
            {
                x[i] = int.Parse(t[2 * i]);
                y[i] = int.Parse(t[2 * i + 1]);
            }

            if (isright(x, y)) { Console.WriteLine("RIGHT"); return; }
            if (isalmostright(x, y)) { Console.WriteLine("ALMOST"); return; }
            Console.WriteLine("NEITHER");
        }
    }


using System;
using System.Linq;
static class P {
    static int[] ToIntArray(this string val) { return val.Split().Select(int.Parse).ToArray(); }
    static double _exp = 0.0000001;
    static int[] _diff = new int[] { -1, 1 };
    static bool has(int[] arr) {
        int x0 = arr[0], y0 = arr[1], x1 = arr[2], y1 = arr[3], x2 = arr[4], y2 = arr[5];
        double a = (x0 - x1) * (x0 - x1) + (y0 - y1) * (y0 - y1),
            b = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2),
            c = (x2 - x0) * (x2 - x0) + (y2 - y0) * (y2 - y0);
        if (a == 0 || b == 0 || c == 0) return false;
        if (Math.Abs(a + b - c) <= _exp) { return true; }
        if (Math.Abs(a + c - b) <= _exp) { return true; }
        if (Math.Abs(c + b - a) <= _exp) { return true; }
        return false;
    }
    static void Main() {
        var line = Console.ReadLine().ToIntArray();
        if (has(line)) {
            Console.Write("RIGHT"); return;
        } else {
            int i = 0, j;
            for (; i < line.Length; ++i) {
                for (j = 0; j < _diff.Length; ++j) {
                    line[i] += _diff[j];
                    if (has(line) && ) {
                        Console.Write("ALMOST"); return;
                    } else { line[i] -= _diff[j]; }
                }
            }
        }
        Console.Write("NEITHER");
    }
}


 public class Program
    {
        private static void Main(string[] args)
        {
            var input = Console.ReadLine();

            var list = new List<Char>
            {
                'h',
                'e',
                'l',
                'l',
                'o'
            };

            for (int i = 0; i < input.Length; i++)
            {
                if (list.Count >= 1 && input[i] == list[0])
                {
                    list.RemoveAt(0);
                }
            }

            Console.WriteLine(list.Count == 0 ? "YES" : "NO");
        }
    }


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

namespace Rextester
{
    public class Program
    {
        public static void Main(string[] args)
        {
            byte h, e, l, o, = 0;
            char[] str = Console.ReadLine().ToCharArray();
            if (str.Length < 5)
            {
                Console.WriteLine("NO");
                return;
            }
            for (int i = 0; i < str.Length; i++)
            {
                if (h != 1)
                    h = 1;
                if (h == 1 && e != 1)
                    e = 1;
                if (h == 1 && e == 1 && l!=2)
                    l++;
                if (h == 1; e == 1; l == 2; o != 1)
                    o = 1;
            }
            if (h + e + l + O == 5)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}


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

namespace Test1
{
    public class Test1
    {
        public static void function()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int[] p = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();
            int[] b = Console.ReadLine().Split().Select(x => Convert.ToInt32(x)).ToArray();

            bool good = true;

            if (n % 2 != 0) { good = false; goto Result; }
            if (b.Length > 1)
            {
                for (int i = 1; i < b.Length; i++)
                {
                    p[b[i] - 1] = 0 - p[b[i] - 1];
                }
            }

            if (p[0] < 0) { good = false; goto Result; }
            bool[] used = new bool[p.Length];

            for (int i = 1; i < n; i++) // looking for negative numbers or "closing paranthesis"
            {
                if (p[i] < 0)
                {
                    bool pairFound = false;
                    List<int> range = new List<int>();
                    List<int> index = new List<int>();
                    for (int j = i - 1; j >= 0; j--) // finding a pair
                    {
                        if (!used[j])
                        {
                            if (p[i] == 0 - p[j])
                            {
                                if (range.Count > 0)
                                {
                                    if (range.Count % 2 == 0)
                                    {
                                        List<int> pairs = new List<int>();
                                        List<int> minus = new List<int>();
                                        for (int k = range.Count - 1; k >= 0; k--)
                                        {
                                            if (pairs.Count > 0) { if (pairs.Last() == range[k]) { minus.Add(index[k]); pairs.RemoveAt(pairs.Count - 1); } else { pairs.Add(range[k]); } }
                                            else { pairs.Add(range[k]); }
                                        }
                                        if (pairs.Count == 0)
                                        {
                                            pairFound = true;
                                            used[i] = used[j] = true;
                                            for (int m = 0; m < index.Count; m++) { used[index[m]] = true; }
                                            for (int s = 0; s < minus.Count; s++) { p[minus[s]] = 0 - p[minus[s]]; }
                                            break;
                                        }
                                    }
                                    else { range.Add(p[j]); index.Add(j); }
                                }
                                else { pairFound = true; used[i] = used[j] = true; break; }
                            }
                            else { range.Add(p[j]); index.Add(j); }
                        }
                    }
                    if (!pairFound) { good = false; goto Result; }
                }
            }

            List<int> remained = new List<int>();
            List<int> indexes = new List<int>();
            for (int i = 0; i < p.Length; i++)
            {
                if (!used[i]) { remained.Add(p[i]); indexes.Add(i); }
            }
            if (remained.Count > 0)
            {
                List<int> pair = new List<int>();
                for (int j = 0; j < remained.Count; j++)
                {
                    if (pair.Count > 0) { if (pair.Last() == remained[j]) { p[indexes[j]] = 0 - p[indexes[j]]; pair.RemoveAt(pair.Count - 1); } else pair.Add(remained[j]); }
                    else pair.Add(remained[j]);
                }
            }

        Result:
            {
                if (good)
                {
                    Console.WriteLine("YES");
                    foreach (int cc in p) { Console.Write(cc + " "); }
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
        public static void function1()
        {
            char[] brackets = Console.ReadLine().ToCharArray();
            int[] intBrackets = brackets.Select(x => (int)(x)).ToArray();
            int circle = 0, square = 0;
            List<int> stack = new List<int>();
            List<List<int>> groups = new List<List<int>>();
            int goodindex = 0;
            for (int i = 0; i < intBrackets.Length; i++)
            {
                if (stack.Count > 0)
                {
                    int dfrnc = intBrackets[i] - stack.Last();
                    if (dfrnc == 53 || dfrnc == -50)
                    {
                        if (square > 0 || circle > 0)
                        {
                            List<int> newlist = new List<int>() { square, circle, goodindex, square * 2 + circle * 2 };
                            groups.Add(newlist);
                            square = circle = 0;
                        }
                        stack.Clear();
                    }
                    else
                    {
                        if (dfrnc == 1) { circle++; stack.RemoveAt(stack.Count - 1); goodindex = i; continue; }
                        else if (dfrnc == 2) { square++; stack.RemoveAt(stack.Count - 1); goodindex = i; continue; }
                        else
                        {
                            stack.Add(intBrackets[i]);
                        }
                    }
                }
                else
                {
                    if (intBrackets[i] == 40 || intBrackets[i] == 91)
                    {
                        if (i != intBrackets.Length - 1)
                        {
                            stack.Add(intBrackets[i]);
                        }
                    }
                    else
                    {
                        if (square > 0 || circle > 0)
                        {
                            List<int> newlist = new List<int>() { square, circle, goodindex, square * 2 + circle * 2 };
                            groups.Add(newlist);
                            square = circle = 0;
                        }
                        stack.Clear();
                    }
                }
            }
            if (square > 0 || circle > 0) { List<int> newlist = new List<int>() { square, circle, goodindex, square * 2 + circle * 2 }; groups.Add(newlist); }
            int max = 0;
            int maxIndex = 0;
            if (groups.Count > 0)
            {
                for (int i = 0; i < groups.Count; i++)
                {
                    if (groups[i][0] > max) { max = groups[i][0]; maxIndex = i; }
                }
                int start = groups[maxIndex][2] - groups[maxIndex][3] + 1;
                int end = groups[maxIndex][2] + 1;
                Console.WriteLine(groups[maxIndex][0]);
                for (int i = start; i < end; i++) { Console.Write(brackets[i]); }
            }
            else Console.WriteLine("0");
        }
        public static void Main()
        {
            char[] input = Console.ReadLine().ToCharArray();
            List<char> letters = new List<char>();
            List<int> lcount = new List<int>();
            int cnt = 0;
            for (int i = 0; i < input.Length; i++)
            {
                if (letters.Count > 0)
                {
                    if (letters.Last() == input[i]) { cnt++; if (i == input.Length - 1) { lcount.Add(cnt); } }
                    else { lcount.Add(cnt); letters.Add(input[i]); cnt = 1; if (i == input.Length - 1) lcount.Add(cnt); }
                }
                else { letters.Add(input[i]); cnt++; }
            }

            string check = string.Join("", letters.ToArray());
            string hello = "helo";
            bool matchFound = false;
            if (letters.Count < 4) { goto Result; }
            else
            {
                for (int i = 0; i < letters.Count() - 3; i++)
                {
                    if (check.Substring(i, 4) == hello)
                    {
                        if (lcount[i + 2] >= 2) { matchFound = true; break; }
                    }
                }
            }
            Result:
                Console.WriteLine(matchFound ? "YES" : "NO");
        }
    }
}


using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Chat
{

  class ChattyBoy
  {

    static void Main(string[] args)
    {
      string s = Console.ReadLine();
      Regex condfilter = new Regex(s);
      if (condfilter.IsMatch("^\w*h*\w*e*\w*l{2,}\w*o*\w*$") == true)
        Console.WriteLine("YES");
      else Console.WriteLine("NO");

    }

  }

}


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

namespace Test1
{
    public class Test1
    {
        public static void Main()
        {
            char[] input = Console.ReadLine().ToCharArray();
            List<char> letters = new List<char>();
            List<int> lcount = new List<int>();
            int cnt = 0;
            for (int i = 0; i < input.Length; i++)
            {
                if (letters.Count > 0)
                {
                    if (letters.Last() == input[i]) { cnt++; if (i == input.Length - 1) { lcount.Add(cnt); } }
                    else { lcount.Add(cnt); letters.Add(input[i]); cnt = 1; if (i == input.Length - 1) lcount.Add(cnt); }
                }
                else { letters.Add(input[i]); cnt++; }
            }

            string check = string.Join("", letters.ToArray());
            string hello = "helo";
            bool matchFound = false;
            if (letters.Count < 4) { goto Result; }
            else
            {
                for (int i = 0; i < letters.Count() - 3; i++)
                {
                    if (check.Substring(i, 4) == hello)
                    {
                        if (lcount[i + 2] >= 2) { matchFound = true; break; }
                    }
                }
            }
            Result:
                Console.WriteLine(matchFound ? "YES" : "NO");
        }
    }
}


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

namespace CodeForces1
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] symbols = ['h', 'e', 'l', 'l', 'o'];
            string inputString = Console.ReadLine();

            int count = 0;

            foreach(char c in inputString)
            {
                if(count<5
                    && c == symbols[count])
                {
                    count++;
                }
            }

            Console.WriteLine(count == 5 ? "YES" : "NO");
        }
    }
}


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

namespace W0lf
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int z = 0;
            for(int i = 0; i < s.Length; i++)
            {
                if(z == 0 && s[i] == 'h') z++;
                if(z == 1)
                {
                    if(s[i] == 'e') z++;
                    else if(s[i] != 'h') z = 0;
                }
                if(z == 2)
                {
                    if(s[i] == 'l') z++;
                    else if(s[i] != 'e') z = 0;
                }
                if(z == 3)
                {
                    if(s[i] == 'l') z++;
                    else z = 0;
                }
                if(z == 4)
                {
                    if(s[i] == 'o')
                    {
                        Console.WriteLine("YES");
                        return;
                    }
                    else if(s[i] != 'l') z = 0;
                }
            }
            Console.WriteLine("NO");
            Console.ReadLine();
        }
    }


using System;
using System.Collections.Generic;
using System.Text;
using System.RegularExpressions;

namespace Chat
{

  class ChattyBoy
  {

    static void Main(string[] args)
    {
      string s = Console.ReadLine();
      Regex condfilter = new Regex(s);
      if (condfilter.IsMatch("^.*h*.*e*.l{2,}.*o*.*$") == true)
        Console.WriteLine("YES");
      else Console.WriteLine("NO");

    }

  }

}


using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;

namespace Chat
{

  class ChattyBoy
  {

    static void Main(string[] args)
    {
      string s = Console.ReadLine();
      Regex condfilter = new Regex(s);
      if (condfilter.IsMatch("^[a-z]*(hello)\1$") == true)
        Console.WriteLine("YES");
      else Console.WriteLine("NO");

    }

  }

}


using System;

class Program {
  static void Main() {
    var str = Console.ReadLine();
    var str2 = "hello";
    var i = 0;
    foreach (var c in str) if (c == str2[i])
      if (++i == str2.Length) { Console.WriteLine("YES"); return }
    Console.WriteLine("NO");
  }
}


    internal class Program
    {
        private static void Main(string[] args)
        {
            var word = "hello";
            var s = Console.ReadLine();
            var t = 0;
            var result = false;
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == word[t + 1])
                {
                    if (++t == word.Length - 1)
                    {
                        result = true;
                        break;
                    }
                }
                else if (s[i] != word[t])
                    t = 0;
            }

            Console.WriteLine(result ? "YES" : "NO");
        }
    }


using System;
using System.RegularExpressions;

namespace Chat
{

  class ChattyBoy
  {

    static void Main(string[] args)
    {
      string s = Console.ReadLine();
      Regex condfilter = new Regex(s);
      if (condfilter.IsMatch("^\w*h*\w*e*\w*l{2,}\w*o*\w*$") == true)
        Console.WriteLine("YES");
      else Console.WriteLine("NO");

    }

  }

}


using System;
namespace test{
    class Program{
        static void Main(string [] args){
            string text=Console.ReadLine();
            if(text.Length > 100 || text.Length < 1  ) return;

            char word =new char[]{'h','e','l','l','o'};
            int index=0,counter=0;
            foreach(char c in text.ToLower()){
                if(c == word[index]){
                    index++;
                    counter++;
                }
            }
            if(counter == word.Length)  Console.WriteLine("YES");
            else  Console.WriteLine("NO");

        }
    }
}


using System;
namespace test{
    class Program{
        static void Main(string [] args){
            string text=Console.ReadLine();
            if(text.Length > 100 || text.Length < 1  ) return ;

            char word ={'h','e','l','l','o'};
            int index=0,counter=0;
            foreach(char c in text.ToLower()){
                if(c == word[index]){
                    index++;
                    counter++;
                }
            }
            if(counter == word.Length)  Console.WriteLine("YES");
            else  Console.WriteLine("NO");

        }
    }
}


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

namespace Chat_Room___Guloso
{
    class Program
    {
        static void Main(string[] args)
        {
            /* Dada uma string s, formada por letras latinas minúsculas e contendo entre 1 e 100 letras,
             * determinar se é possível encontrar dentro dela a palavra “hello”, sem alterar a ordem.
             */
            Rodar();
        }

        static void Rodar()
        {
            string s = Console.ReadLine(); //entrada de dados
            Operacao.TesteChatRoom(s);
        }
    }

}


using System;

namespace CF_Hello {
    class Program {
        static void Main(string[] args) {
            string input = Console.ReadLine());
            string example = "hello";
            string output = string.Empty;
            int deleted = 0;
            for(int i=0;i<input.Length;i++) {
                if (input[i] == example[deleted]) {
                    output += input[i];
                    ++deleted;
                }
                if (deleted == 5) {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{68CD1BEE-E54A-4B06-86A4-71918E0386FE}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Chat_Room___Guloso</RootNamespace>
    <AssemblyName>Chat Room - Guloso</AssemblyName>
    <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Operacao.cs" />
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>


   class Program
    {

        public static string solution(string s)
        {
            string a = "hello";
            var counter = 0;
            for (int i = 0; i < s.Length; i++)
            {
                if (counter == 5)
                    return "Yes";

                if (s[i] == a[counter])
                    counter++;
            }
            if (counter == 5)
                return "Yes";
            return "No";

        }
        static void Main(string[] args)
        {
            var a = "ahhellllloou";
            Console.WriteLine(solution(args[0]));
            Console.ReadLine();
        }


using System;
using System.Collections.Generic;
using System.Text;
using System.RegularExpressions;

namespace Chat
{

  class ChattyBoy
  {

    static void Main(string[] args)
    {
      string s = Console.ReadLine();
      Regex condfilter = new Regex(s);
      if (condfilter.IsMatch("^\w*h*\w*e*\w*l{2,}\w*o*\w*$") == true)
        Console.WriteLine("YES");
      else Console.WriteLine("NO");

    }

  }

}


using System;

namespace ChatRoom
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine().ToLower();
            int counter = 0;
            string result = "NO";

            foreach (char chara in line)
            {
                if ((counter == 0 && chara == 'h')
                    || (counter == 1 && chara == 'e')
                    || ((counter == 2 || counter == 3) && chara == 'l'))
                {
                    counter++;
                    lastChar = chara;
                }
                else if (counter == 4 && chara == 'o')
                {

                    result = "YES";
                    break;
                }

            }

            Console.WriteLine(result);
        }
    }
}


using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            bool canHello = false;

            if (input.Contains('h'))
            {
                int index = input.IndexOf('h');
                string _input = input.Substring(index + 1);

                if (_input.Contains('e'))
                {
                    index = _input.IndexOf('e');
                    _input = _input.Substring(index + 1);

                    if (_input.Contains('l'))
                    {
                        index = _input.IndexOf('l');
                        _input = _input.Substring(index + 1);

                        if (_input.Contains('l'))
                        {
                            index = _input.IndexOf('l');
                            _input = _input.Substring(index + 1);

                            if (_input.Contains('o'))
                            {
                                canHello = true;
                            }
                        }
                    }
                }
            }

            if (canHello) System.Console.WriteLine("YES");
            else System.Console.WriteLine("NO");
        }

        static bool IsLuckyNumber(int number)
        {
            bool lucky = false;

            while (number != 0)
            {
                int lastDigit = LastDigit(number);
                number /= 10;

                if (lastDigit != 4 || lastDigit != 7) return false;
                else lucky = true;
            }

            if (lucky) return lucky;

            for (int i = number-1; i > 0; i--)
            {
                if (number % i == 0 && IsLuckyNumber(i))
                    return true;
            }

            return false;
        }

        static int LastDigit(int number)
        {
            return 0;
        }

        static char ToLower(char c)
        {
            return (c >= 'A' && c <='Z') ? (char)(c + 32) : c;
        }

        static bool Contains(char[] arr, char c)
        {
            foreach (char x in arr)
            {
                if (x == c) return true;
            }

            return false;
        }
    }
}


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

namespace YOLO
{
    class Program
    {
        static void Main(string[] args)
        {
            string x;
            x = Console.ReadLine();
            char[] cth = { 'h', 'e', 'l', 'l', 'o' };

            int index=0;
            for(int i=0; i<x.Length; i++){
                if(index==5){
                    break;
                }
                if(Char.ToLower(x[i])==cth[index]){
                    index++;
                }
                else if(Char.ToLower(x[i]==cth[index-1]) && index>0){
                    continue;
                }
                else{
                    index = 0;
                }
            }

            if(index==5){
                Console.Write("YES");
            }
            else{
                Console.Write("NO");
            }

        }
    }
}


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

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

            int l;
            string str=Console.ReadLine();
            string []str2=str.Split(' ');

           int n=Convert.ToInt32(str2[0]);

             int k=Convert.ToInt32(str2[1]);
            int[] a=new int [n];

            string

            int s=0;
            for (l = 0; l < k; l++)
            {
                int one = 0;
                int two = 0;
                for (int i = 0; i < n; i = i + k)
                    if (a[i + l] == 1)
                        one++;
                    else
                        two++;
                int min = one > two ? two : one;
                s = s + min;
            }
            Console.WriteLine(s);
            Console.ReadLine();

        }
    }
}


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

class Solution
    {
        static void Main(string[] args)
        {
            new FriendsMeeting().Solve();
            Console.ReadLine();
        }
    }

public class FriendsMeeting : ISolution
    {
        public override void Solve()
        {
            var a1 = ReadInt();
            var b1 = ReadInt();
            var a = Math.Min(a1, b1);
            var b = Math.Max(a1, b1);
            var dist = Math.Abs(b - a);
            Console.WriteLine(Math.Min(distance(dist), distance((b - (int)Math.Floor((double)(a + b) / 2))) + distance(((int)Math.Floor((double)(a + b) / 2) - a))));
        }

        public int distance(int k)
        {
            return (k * (k + 1) / 2);
        }
    }


<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectGuid>{CA709FE1-A7B9-416E-8ACA-32B55CB0CB31}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <RootNamespace>Olimp</RootNamespace>
    <AssemblyName>Olimp</AssemblyName>
    <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
    <FileAlignment>512</FileAlignment>
    <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug\</OutputPath>
    <DefineConstants>DEBUG;TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <PlatformTarget>AnyCPU</PlatformTarget>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Program.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  </ItemGroup>
  <ItemGroup>
    <None Include="App.config" />
  </ItemGroup>
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>


int m = c * p;
                int n = m / (d - p);
                int di = n * d;
                if(di<dic)
                {
                    int i = di / p;
                    c = i + f + (di / d);
                    opp++;
                }
                else
                {
                    break;
                }


using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ReadLine();
			int n = 5; //Convert.ToInt32(Console.ReadLine());
            int[] a = new int[n];
            int s,er;
            int t = 0;
            int jami = 0;
            for (int i = 0; i < n; i++)
            {
				Console.ReadLine()
                //a[i] = Convert.ToInt32(Console.ReadLine());
                jami += a[i];

            };
			a[0]=1;
			a[1]=0;
			a[2]=0;
			a[3]=1;
			a[4]=0;

            s = jami;
            for (int i = 0; i < n; i++)
            {
                jami = s;
                if (a[i] == 0)
                {
                    jami += 1;
                }
                if (a[i] == 1)
                {
                    jami -= 1;
                }
                for (int j = i + 1; j < n; j++)
                {
                    if (a[j] == 0)
                    {
                        jami += 1;
                    }
                    if (a[j] == 1)
                    {
                        jami -= 1;
                    }
                    if (jami > t)
                    {
                        t = jami;
                    }

                }
            }

            Console.WriteLine(t);

        }
    }
}


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

class Program
    {
static int Main()
        {
  string l1 = Console.ReadLine();
            int n = int.Parse(l1);
            int[] inputs = new int[n];

            string l2 = Console.ReadLine();
            string[] inpS = l2.Split(' ');

            int OrigTotal1s = 0;
            for (int i = 0; i < n; i++)
            {
                inputs[i] = int.Parse(inpS[i]);
                if (inputs[i] == 1)
                {
                    OrigTotal1s++;
                }
            }

            int delta = -1;
            int maxdelta = -1;
            int nums0 = 0;
            int nums1 = 0;

            for (int i = 0; i < n - 1; i++)
            {
                nums0 = 0; nums1 = 0;
                if (inputs[i] == 0)
                {
                    nums0++;
                    for (int j = i + 1; j < n; j++)
                    {
                        if (inputs[j] == 1)
                        {
                            nums1++;
                        }
                        else nums0++;

                        delta = nums0 - nums1;

                        if (delta > maxdelta)
                        {
                            maxdelta = delta;
                        }

                    }
                }
            }

            Console.Write(OrigTotal1s + maxdelta);
        }
}


using System;
using System.Collections.Generic;
using System.Linq;
namespace rapidPrograming
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Console.ReadLine();
            var nums = Console.ReadLine().Split().Select((s) => Convert.ToInt32(s)).ToList();
            var max = 0;
            for(int i = nums.Count; i > 0; i--)
            {
                for(int j = 0; j <= nums.Count-i; j++)
                {
                   // Console.WriteLine($"{j},{i}");
                    var nums2 = nums.GetRange(j, i).Select(n => n == 0 ? 1:0).ToList() ;
                    var before = nums.GetRange(0, j);
                    var after = nums.GetRange(j + i, nums.Count - nums2.Count-before.Count);
                    var count= nums2.Count(ni => ni == 1)+ before.Count(ni => ni == 1)+ after.Count(ni => ni == 1);
                    if (count > max)
                    {
                        max = count;
                    }
                }

            }
            Console.WriteLine(max);
        }
    }
}


/*
There are n integers a1, a2, ..., an. Each of those integers can be either 0 or 1. We are allowed to do exactly one move: We must choose two indices i and j (1 <= i <= j <= n) and flip all values ak for which their positions are in range [i, j] (that is i <= k <= j). Flip the value of x means to apply operation x = 1 - x.

The goal is - After exactly one move to obtain the maximum number of ones.

Input:-

The first line of the input contains an integer n (1 <= n <= 10^6). In the second line of the input there are n integers: a1, a2, ..., an. It is guaranteed that each of those n values is either 0 or 1

Output:-
Print an integer - the maximal number of 1s that can be obtained after exactly one move.

Sample test(s)
input
5
1 0 0 1 0
output
4

input
4
1 0 0 1
output
4

Note:-
In the first case, flip the segment from 2 to 5 (i=2, j=5). That flip changes the sequence, it becomes: [1 1 1 0 1]. So, it contains four ones. There is no way to make the whole sequence equal to [1 1 1 1 1].

In the second case, flipping only the second and the third element (i=2, j=3) will turn all numbers into 1.

Source: http://codeforces.ru/problemset/problem/327/A
*/

using System;

namespace FlippingGame327A
{
    class Program
    {
        int kkMax(int a, int b)
        {
            return (a < b) ? b : a;
        }

        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            int n = Convert.ToInt32(str);
            str = Console.ReadLine();
            string[] strArray = str.Split(' ');
            int[] input = new int[n + 3];
            int sum = 0;
            for (int i = 0; i < n; i++)
            {
                input[i] = Convert.ToInt32(strArray[i]);
                if (input[i] == 1)
                {
                    sum++;
                }
            }

            // main logic
            // O(n) solution... it is a version of 'maximum subarray problem' which can be solved using Kadane's Algorithm
            int ans = (input[0] == 1) ? -1 : 1;
            int ends = ans;
            for (int i = 1; i < n; i++)
            {
                int temp = 1;
                if (input[i] == 1)
                {
                    temp = -1;
                }

                ends = kkMax(temp, ends + temp);
                ans = kkMax(ans, ends);
            }
            Console.WriteLine(sum + ans);
            /*
            // O(n^2) solution
            int[,] res = new int[n, n];
            int ans = Int32.MinValue;
            for (int i = 0; i < n; i++)
            {
                int zeros = 0;
                for (int j = i; j < n; j++)
                {
                    if (input[j] == 0)
                    {
                        zeros++;
                        res[i, j] = zeros;
                    }
                    int temp = sum - (j - i + 1 - res[i, j]) + res[i, j];
                    ans = (temp > ans) ? temp : ans;
                }
            }
            Console.WriteLine(ans);
            Console.ReadLine();
            */
        }
    }
}


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

namespace COJ
{
    class Program
    {
        /*
         * Author: Luismo
         * Idea: BinarySearch + DFS
         *
         * */

        static void Main(string[] args)
        {
            TextReader tr = Console.In;
           // Console.SetIn(new StreamReader(@"d:\lmo.in"));

            SolveSingleProblem();

            Console.SetIn(tr);
            Console.ReadLine();

            //string[] data = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
        }

        static List<Interval> intervals;
        static void SolveSingleProblem()
        {
            int n = int.Parse(Console.ReadLine());
            int[] arr = new int[n];
            string[] data = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

            int firstZ = -1;
            int totalOnes = 0;

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

                if (arr[i] == 0)
                {
                    if(firstZ==-1)
                        firstZ = i;
                }
                else totalOnes++;
            }
            //
            int zeroes = 0, ones = 0, max =0, cnt=0;
            for (int i = firstZ; i < arr.Length; i++)
            {
                if (arr[i] == 0)
                    zeroes++;
                else ones++;

                if (zeroes - ones > max)
                {
                    max = zeroes - ones;
                    cnt = zeroes - ones + totalOnes - ones;
                }
            }

            Console.WriteLine(cnt);

        }

    }

}


using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
string s_n ;
s_n=Console.ReadLine();
            Console.WriteLine(s_n);

            int n = 5;
            int[] a = new int[n];
string s_a[]=new string [n];
            int s;
            int t = 0;
            int jami = 0;
            for (int i = 0; i < n; i++)
            {
                s_a[i] = Console.ReadLine();
                //jami += a[i];
 Console.WriteLine( s_a[i]);
            }
return;
            s = jami;
            for (int i = 0; i < n; i++)
            {
                jami = s;
                if (a[i] == 0)
                {
                    jami += 1;
                }
                if (a[i] == 1)
                {
                    jami -= 1;
                }
                for (int j = i + 1; j < n; j++)
                {
                    if (a[j] == 0)
                    {
                        jami += 1;
                    }
                    if (a[j] == 1)
                    {
                        jami -= 1;
                    }
                    if (jami > t)
                    {
                        t = jami;
                    }

                }
            }

            Console.WriteLine(t);

        }
    }
}


using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Text;

namespace Codeforces
{
    class Program
    {
        private static string readString() => Console.ReadLine();
        private static T readValue<T>() => (T)Convert.ChangeType(readString(), typeof(T));
        private static string[] readStrings(char delimiter = ' ') => readString().Split(delimiter);
        private static List<T> readValues<T>(char delimiter = ' ') => readStrings(delimiter: delimiter).Select(x => (T)Convert.ChangeType(x, typeof(T))).ToList();
        private static void write<T>(T s) => Console.WriteLine(s);

        private static int binarySearch<T>(List<T> list, T target) where T : IComparable
        {
            int l = 0, r = list.Count - 1;
            while (l <= r)
            {
                var m = (int)Math.Floor((double)(l + r) / 2);
                if (list[m].CompareTo(target) <= 0)
                    if (m == r || list[m + 1].CompareTo(target) > 0)
                        return m;
                    else
                        l = m + 1;
                else
                    r = m - 1;
            }
            return -1;
        }

        private static int quickSortPartition<T>(List<T> a, int lo, int hi) where T : IComparable
        {
            var pivot = a[lo];
            int i = lo - 1, j = hi + 1;
            while (true)
            {
                do { i++; } while (a[i].CompareTo(pivot) < 0);
                do { j--; } while (a[j].CompareTo(pivot) > 0);
                if (i >= j)
                    return j;
                var temp = a[i];
                a[i] = a[j];
                a[j] = temp;
            }
        }
        private static void quickSort<T>(List<T> a, int lo, int hi) where T : IComparable
        {
            if (lo < hi)
            {
                int q = quickSortPartition(a, lo, hi);
                quickSort(a, lo, q);
                quickSort(a, q + 1, hi);
            }
        }
        private static void quickSort<T>(List<T> a) where T : IComparable => quickSort(a, 0, a.Count - 1);

        private static void watermelon()
        {
            var w = readValue<int>();
            write(w >= 4 && w % 2 == 0 ? "YES" : "NO");
        }
        private static void wayTooLongWords()
        {
            var words = new List<string>();

            var n = readValue<int>();
            for (int i = 0; i < n; ++i)
                words.Add(readString());

            foreach (var word in words)
                write(word.Length <= 10 ? word : $"{word.First()}{word.Length - 2}{word.Last()}");
        }
        private static void team()
        {
            int solve = 0;

            var n = readValue<int>();
            for (int i = 0; i < n; ++i)
                if (readValues<int>().Where(x => x == 1).Count() > 1)
                    ++solve;

            write(solve);
        }
        private static void football()
        {
            var positions = readString();
            for (int i = 6; i < positions.Length; ++i)
                if (positions.Substring(i - 6, 6) == (positions[i] == '0' ? "000000" : "111111"))
                {
                    write("YES");
                    return;
                }
            write("NO");
        }
        private static void theatreSquare()
        {
            var sizes = readValues<int>();
            write((long)Math.Ceiling((double)sizes[0] / (double)sizes[2]) * (long)Math.Ceiling((double)sizes[1] / (double)sizes[2]));
        }
        private static void stringTask()
        {
            var Vowels = new HashSet<char> { 'a', 'o', 'y', 'e', 'u', 'i' };
            var sb = new StringBuilder();
            var s = readString().ToLower();
            foreach (var c in s)
                if (!Vowels.Contains(c))
                {
                    sb.Append('.');
                    sb.Append(c);
                }

            write(sb.ToString());
        }
        private static void taxi()
        {
            int taxis = 0;
            var groups = new Dictionary<int, int> { { 1, 0 }, { 2, 0 }, { 3, 0 } };

            readValue<int>();
            var groupSizes = readValues<int>();
            foreach (var size in groupSizes)
                if (size == 4)
                    ++taxis;
                else
                    groups[size] = groups[size] + 1;

            taxis += groups[3];
            groups[1] = groups[1] - Math.Min(groups[1], groups[3]);

            taxis += groups[2] / 2;
            if (groups[2] % 2 == 1)
            {
                ++taxis;
                groups[1] = groups[1] - 2;
            }

            if (groups[1] > 0)
                taxis += (int)Math.Ceiling((double)groups[1] / 4.0);

            write(taxis);
        }
        private static void fancyFence()
        {
            var a = readValue<int>();
            for (double i = 3.0; ; i += 1.0)
            {
                var x = (double)(i - 2.0) * 180.0 / i;
                if (a <= x)
                {
                    write(a < x ? "NO" : "YES");
                    break;
                }
            }
        }
        private static void interestingDrink()
        {
            readString();
            var prices = readValues<int>().OrderBy(x => x).ToList();
            var days = readValue<int>();
            for (int i = 0; i < days; ++i)
                write(binarySearch(prices, readValue<int>()) + 1);
        }
        private static void compilationErrors()
        {
            readString();
            Dictionary<int, int> errors = readValues<int>().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count()), errors1 = new Dictionary<int, int>();
            foreach (var error in readValues<int>())
            {
                if (errors[error] > 1)
                    errors[error] = errors[error] - 1;
                else
                    errors.Remove(error);

                if (errors1.TryGetValue(error, out var count))
                    errors1[error] = count + 1;
                else
                    errors1.Add(error, 1);
            }
            write(errors.First().Key);

            foreach (var error in readValues<int>())
                if (errors1[error] > 1)
                    errors1[error] = errors1[error] - 1;
                else
                    errors1.Remove(error);
            write(errors1.First().Key);
        }
        private static void doubleCola()
        {
            var idToName = new Dictionary<int, string> { { 0, "Sheldon" }, { 1, "Leonard" }, { 2, "Penny" }, { 3, "Rajesh" }, { 4, "Howard" } };
            int n = readValue<int>(), i = 1;
            for (; n > i * 5; i *= 2)
                n -= i * 5;
            write(idToName[(n - 1) / i]);
        }
        private static void ilyaAndQueries()
        {
            var dic = new Dictionary<int, int>();
            var list = new List<Tuple<int, int>>();

            var s = readString();
            int start = 0, dicStart = 0;
            for (int j = 0; j < s.Length - 1; ++j)
                if (s[j] != s[j + 1])
                {
                    if (start < j)
                    {
                        list.Add(new Tuple<int, int>(start + 1, j + 1));
                        for (; dicStart < j + 1; ++dicStart)
                            dic.Add(dicStart, list.Count - 1);
                    }
                    start = j + 1;
                }
            if (start < s.Length - 1)
            {
                list.Add(new Tuple<int, int>(start + 1, s.Length));
                for (; dicStart < s.Length; ++dicStart)
                    dic.Add(dicStart, list.Count - 1);
            }

            var m = readValue<int>();
            for (int j = 0; j < m; ++j)
            {
                var q = readValues<int>();
                int l = q[0], r = q[1], result = 0;
                if (dic.TryGetValue(l, out var i))
                    for (; i < list.Count && r >= list[i].Item1; ++i)
                        if (l < list[i].Item2)
                            result += Math.Min(r, list[i].Item2) - Math.Max(l, list[i].Item1);
                write(result);
            }
        }
        private static void twoTeamsComposing()
        {
            var n = readValue<int>();
            var skills = readValues<int>().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
        }
        #region Laptop
        private class Laptop
        {
            internal int Price { get; private set; }
            internal int Quality { get; private set; }
            internal Laptop(List<int> values)
            {
                Price = values[0];
                Quality = values[1];
            }
        }
        private class Laptop_Comparer_Price : Comparer<Laptop>
        {
            public override int Compare([AllowNull] Laptop x, [AllowNull] Laptop y) => x.Price - y.Price;
        }
        private class Laptop_Comparer_Quality : Comparer<Laptop>
        {
            public override int Compare([AllowNull] Laptop x, [AllowNull] Laptop y) => x.Quality - y.Quality;
        }
        private static void laptops()
        {
            List<Laptop> prices = new List<Laptop>(), qualities = new List<Laptop>();
            var n = readValue<int>();
            for (int i = 0; i < n; ++i)
            {
                var laptop = new Laptop(readValues<int>());
                prices.Add(laptop);
                qualities.Add(laptop);
            }

            for (int i = 0; i < n; ++i)
                if (prices[i] != qualities[i])
                {
                    write("Happy Alex");
                    return;
                }
            write("Poor Alex");
        }
        #endregion
        private static void fence()
        {
            int k = readValues<int>()[1], minI = 0, currentH = 0;
            var h = readValues<int>();

            for (int i = 0; i < k; ++i)
                currentH += h[i];
            var minH = currentH;

            for (int i = 1; i < h.Count - k + 1; ++i)
            {
                currentH = currentH - h[i - 1] + h[i + k - 1];
                if (minH > currentH)
                {
                    minH = currentH;
                    minI = i;
                }
            }

            write(minI + 1);
        }
        #region serejaAndSuffixes
        private class SerejaL : IComparable
        {
            internal int L { get; private set; }
            internal int Result;
            internal SerejaL(int l)
            {
                L = l;
            }

            public int CompareTo(object obj) => L - ((SerejaL)obj).L;
        }
        private static void serejaGetLs(int m, out List<SerejaL> listDistinct, out List<SerejaL> listOrdered)
        {
            listDistinct = new List<SerejaL>();
            listOrdered = new List<SerejaL>();
            var dic = new Dictionary<int, SerejaL>();
            for (int i = 0; i < m; ++i)
            {
                var l = readValue<int>() - 1;
                if (!dic.TryGetValue(l, out var item))
                {
                    item = new SerejaL(l);
                    dic.Add(l, item);
                    listDistinct.Add(item);
                }
                listOrdered.Add(item);
            }
            quickSort(listDistinct);
        }
        private static void serejaAndSuffixes()
        {
            var m = readValues<int>()[1];
            var a = readValues<int>();
            serejaGetLs(m, out var listDistinct, out var listOrdered);

            var distinct = new HashSet<int>();
            for (int i = listDistinct.Count - 1, j = a.Count - 1; i >= 0; --i)
            {
                for (; j >= listDistinct[i].L; --j)
                    if (!distinct.Contains(a[j]))
                        distinct.Add(a[j]);

                listDistinct[i].Result = distinct.Count;
            }

            foreach (var item in listOrdered)
                write(item.Result);
        }
        #endregion
        private static void bowWowTimetable()
        {
            string s = readString(), r = "1";
            int i = 1;
            for (; r.Length < s.Length; ++i, r = r + "00") ;
            if (r.Length > s.Length || !s.Substring(1).Contains('1'))
                write(i - 1);
            else
                write(i);
        }
        private static void digits()
        {
            readString();
            var numbers = readValues<int>().GroupBy(x => x).ToDictionary(x => x.Key, x => x.Count());
            if (!numbers.ContainsKey(0))
            {
                write(-1);
                return;
            }
        }
        private static void lifeWithoutZeros()
        {
            long a = readValue<int>(), b = readValue<int>(), c = a + b;
            write(Convert.ToInt64(a.ToString().Replace("0", "")) + Convert.ToInt64(b.ToString().Replace("0", "")) == Convert.ToInt64(c.ToString().Replace("0", "")) ? "YES" : "NO");
        }
        private static void permutation()
        {
            var n = readValue<int>();
            var a = readValues<int>();
            write(n - a.Where(x => x <= n).Distinct().Count());
        }
        private static void hamsterFarm()
        {
            var n = readValues<long>()[0];
            var k = readValues<long>();
            int bestI = 0;
            for (int i = 1; i < k.Count; ++i)
                if (n % k[i] < n % k[bestI])
                    bestI = i;
            write($"{bestI + 1} {n / k[bestI]}");
        }
        private static void shellGame()
        {
            int n = readValue<int>(), x = readValue<int>();
            if (x == 1)
            {
                if (n % 2 == 1)
                    x = 0;
                else
                    x = 2;
                --n;
            }
            for (int i = n % 6; i > 0; --i)
                if (i % 2 == 1)
                {
                    if (x == 0)
                        x = 1;
                    else if (x == 1)
                        x = 0;
                }
                else if (x == 1)
                    x = 2;
                else if (x == 2)
                    x = 1;
            write(x);
        }
        private static void ACM_ICPC()
        {
            var a = readValues<int>();
            int[] score = new int[2], members = new int[2];
            for (int i1 = 0; i1 < 2; ++i1)
            {
                score[i1] = a[0];
                members[i1] = 1;
                for (int i2 = 0; i2 < 2; ++i2)
                {
                    score[i2] += a[1];
                    members[i2] += 1;
                    for (int i3 = 0; i3 < 2; ++i3)
                    {
                        score[i3] += a[2];
                        members[i3] += 1;
                        for (int i4 = 0; i4 < 2; ++i4)
                            if (members[i4] < 3)
                            {
                                score[i4] += a[3];
                                members[i4] += 1;
                                for (int i5 = 0; i5 < 2; ++i5)
                                    if (members[i5] < 3)
                                    {
                                        score[i5] += a[4];
                                        members[i5] += 1;
                                        for (int i6 = 0; i6 < 2; ++i6)
                                            if (members[i6] < 3)
                                            {
                                                score[i6] += a[5];
                                                members[i6] += 1;
                                                if (score[0] == score[1])
                                                {
                                                    write("YES");
                                                    return;
                                                }
                                                score[i6] -= a[5];
                                                members[i6] -= 1;
                                            }
                                        score[i5] -= a[4];
                                        members[i5] -= 1;
                                    }
                                score[i4] -= a[3];
                                members[i4] -= 1;
                            }
                        score[i3] -= a[2];
                        members[i3] -= 1;
                    }
                    score[i2] -= a[1];
                    members[i2] -= 1;
                }
                score[i1] = 0;
                members[i1] = 0;
            }
            write("NO");
        }
        private static void mex()
        {
            var x = readValues<int>()[1];
            var n = readValues<int>();
            write(x - n.Count(y => y < x) + (n.Contains(x) ? 1 : 0));
        }
        private static void minimumProduct()
        {
            var input = readValues<int>();
            int a = input[0], b = input[1], x = input[2], y = input[3], n = input[4], minA = Math.Min(a - x, n), minB = Math.Min(b - y, n);
            if (a - minA <= b - minB)
            {
                a -= minA;
                n -= minA;
            }
            else
            {
                b -= minB;
                n -= minB;
            }

            if (n > 0)
                if (a > x)
                    a -= Math.Min(a - x, n);
                else if (b > y)
                    b -= Math.Min(b - y, n);

            write((long)a * (long)b);
        }
        private static void shovelsAndSwords()
        {
            var input = readValues<int>();
            int a = input[0], b = input[1], result = 0;
            if (a > b)
            {
                var min = Math.Min(a - b, b);
                a -= min * 2;
                b -= min;
                result += min;
            }
            else if (b > a)
            {
                var min = Math.Min(b - a, a);
                a -= min;
                b -= min * 2;
                result += min;
            }
            int d = Math.Min(a / 3, b / 3);
            a -= d * 3;
            b -= d * 3;
            result += d * 2;
            if (a > 0 && b > 0 && (a > 1 || b > 1))
                ++result;
            write(result);
        }
        private static void matrixGame()
        {
            var input = readValues<int>();
            int n = input[0], m = input[1];
            HashSet<int> claimedRows = new HashSet<int>(), claimedColumns = new HashSet<int>();
            for (int i = 0; i < n; ++i)
            {
                input = readValues<int>();
                for (int j = 0; j < m; ++j)
                    if (input[j] == 1)
                    {
                        if (!claimedRows.Contains(i))
                            claimedRows.Add(i);
                        if (!claimedColumns.Contains(j))
                            claimedColumns.Add(j);
                    }
            }
            write(Math.Min(n - claimedRows.Count, m - claimedColumns.Count) % 2 == 0 ? "Vivek" : "Ashish");
        }
        private static void cinemaLine()
        {
            readString();
            var clerk = new Dictionary<int, int> { { 25, 0 }, { 50, 0 } };
            foreach (var a in readValues<int>())
                switch (a)
                {
                    case 25:
                        clerk[25] += 1;
                        break;
                    case 50:
                        if (clerk[25] > 0)
                        {
                            clerk[25] -= 1;
                            clerk[50] += 1;
                        }
                        else
                        {
                            write("NO");
                            return;
                        }
                        break;
                    default: // 100
                        if (clerk[50] > 0 && clerk[25] > 0)
                        {
                            clerk[25] -= 1;
                            clerk[50] -= 1;
                        }
                        else if (clerk[25] > 2)
                            clerk[25] -= 3;
                        else
                        {
                            write("NO");
                            return;
                        }
                        break;
                }
            write("YES");
        }
        private static void kindAnton()
        {
            readString();
            List<int> a = readValues<int>(), b = readValues<int>();
            bool positive1 = false, negative1 = false;
            HashSet<int> positive = new HashSet<int>(), negative = new HashSet<int>();
            for (int i = 0; i < a.Count; ++i)
            {
                int diff = b[i] - a[i];
                if (((diff > 0 && !positive1) || (diff < 0 && !negative1)) && !(diff > 0 ? positive : negative).Any(x => diff % x == 0))
                {
                    write("NO");
                    return;
                }
                if (a[i] > 0)
                {
                    if (!positive1)
                        if (a[i] == 1)
                        {
                            positive1 = true;
                            if (negative1)
                            {
                                write("YES");
                                return;
                            }
                        }
                        else if (!positive.Contains(a[i]))
                            positive.Add(a[i]);
                }
                else if (a[i] < 0 && !negative1)
                    if (a[i] == -1)
                    {
                        negative1 = true;
                        if (positive1)
                        {
                            write("YES");
                            return;
                        }
                    }
                    else if (!negative.Contains(a[i]))
                        negative.Add(a[i]);
            }
            write("YES");
        }
        private static void staircases()
        {
            var input = readValues<int>();
            int n = input[0], mn = input[1];
            if (mn == 0)
            {
                write("YES");
                return;
            }
            var m = readValues<int>().OrderBy(x => x).ToList();
            if (m[0] == 1 || m[m.Count - 1] == n)
            {
                write("NO");
                return;
            }
            for (int i = 0; i < m.Count - 2; ++i)
                if (m[i] == m[i + 1] - 1 && m[i] == m[i + 2] - 2)
                {
                    write("NO");
                    return;
                }
            write("YES");
        }
        private static void blownGarland()
        {
            var colors = new Dictionary<char, int> { { 'R', 0 }, { 'Y', 0 }, { 'B', 0 }, { 'G', 0 } };
            var s = readString();

            var colorPerPosition = new char[4];
            foreach (var color in colors)
                colorPerPosition[s.IndexOf(color.Key) % 4] = color.Key;

            for (int i = 0; i < s.Length; ++i)
                if (s[i] == '!')
                    colors[colorPerPosition[i % 4]] += 1;

            write($"{colors['R']} {colors['B']} {colors['Y']} {colors['G']}");
        }
        private static void mikeAndFax()
        {
            var s = readString();
            int k = readValue<int>();

            if (s.Length % k != 0)
            {
                write("NO");
                return;
            }

            int size = s.Length / k;
            for (int i = 0; i < s.Length; i += size)
                for (int j1 = i + size / 2 - 1, j2 = i + size / 2 + size % 2; j1 >= i; --j1, ++j2)
                    if (s[j1] != s[j2])
                    {
                        write("NO");
                        return;
                    }

            write("YES");
        }
        #region weirdRounding
        private static bool weirdRounding_Recursion(string ns, int kp, int d)
        {
            if (d > 0)
                for (int i = ns[1] == '0' && ns.Length > 2 ? 1 : 0; i < ns.Length; ++i)
                {
                    string nsNew = ns.Remove(i, 1);
                    int n = Convert.ToInt32(nsNew);
                    if (n % kp == 0 || weirdRounding_Recursion(nsNew, kp, d - 1))
                        return true;
                }
            return false;
        }
        private static void weirdRounding()
        {
            var input = readStrings();
            string ns = input[0];
            int n = Convert.ToInt32(ns), k = Convert.ToInt32(input[1]), kp = (int)Math.Pow(10, k);

            if (n < kp)
                write(ns.Length - 1);
            else if (n % kp == 0)
                write(0);
            else
                for (int d = 1; d < ns.Length; ++d)
                    if (weirdRounding_Recursion(ns, kp, d))
                    {
                        write(d);
                        return;
                    }
        }
        #endregion
        private static void wilburArray()
        {
            readString();
            var b = readValues<int>();
            long result = Math.Abs(b[0]);
            for (int i = 1; i < b.Count; ++i)
                result += Math.Abs(b[i] - b[i - 1]);
            write(result);
        }
        private static void zuhairStrings()
        {
            int k = readValues<int>()[1];
            var s = readString();
            var result = new Dictionary<char, int>();

            for (int i = 0; i < s.Length - k + 1;)
            {
                int j = i + 1;
                for (; j < i + k && s[i] == s[j]; ++j) ;
                if (j == i + k)
                    if (!result.ContainsKey(s[i]))
                        result.Add(s[i], 1);
                    else
                        result[s[i]] += 1;
                i = j;
            }

            write(result.Count > 0 ? result.Max(x => x.Value) : 0);
        }
        private static void artfulExpedient()
        {
            var n = readValue<int>();
            List<int> x = readValues<int>(), y = readValues<int>();
            var numbers = x.Union(y).ToHashSet();
            var resultEven = true;

            for (int i = 0; i < n; ++i)
                for (int j = 0; j < n; ++j)
                    if (numbers.Contains(x[i] ^ y[j]))
                        resultEven = !resultEven;

            write(resultEven ? "Karen" : "Koyomi");
        }
        private static void ebonyIvory()
        {
            var input = readValues<int>();
            int a = input[0], b = input[1], c = input[2];
            if (a < b)
            {
                var t = a;
                a = b;
                b = t;
            }
            for (; c >= 0; c -= a)
                if (c % b == 0)
                {
                    write("Yes");
                    return;
                }
            write("No");
        }
        #region Lala Land Apple Trees
        private class LalaLand_AppleTree : IComparable
        {
            private int coordinate;
            internal int Apples { get; private set; }
            internal LalaLand_AppleTree(int coordinate, int apples)
            {
                this.coordinate = coordinate;
                Apples = apples;
            }
            public int CompareTo(object obj) => coordinate - ((LalaLand_AppleTree)obj).coordinate;
        }
        private static void lalaLandAppleTrees()
        {
            var n = readValue<int>();
            List<LalaLand_AppleTree> right = new List<LalaLand_AppleTree>(), left = new List<LalaLand_AppleTree>();
            for (int i = 0; i < n; ++i)
            {
                var input = readValues<int>();
                if (input[0] > 0)
                    right.Add(new LalaLand_AppleTree(input[0], input[1]));
                else
                    left.Add(new LalaLand_AppleTree(-input[0], input[1]));
            }

            if (Math.Abs(right.Count - left.Count) < 2)
                write(right.Sum(x => x.Apples) + left.Sum(x => x.Apples));
            else
            {
                quickSort(right);
                quickSort(left);
                if (right.Count > left.Count)
                    write(right.GetRange(0, left.Count + 1).Sum(x => x.Apples) + (left.Count > 0 ? left.Sum(x => x.Apples) : 0));
                else
                    write((right.Count > 0 ? right.Sum(x => x.Apples) : 0) + left.GetRange(0, right.Count + 1).Sum(x => x.Apples));
            }
        }
        #endregion
        private static void lanterns()
        {
            int l = readValues<int>()[1], d = 0;
            var a = readValues<int>().Distinct().ToList();
            quickSort(a);
            for (int i = 0; i < a.Count - 1; ++i)
            {
                var diff = a[i + 1] - a[i];
                if (diff > d)
                    d = diff;
            }
            if (a[0] > 0 && a[a.Count - 1] < l)
                write(Math.Max(Math.Max(a[0] - 0, l - a[a.Count - 1]), d / 2.0));
            else if (a[0] > 0)
                write(Math.Max(a[0] - 0, d / 2.0));
            else if (a[a.Count - 1] < l)
                write(Math.Max(l - a[a.Count - 1], d / 2.0));
            else
                write((double)d / 2.0);
        }
        private static void cheapTravel()
        {
            var input = readValues<int>();
            int n = input[0], m = input[1], a = input[2], b = input[3];
            if (b >= a * m)
                write(n * a);
            else
                write((n / m) * b + ((n % m) * a < b ? (n % m) * a : b));
        }
        private static void berSUBall()
        {
            readString();
            var a = readValues<int>();
            readString();
            var b = readValues<int>();
            quickSort(a);
            quickSort(b);
            int result = 0;
            for (int i = 0, j = 0; i < a.Count && j < b.Count;)
                if (Math.Abs(a[i] - b[j]) < 2)
                {
                    ++result;
                    ++i;
                    ++j;
                }
                else if (a[i] < b[j])
                    ++i;
                else
                    ++j;
            write(result);
        }
        private static void flippingGame()
        {
            readString();
            var a = readValues<int>();
            int max = 0;
            for (int i = 0, previousOnes = 0, total = a.Sum(); i < a.Count; previousOnes += a[i], ++i)
                for (int j = i, remainingOnes = total - previousOnes; j < a.Count; , ++j)
                {
                    remainingOnes -= a[j];
                    var ones = previousOnes + (j - i + 1 - (total - previousOnes - remainingOnes)) + remainingOnes;
                    if (ones > max)
                        max = ones;
                }
            write(max);
        }

        static void Main(string[] args)
        {
            //var t = readValue<int>();
            //for (int i = 0; i < t; ++i)
            flippingGame();
        }
    }
}


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

namespace Flipping_Game
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int maxCount = 0;
            for(int i = 0; i < numbers.Length;i++)
            {
                for (int j = 0; j < numbers.Length; j++)
                {
                    int count = 0;
                    for (int k = 0; k < numbers.Length; k++)
                    {
                        if (k >= i && k <= j)
                        {
                            if (numbers[k] == 0)
                                count++;
                        }
                        else
                        {
                            if (numbers[k] == 1)
                                count++;
                        }
                    }
                    maxCount = Math.Max(count, maxCount);
            }
            Console.WriteLine(maxCount);
        }
    }
}


using System;

namespace ConsoleApp4
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(n);
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int s;
            int t = 0;

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

                jami += a[i];

            }
            s = jami;
            for (int i = 0; i < n; i++)
            {
                jami = s;
                if (a[i] == 0)
                {
                    jami += 1;
                }
                if (a[i] == 1)
                {
                    jami -= 1;
                }
                for (int j = i + 1; j < n; j++)
                {
                    if (a[j] == 0)
                    {
                        jami += 1;
                    }
                    if (a[j] == 1)
                    {
                        jami -= 1;
                    }
                    if (jami > t)
                    {
                        t = jami;
                    }

                }
            }

            Console.WriteLine(t);

        }
    }
}


//#define __debug

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

namespace _TestData
{
    public static class ListExtensions
    {
        public static bool IsAllFree(this IEnumerable<bool> houses)
        {
            return houses.All(v => !v);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
#if __debug
            var power = Convert.ToInt32("1");
#else
            var power = Convert.ToDouble(Console.ReadLine());
#endif
            Console.WriteLine(Check(power));
        }

        static double Check(double power)
        {
            if (power == 0) return 0;
            //1-8
            //2-4
            //3-2
            //4-6

            //5-8
            //6-4
            //7-2
            //8-6

            var lPower = (power % 10) % 4;

            switch (lPower)
            {
                case 0:
                    return 6;
                case 1:
                    return 8;
                case 2:
                    return 4;
                case 3:
                    return 2;
            }

            return 0;
        }
    }
}


//
// 742A Codeforces
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,op;
            n = Convert.ToInt32(Console.ReadLine());
            op = n % 4;
            if(n == 0)
            {
                Console.WriteLine("1\n");
                break;
            }
            switch (op)
            {
                case 0:
                    Console.WriteLine("6\n");
                    break;
                case 1:
                    Console.WriteLine("8\n");
                    break;
                case 2:
                    Console.WriteLine("4\n");
                    break;
                case 3:
                    Console.WriteLine("2\n");
                    break;
                default:
                    Console.WriteLine("\n");
                    break;
            }
        }
    }
}


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

namespace NetCore3
{
    public class Test
    {
        public static void Main(string[] args)
        {
            var input = long.Parse(Console.ReadLine());
            var baseNumber = 8;

            for (int i = 1; i <= input; i++)
            {
                baseNumber = Math.Pow(baseNumber, i).ToString().Reverse()[0] - '0';
            }

            Console.WriteLine(baseNumber);
        }
    }
}