HQ9+ is a joke programming language which has only four one-character instructions: "H" prints "Hello, World!", "Q" prints the source code of the program itself, "9" prints the lyrics of "99 Bottles of Beer" song,  "+" increments the value stored in the internal accumulator.Instructions "H" and "Q" are case-sensitive and must be uppercase. The characters of the program which are not instructions are ignored.You are given a program written in HQ9+. You have to figure out whether executing this program will produce any output.

The input will consist of a single line p which will give a program in HQ9+. String p will contain between 1 and 100 characters, inclusive. ASCII-code of each character of p will be between 33 (exclamation mark) and 126 (tilde), inclusive.

Output "YES", if executing the program will produce any output, and "NO" otherwise.

NoteIn the first case the program contains only one instruction — "H", which prints "Hello, World!".In the second case none of the program characters are language instructions.

using System;
public class HQ{
	static void Main(){
		String s = Console.ReadLine();
		for(int i=0; i<s.Length; i++){
			if(s[i]=='H'||s[i]=='Q'||s[i]=='9'){
				Console.WriteLine("YES");
				return;
			}

		}
		Console.WriteLine("NO");

	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using System.Collections;
class Source
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        for ( int i = 0 ; i < s.Length ; ++ i )
            if (s[i] == 'H' | s[i] == 'Q' | s[i] == '9' )
            {
                Console.WriteLine("YES");
                return;
            }
        Console.WriteLine("NO");

        return;
    }

}

using System;
using System.Linq;

namespace CodeForces {
    class Program {
        static void Main (string[] args) {
            string n = Console.ReadLine ();
            if (n.Contains ('H') || n.Contains ('Q') || n.Contains ('9')) {
                System.Console.WriteLine ("YES");
            } else {
                System.Console.WriteLine ("NO");
            }

        }
    }
}

using System;
class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            char[] dt = {'H', 'Q','9' };
            for (int i = 0; i < 3; ++i)
                if (input.IndexOf(dt[i]) >= 0) { dt[0] = 's'; break; }
            Console.WriteLine(dt[0] == 's' ?"YES":"NO");
        }
    }

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

namespace HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            bool x = false;

            for (int i = 0 ; i<= line.Length-1; i++)
            {

                 if (line[i] == 'H' || line[i] == 'Q' || line[i] == '9')
                {
                    x = true;

                }

            }
            if (x == true)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            }
        }
    }

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9"))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadLine();
        }
    }
}

using System;

namespace CF_HQ9Plus {
    class Program {
        static void Main(string[] args) {
            string input = Console.ReadLine();
            if (input.Contains("H") || input.Contains("9") || input.Contains("Q")) {
                Console.WriteLine("YES");
                return;
            }
            Console.WriteLine("NO");
        }
    }
}

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

namespace A.HQ9
{
    class Program
    {
        static void Main(string[] args)
        {

            string sa = Console.ReadLine();
            if (sa.Contains("H")||sa.Contains("Q")||sa.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace HQ9
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            if (line.Contains('H')||line.Contains('Q')||line.Contains('9')) Console.WriteLine("YES");
            else Console.WriteLine("NO");
        }
    }
}

using System;

class HQ9Puls
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        if (s.Contains("Q") || s.Contains("H") || s.Contains("9")) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}

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

namespace ConsoleApplication30
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();

            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == 'H' || str[i] == 'Q' || str[i] == '9')
                {
                    Console.WriteLine("YES");
                    return;
                }
                else
                    if (i == str.Length-1)
                        Console.WriteLine("NO");
            }

        }
    }
}

using System;

namespace ConsoleApp7
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            string word = Console.ReadLine();

            Console.WriteLine(word.Contains("Q") || word.Contains("H") || word.Contains("9") ? "YES" : "NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApp2Framework
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            if (p.Contains("H") || p.Contains("Q") || p.Contains("9"))
                Console.WriteLine("YES");

            else
                Console.WriteLine("NO");

        }
    }
}

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

namespace add
{
    class Program
    {
        static void Main(string[] args)
        {
            string a=Console.ReadLine();
            if(a.Contains("H")|a.Contains("Q")|a.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
}
}

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

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            bool b = false;
            string s;
            s = Console.ReadLine();
            //s = s.ToUpper();
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9' || s[i] == 'Q')
                {
                    Console.WriteLine("YES");
                    b = true;
                    break;

                }
            }
            if(!b)
                Console.WriteLine("NO");

        }
    }
}

using System;

public class Test
{
	public static void Main()
	{
		string str = Console.ReadLine();
			if(str.Contains("H") || str.Contains("Q")|| str.Contains("9"))
			{
				Console.WriteLine("YES");
			}
			else { Console.WriteLine("NO"); }
	}
}

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

namespace HQ_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            if (p.Contains('H') || p.Contains('Q') || p.Contains('9'))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;

namespace CFDay8
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9") )
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

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

namespace HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            if (p.Contains("H") || p.Contains("Q") || p.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            Console.ReadLine();

        }

    }
}

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)
        {
            string str = Console.ReadLine();
            if(str.Contains('H')|| str.Contains('Q')|| str.Contains('9') )
            {
                Console.WriteLine("YES");

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

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

namespace DZ_1._1
{
    class Program
    {
        static void Main(string[] args)
        {
            //int x = 0;
            //int timesToCount;
            //timesToCount =  Convert.ToInt32(Console.ReadLine());

            //string[] XCOMmands = new string[timesToCount];

            //for (int i = 0; i < timesToCount; i++)
            //{
            //    XCOMmands[i] = Console.ReadLine();
            //    XCOMmands[i] = XCOMmands[i].ToLower();
            //    if (XCOMmands[i] == "x++" || XCOMmands[i] == "++x") x++;
            //    else if (XCOMmands[i] == "x--" || XCOMmands[i] == "--x") x--;
            //}

            //Console.WriteLine(x);
            ////Console.ReadKey();

            //int answer = 0;

            //string firstString = Console.ReadLine();
            //string secondString = Console.ReadLine();

            //firstString = firstString.ToLower();
            //secondString = secondString.ToLower();

            //byte[] encodeFirstString = Encoding.ASCII.GetBytes(firstString);
            //byte[] encodeSecondString = Encoding.ASCII.GetBytes(secondString);

            //for (int i=0; i<firstString.Length; i++)
            //{
            //    if (encodeFirstString[i] > encodeSecondString[i])
            //    {
            //        answer = 1;
            //        break;
            //    }
            //    else if (encodeFirstString[i] < encodeSecondString[i])
            //    {
            //        answer = -1;
            //        break;
            //    }
            //}
            //Console.WriteLine(answer);
            ////Console.ReadKey();
            ///

            //int spaciousness = 0;
            //int passengers = 0;
            //int timesToCount = Convert.ToInt32(Console.ReadLine());
            //for (int i = 0; i < timesToCount; i++)
            //{
            //    string temp = Console.ReadLine();
            //    string[] IOnumbers = temp.Split(' ');
            //    passengers-= Convert.ToInt32(IOnumbers[0]);
            //    passengers+= Convert.ToInt32(IOnumbers[1]);

            //    if (passengers > spaciousness) spaciousness = passengers;
            //}

            //Console.WriteLine(spaciousness);
            ////Console.ReadKey();

            string inputText = Console.ReadLine();

            if (inputText.Contains("H") || inputText.Contains("Q") || inputText.Contains("9"))
            {
                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;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();

            if ((p.Contains('H') == true) || (p.Contains('Q') == true) || (p.Contains('9') == true))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

            Console.Read();
        }
    }
}

using System;

namespace Theatre_Square
{
    class Program
    {
         static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var output = "NO";

            foreach(var s in str)
            {
                if (s == 'H' || s == 'Q' || s == '9')
                {
                    output =  "YES";
                    break;
                }

            }
            Console.WriteLine(output);
            Console.ReadLine();
        }

    }

}

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

namespace _133A_HQ
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var p = @"(H)|(Q)|(9)";
            Regex regex = new Regex(p);
            MatchCollection matches = regex.Matches(str);
            var t = new List<HashSet<string>>();
            if (matches.Count > 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
public class HQ{
	static void Main(){
		String s = Console.ReadLine();
		for(int i=0; i<s.Length; i++){
			if(s[i]=='H'||s[i]=='Q'||s[i]=='9'){
				Console.WriteLine("YES");
				return;
			}

		}
		Console.WriteLine("NO");

	}
}

using System;
class Program
{
    static void Main()
    {
        Console.WriteLine(Console.ReadLine().IndexOfAny(new char[] { 'H', 'Q', '9' }) != -1 ? "YES" : "NO");
    }
}

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

namespace A.HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            bool flage = false;
            input= Console.ReadLine();
            for (int i = 0; i < input.Length; i++)
            {
                if ((input[i] == 'H') | (input[i] == 'Q') | (input[i] == '9'))
                {
                    flage = true;
                    Console.WriteLine("YES");
                    break;
                }

            }

            if (flage == false)
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace _133A
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            char[] chars = line.ToCharArray();

            bool found = false;
            foreach (char item in chars)
            {
                if (item == 'H' || item == 'Q' || item == '9')
                {
                    Console.WriteLine("YES");
                    found = true;
                    break;
                }
            }

            if (found == false)
                Console.WriteLine("NO");
            //Console.ReadKey();
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            var set=new HashSet<char>();
            String s = Console.ReadLine();
            foreach (var i in s)
            {
                set.Add(i);
            }
            if(set.Contains('H')|| set.Contains('Q') || set.Contains('9') )
                Console.WriteLine("YES");
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        string c = Console.ReadLine();
        RunCode( c);
        Console.ReadLine();
    }
    static void RunCode(string code)
    {
        int c = 0;
        if(code[code.Length-1] !='+'){
        for (int i = 0; i < code.Length; i++)
        {

            char l = code[i];
            //l = char.ToUpperInvariant(l);
            if (l == 'H')
            {
                c ++;
            }
            else if (l == 'Q')
            {
                c++;
            }
            else if (l == '9')
            {
                c++;
            }
        }
        }
        if (code.Length>1 &&code[code.Length-1] == '+')
        {
            string sub=code.Substring(0,code.Length-1);
            try
            {
                int cc = Convert.ToInt32(sub);

            }
            catch
            {
                if(sub.Length>0)
                c++;
            }

        }

     if(c>0 && plus(code))
      {
        Console.WriteLine("YES");
      }
     else
       {
           Console.WriteLine("NO");
       }
    }

    static bool plus(string code)
    {
        for (int i = 0; i < code.Length; i++)
        {
            if (code[i] != '+')
            {
                return true;
            }
        }
        return false;

    }

}

using System;
namespace Contest
{
class MainClass{
   public static void Main (string[] args){
        int n,s=0;
        string num = Console.ReadLine();
        if((num.Contains("H"))||(num.Contains("Q"))||(num.Contains("9")))
        {
             Console.WriteLine("YES");
         }
         else
             Console.WriteLine("NO");

    }
 }
}

using System;
    internal class Program
    {
        private static void Main(string[] args)
        {
            var s = Console.ReadLine();
            Console.WriteLine(s.Contains("Q") || s.Contains("9") || s.Contains("H") ? "YES" : "NO");
        }
    }

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

namespace Solving_online_problems
{
    class Program
    {
        static void Main()
        {
            string word = Console.ReadLine();

            bool output = false;

            foreach (char letter in word)
            {
                if (letter == 'H' || letter == 'Q' || letter == '9')
                {
                    output = true;
                }
            }

            if (output == true) Console.Write("YES");
            else Console.Write("NO");
        }
    }
}

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

namespace HqPlus
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Regex.IsMatch(Console.ReadLine(), @"[HQ9]") ? "YES" : "NO");
        }
    }
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9"))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadLine();
        }
    }
}

//FelisDJ =*w*=

using System;

class Program
{
    static void Main(string[] args)
    {
        string p = Console.ReadLine();
        bool ck = false;
        for(int i =0 ;i<p.Length;i++)
        {
            if(p[i]=='H' || p[i]=='Q' || p[i]=='9' /* || p[i]=='+' */)
            {
                ck = true;
            }
        }
        if(ck)
            Console.WriteLine("YES");
        else
            Console.WriteLine("NO");
    }
}

using System;
using System.Text;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9")) Console.WriteLine("YES");
            else Console.WriteLine("NO");

        }
    }

}

using System;

class HQ9Puls
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        if (s.Contains("Q") || s.Contains("H") || s.Contains("9")) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}

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)
        {
            string q = Console.ReadLine();
            if (q.Contains("H")|| q.Contains("Q") || q.Contains("9") )
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
using System.Text;

namespace vvv
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9')
                {
                    Console.WriteLine("YES");
                    Environment.Exit(0);
                }
            }

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

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

namespace _133A
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            if (str.Contains("H") || str.Contains("Q") || str.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApplication234
{
    class Program
    {
        static void Main(string[] args)
        {
            //int n = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9' )
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }

    }
}

using System;

namespace HQ9Plus
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            bool evaluator = false;
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == 'H' || str[i] == 'Q' || str[i] == '9')
                {
                    evaluator = true;
                    break;
                }
            }
            if (evaluator)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

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

public class Program
{
    static void Main(string[] args)
    {
        HQ9 h = new HQ9();
        //Console.ReadLine();
    }
}
public class HQ9
{
    public HQ9()
    {
        int i = 0;
        bool output = false;
        string x = Console.ReadLine().Trim();
        for (i = 0; i < x.Length; i++)
        {
            if (x[i] == 'H' || x[i] == 'Q' || x[i] == '9')
            {
                output = true;
                break;
            }
        }
        Console.WriteLine(output ? "YES" : "NO");
    }
}

using System;

class Program
{
    static void Main()
    {
        string InputWord = Console.ReadLine();

        for (int i = 0; i < InputWord.Length; i++)
        {
            if (InputWord[i] == 'H' || InputWord[i] == 'Q' || InputWord[i] == '9')
            {
                Console.WriteLine("YES");
                break;
            }

            if (i == (InputWord.Length - 1))
                Console.WriteLine("NO");
        }
    }
}

using System;
using System.Collections.Generic;

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

      //  int num = Convert.ToInt32(Console.ReadLine());

        string input = Console.ReadLine();

        char[] chars = input.ToCharArray();

        int count = 0;

        for( int i=0; i<chars.Length; i++)
        {
            if(chars[i]=='H')
            {
                count++;
            }

            else if(chars[i]=='Q')
            {
                count ++;
                    }

            else if(chars[i]=='9')
            {
                count++;
            }

            //else if (chars[i]=='+')
            //{
            //    count++;
            //}
        }
        if (count > 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 InfoProblems
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            bool ok = false;
            for (int i = 0; i < s.Length; i ++)
            {
                if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9')
                    ok = true;
            }
            if (ok == true) {
                Console.WriteLine("YES");
            }
            else {
                Console.WriteLine("NO");
            }

            //Console.ReadKey();
        }
    }
}

using System;

namespace CF_HQ9Plus {
    class Program {
        static void Main(string[] args) {
            string input = Console.ReadLine();
            Console.WriteLine((input.Contains("H") || input.Contains("Q") || input.Contains("9")) ? "YES" : "NO");
        }
    }
}

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

namespace prA {
    class Program {
        static void Main(string[] args) {
#if ONLINE_JUDGE
#else

            StreamWriter sw = new StreamWriter("output");
            Console.SetOut(sw);
            Console.SetIn(new StreamReader("input"));
#endif

            string s = Console.ReadLine();
            Console.WriteLine(s.IndexOfAny("HQ9".ToCharArray()) != -1 ? "YES" : "NO");

#if ONLINE_JUDGE
#else
            sw.Close();
#endif
        }
    }
}

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

namespace Lv1Phase1
{
    class Program
    {
        static void Main(string[] args)
        {
            int counter = 0;
            string input = Console.ReadLine();
            foreach (char c in input)
            {
                if (c == 'Q' || c == 'H' || c == '9') counter++;
            }
            if (counter > 0) { Console.WriteLine("YES"); }
            else { Console.WriteLine("NO"); }
           // Console.ReadKey();
        }

    }
}

using System;

public class Test
{
	public static void Main()
	{
		string input = Console.ReadLine();

		Console.WriteLine(GetHQ9p(input));
	}

	public static string GetHQ9p(string input)
	{
		char[] alphabet = new char[]{'H','Q','9'};

		foreach(char a in input){
			foreach(char a2 in alphabet){
				if(a==a2){
					return "YES";
				}
			}
		}
		return "NO";
	}
}

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

namespace ConsoleApplication166
{

    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            Console.WriteLine(p.Contains('H') | p.Contains('Q') | p.Contains('9') ? "YES" : "NO");
        }
    }
}

using System;
using System.Linq;

namespace hello
{

    class FDay
    {

        static void Main()
        {

            string[] chars = new string[] { "H", "Q", "9"};
            string x = Console.ReadLine();
            var xx = chars.Any(x.Contains);
            Console.WriteLine(xx?"YES":"NO");
            //int[,] arr = new int[,] { { -3, -2, -1, 0 }, { -2, -1, 0, 1 }, { 4, 3, 2, 3 } };

            //int count = 0;

            //Console.WriteLine($"UpperBound(0) = {arr.GetUpperBound(0)}");
            //Console.WriteLine($"UpperBound(1) = {arr.GetUpperBound(1)}");

            //for (int i = 0; i <= arr.GetUpperBound(0); i++)
            //{
            //    //Console.WriteLine();
            //    for (int j = 0; j <= arr.GetUpperBound(1); j++)
            //    {
            //        if (arr[i, j] >= 0)
            //            break;
            //        else if (arr[i, j] < 0)
            //        {
            //            count++;
            //        }
            //        //Console.Write(arr[i,j]+" ");
            //    }
            //}
            //Console.WriteLine(count);
            //Console.ReadLine();
            //Console.WriteLine();
            //int a=0, b=0;
            //string[] x = { "00000", "00000", "00000", "00000", "0000x" };
            //for (int i = 0; i < x.Length; i++)
            //{
            //    for (int j = 0; j < x.Length; j++)
            //    {
            //        string cc = x[i];
            //        char v = cc[j];
            //        if (v == 'x')
            //        {
            //            a = i;
            //            b = j;
            //        }
            //    }
            //}

            //string t1 = "10:00PM";
            //string tv2 = "11:00PM";

            //DateTime tt1 = Convert.ToDateTime(t1);
            //DateTime tt2 = Convert.ToDateTime(tv2);

            //char v = t1[5];
            //Console.WriteLine(tt1.Hour-12);

            //Console.WriteLine("Hello");
            //int[] c = { 10, 20, 20, 10, 80, 30, 50, 10, 20 };

            //int[] b = { 10, 34, 18, 50, 10, 80, 20 };

            //var x = c.Intersect(b);

            //var v = (int [])c.Clone();
            //int[] y=new int [b.Length];
            //Array.Copy(b, y, b.Length);
            //Console.WriteLine(b.GetHashCode());
            //Console.WriteLine(y.GetHashCode());
            //Console.WriteLine(v.Length);
            ////Array.Sort(c);
            //foreach (var item in v)
            //{
            //    Console.WriteLine(item);
            //}

            //int sum=0;
            //for (int i = 1; i < c.Length; i++)
            //{
            //    if (c[i]==c[i-1])
            //    {
            //        sum++;
            //        i++;
            //     }
            //}
            //Console.WriteLine(sum);
            //Console.ReadLine();
        }

    }

}

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

namespace Tram
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            HQ9Plus(input);

        }
        static void HQ9Plus(string input)
        {
            string instructions = "HQ9";
            for (int i = 0; i < instructions.Length; i++)
            {
                if (input.Contains(instructions[i]))
                {
                    Console.WriteLine("YES");
                    break;
                }
                else
                {
                    if (i==instructions.Length-1)
                    {
                        Console.WriteLine("NO");
                    }

                }

            }

        }

    }
}

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            string frase = Console.ReadLine();
            int contador = 0;
            for (int i = 0; i < frase.Length; i++)
            {
                if ((frase[i] == 'H') || (frase[i] == 'Q') || (frase[i] == '9'))
                {
                    contador++;
                }

            }
            if (contador >= 1)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9')
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

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

namespace example_1_0
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            char[] ch = str.ToArray<char>();

            for (int i = 0; i < ch.Length; i++)
            {
                if (ch[i] == 'H' || ch[i] == 'Q' || ch[i] == '9')
                {
                    Console.WriteLine("YES");
                    return;
                }
            }

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

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

namespace _41a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if(s.Contains("H")==true || s.Contains("Q")  || s.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");

        }
    }
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9"))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadLine();
        }
    }
}

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

namespace Code7.Tamrin
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            if(input.Contains("H")|| input.Contains("9") || input.Contains("Q"))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

using System;

namespace Watermelon
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = input.IndexOfAny(new char[] { 'H', 'Q', '9' });
            if (n == -1)
            {
                Console.Write("NO");
            }
            else Console.Write("YES");
            Console.ReadLine();
        }
    }
}

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

namespace WarmingUpC_Sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string ans = "NO";
            string p = Console.ReadLine();
            for (int i = 0; i < p.Length; i++)
            {
                if (p[i] == 'H' || p[i] == 'Q' || p[i] == '9')
                {
                    ans = "YES";
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            /* int k = int.Parse(Console.ReadLine());
             int n = int.Parse(Console.ReadLine());
             int w = int.Parse(Console.ReadLine());

             int sum = 0;
             int ans = 0;
             for(int i=1;i<=w;i++)
             {
                 sum += (i * k);

             }
             ans = sum - n;
             Console.WriteLine(ans);*/

            string s;

            s = Console.ReadLine();

            if (s.Contains("H") || s.Contains("Q") || s.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else
                Console.WriteLine("NO");

        }
    }
}

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

namespace A.HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            char[] pro = "HQ9".ToCharArray();
            int sum=0;
            for(int j=0;j<pro.Length;j++)
            {
                if (input.Contains(pro[j]))
                {
                    Console.WriteLine("YES");
                    break;
                }
                else
                    sum++;
            }
            if (sum == pro.Length)
                Console.WriteLine("NO");

        }
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Functions x = new Functions();
            string row = Console.ReadLine();
            Console.WriteLine(x.SomeMethod(row));
        }
        class Functions
        {
            public string SomeMethod(string str)
            {
                return ((str.Contains("H")) || (str.Contains("9")) || (str.Contains("Q")))? "YES" : "NO" ;
            }
        }
    }
}

using System;

namespace CFDay8
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9") )
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

using System;
class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            char[] dt = {'H', 'Q','9' };
            for (int i = 0; i < 3; ++i)
                if (input.IndexOf(dt[i]) >= 0) { dt[0] = 's'; break; }
            Console.WriteLine(dt[0] == 's' ?"YES":"NO");
        }
    }

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

class TheProgrammingContestDivTwo
{
    public static void Main()
    {
        var command = Console.ReadLine();
        char[] ch = new char[] { 'H', 'Q', '9'};
        if (res(command, ch))
            Console.WriteLine("YES");
        else
            Console.WriteLine("NO");
    }

    private static bool res(string command, char[] ch)
    {
        for (int i = 0; i < command.Length; i++)
            for (int j = 0; j < ch.Length; j++)
                if (command[i] == ch[j]) return true;
        return false;
    }
}

using System;

namespace A._HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            if (line.Contains("H") ||
                line.Contains("Q") ||
                line.Contains("9"))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

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)
        {
            string q = Console.ReadLine();
            if (q.Contains("H")|| q.Contains("Q") || q.Contains("9") )
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

public class Program
{
    static void Main(string[] args)
    {
        HQ9 h = new HQ9();
        //Console.ReadLine();
    }
}
public class HQ9
{
    public HQ9()
    {
        int i = 0;
        bool output = false;
        string x = Console.ReadLine().Trim();
        for (i = 0; i < x.Length; i++)
        {
            if (x[i] == 'H' || x[i] == 'Q' || x[i] == '9')
            {
                output = true;
                break;
            }
        }
        Console.WriteLine(output ? "YES" : "NO");
    }
}

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

namespace Solving_online_problems
{
    class Program
    {
        static void Main()
        {
            string word = Console.ReadLine();

            bool output = false;

            foreach (char letter in word)
            {
                if (letter == 'H' || letter == 'Q' || letter == '9')
                {
                    output = true;
                }
            }

            if (output == true) Console.Write("YES");
            else Console.Write("NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Threading;

namespace ConsoleApp3
{
    class Program
    {
        static void Main(string[] args)
        {
            Dictionary<char,int> mp=new Dictionary<char,int>();
            String s = Console.ReadLine();
            foreach (char i in s)
            {
                int v;
                if(mp.TryGetValue(i, out v));

                mp[i]=v;
                mp[i]++;
            }
            if(mp.ContainsKey('H') &&  mp['H']>=1)
            Console.WriteLine("YES");
            else if (mp.ContainsKey('Q') && mp['Q'] >= 1)
                Console.WriteLine("YES");
            else if (mp.ContainsKey('9') && mp['9'] >= 1)
                Console.WriteLine("YES");
            //else if (mp.ContainsKey('+') && mp['+'] >= 1)
              //  Console.WriteLine("YES");
            else
            {
                Console.WriteLine("NO");
            }

            Console.ReadLine();
        }
    }
}

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

namespace CodeForces
{
    internal class Program
    {
        private static void Main()
        {
            var code = ReadHelper.ReadString();
            if (code.Contains("H") || code.Contains("Q") || code.Contains("9"))
                Console.WriteLine("YES");
            else
            Console.WriteLine("NO");
        }
    }

    internal static class ReadHelper
    {

        public static string ReadString()
        {
            return Console.ReadLine();
        }

        public static List<long> ReadLongList(char separator = ' ')
        {
            return Console.ReadLine().Trim().Split(separator).Select(long.Parse).ToList();
        }
        public static long ReadLong()
        {
            return long.Parse(Console.ReadLine());
        }
    }

}

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

namespace ConsoleApplication1
{
    class Program
    {
        static int[] ReadInt(int size)
        {
            string[] input = Console.ReadLine().Split(' ');
            int[] res = new int[size];
            for (int i=0; i<input.Length; i++)
            {
                res[i] = Convert.ToInt32(input[i]);
            }
            return res;
        }

        static int ReadInt()
        {
            int n = Convert.ToInt32(Console.ReadLine());
            return n;
        }

        static String ReadString()
        {
            return Console.ReadLine();
        }

        static int Max(int a, int b)
        {
            return (a > b ? a : b);
        }

        static void Main(string[] args)
        {
            String input = ReadString();
            char[] charArray = { 'H', 'Q', '9' };
            if (input.IndexOfAny(charArray) > -1)
            {
                Console.WriteLine("YES");
            }
            else Console.WriteLine("NO");
        }
    }
}

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

namespace ProgrammingContest
{
    class Program
    {
        public static void Main(string[] args)
        {
            var p = Console.ReadLine();

            if (p.Contains('H') || p.Contains('Q') || p.Contains('9') )
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            Console.WriteLine(s.Contains("H") || s.Contains("Q") || s.Contains("9") ? "YES" : "NO");
        }
    }
}

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

namespace CF_HQ9
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine();
            if(input.Any(c => (c == 'H' || c == 'Q' || c == '9')))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
    class Program
    {
        static void Main()
        {
        string a = Console.ReadLine();
        Console.WriteLine((a.Contains("H") || a.Contains("Q") || a.Contains("9") ) ? "YES" : "NO") ;
        }
    }

using System;
namespace Contest
{
class MainClass{
   public static void Main (string[] args){
        int n,s=0;
        string num = Console.ReadLine();
        if((num.Contains("H"))||(num.Contains("Q"))||(num.Contains("9")))
        {
             Console.WriteLine("YES");
         }
         else
             Console.WriteLine("NO");

    }
 }
}

using System;

namespace Problem___122A___A._HQ9Plus
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = Console.ReadLine();
            if (p.Length>=1 && p.Length<=100)
            {
                bool temp = true;

                for (int i = 0; i < p.Length; i++)
                {
                    var x = Convert.ToInt32(p[i]);
                    if (x>=33 && x<=126)
                    {
                        temp = true;
                    }
                    else
                    {
                        temp = false;
                        break;
                    }
                }
                if (temp==true)
                {
                    bool b = false;
                    for (int i = 0; i < p.Length; i++)
                    {
                        if (p[i]=='H' || p[i]=='Q' || p[i]=='9')
                        {
                            b = true;
                        }
                    }

                    if (b!=true)
                    {
                        Console.WriteLine("NO");
                    }
                    else
                    {
                        Console.WriteLine("YES");
                    }
                }
            }
        }
    }
}

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

namespace HQ9
{
    class Program
    {
        static void Main(string[] args)
        {
            string ans="NO";
            string linea = Console.ReadLine();
            foreach (char c in linea)
            {
                if (c=='H' || c=='Q' || c=='9')
                {
                    ans = "YES";
                    break;
                }
            }
            Console.WriteLine(ans);
        }
    }
}

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

namespace HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            if (p.Contains("H") || p.Contains("Q") || p.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            Console.ReadLine();

        }

    }
}

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

namespace Problem122A
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            if(s.Contains("H") || s.Contains("Q") || s.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] HQ9 = { 'H', 'Q', '9' };

            if (Console.ReadLine().IndexOfAny(HQ9) >= 0)
                Console.Write("YES");
            else
                Console.Write("NO");
        }
    }
}

using System;

namespace Theatre_Square
{
    class Program
    {
         static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var output = "NO";

            foreach(var s in str)
            {
                if (s == 'H' || s == 'Q' || s == '9')
                {
                    output =  "YES";
                    break;
                }

            }
            Console.WriteLine(output);
            Console.ReadLine();
        }

    }

}

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

namespace Codeforces
{
    class Class14
    {
        public static void Main()
        {
            string s = Console.ReadLine();
            char[] a = s.ToCharArray();
            for (int i = 0; i < s.Length; i++)
            {
                if (a[i] == 'H' || a[i] == 'Q' || a[i] == '9')
                {
                    Console.WriteLine("YES");
                    return;
                }
            }
            Console.WriteLine("NO");
        }
    }
}

using System;

namespace CFDay8
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9") )
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

using System;
namespace ConsoleApp2Framework
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Console.ReadLine().IndexOfAny("HQ9".ToCharArray()) >= 0 ? "YES" : "NO");
        }
    }
}

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

public class Program
{
	public static void Main()
	{
		string str=Console.ReadLine();
		if(str.Contains("H") || str.Contains("Q") || str.Contains("9"))
			Console.WriteLine("YES");
		else
			Console.WriteLine("NO");
	}
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var sb = new StringBuilder(str);
            var symb = new List<char>()
            {
                'H',
                'Q',
                '9',
            };
            for(int i=0;i<sb.Length;i++)
                if (!symb.Contains(sb[i]))
                {
                    sb.Remove(i, 1);
                    i--;
                }

            Console.WriteLine(sb.Length > 0 ? "YES" : "NO");
         //   Console.ReadKey();
        }

    }
}

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

namespace CSharp_Shell
{

    public static class Program
    {
        public static void Main()
        {
            int kaka=0;
           string palo=Console.ReadLine();
           for(int k=0 ; k<palo.Length ; k++)
           {
               char holas=palo[k];
               string palodios=Char.ToString(holas);
               if(palodios=="H")
               {
                   kaka++;
               }
               else if(palodios=="Q")
               {
                   kaka++;
               }
               else if(palodios=="9")
               {
                   kaka++;
               }
           }
           if(kaka>=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 Tests
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            bool No = true;
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i] == 'H' || input[i] == 'Q' || input[i] == '+' || input[i] == '9')
                {
                    Console.WriteLine("YES");
                    No = false;
                    break;
                }
            }
            if (No == true)
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

class Program
{
    public static void Main(string[] args)
    {
        string str = Console.ReadLine();
        int i;
        bool test = false;
        for (i = 0; i < str.Length; i++)
        {
            if (char.ToUpper(str[i]) == 'H' || char.ToUpper(str[i]) == 'Q' || str[i] == '9' || str[i] == '+')
            {
                test = true;
                break;
            }
        }
        if (test) Console.Write("YES");
        else Console.Write("NO");
        //Console.ReadKey();
    }
}

using System;

namespace CP14HQ
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            if(a.Contains("H") || a.Contains("Q") || a.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            if(a.Contains("+"))
            {
                int ind = a.IndexOf('+');
                if(char.IsDigit(a[ind-1]) || char.IsLetter(a[ind-1]))
                {
                    Console.WriteLine("NO");
                }
                else
                {
                    Console.WriteLine("YES");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
using System.Linq;

namespace CodeForce
{
    class _133A_HQ9_
    {
        static void Main()
        {
            string input = Console.ReadLine();

            if(input.Contains('H')
                || input.Contains('Q')
                || input.Contains('9')
                || input.Contains('+'))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main()
        {
            string x = Console.ReadLine();
            char c = x.FirstOrDefault();

            if (c.ToString() == "H" || c.ToString() == "Q" || c.ToString() == "9")
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

using System;

class HQ9Puls
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();
        if (s.Contains("Q") || s.Contains("H") || s.Contains("9") || s.Contains("+")) Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}

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

namespace prA {
    class Program {
        static void Main(string[] args) {
#if ONLINE_JUDGE
#else

            StreamWriter sw = new StreamWriter("output");
            Console.SetOut(sw);
            Console.SetIn(new StreamReader("input"));
#endif

            string s = Console.ReadLine();
            Console.WriteLine(s.IndexOfAny("HQ9+".ToCharArray()) != -1 ? "YES" : "NO");

#if ONLINE_JUDGE
#else
            sw.Close();
#endif
        }
    }
}

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

namespace A.HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            bool flage = false;
            input= Console.ReadLine();
            for (int i = 0; i < input.Length; i++)
            {
                if ((input[i] == '+') | (input[i] == 'H') | (input[i] == 'Q') | (input[i] == '9'))
                {
                    flage = true;
                    Console.WriteLine("YES");
                    break;
                }

            }

            if (flage == false)
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace LearningCSharp
{
    class _133A
    {
        static void Main() {
            string temp = Console.ReadLine();

            string ty = "";
            foreach (var item in temp)
            {
                if (item == 'H' || item == 'Q' ||  item == '9' || item == '+' )
                {
                    ty = "YES";break;
                }
            }

            if (ty != "YES")
            {

                Console.WriteLine("NO");

            }
            else {

                Console.WriteLine(ty);
            }
            //Console.ReadKey();

        }

    }
}

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

namespace HqPlus
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Regex.IsMatch(Console.ReadLine().ToLower(), @"[hq9]") ? "YES" : "NO");
        }
    }
}

using System;
using System.Linq;

namespace WorkerConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            if (line.Contains("H"))
            {
                Console.WriteLine("YES");
                return;
            }
            if (line.Contains("Q"))
            {
                Console.WriteLine("YES");
                return;
            }
            if (line.Contains("9"))
            {
                Console.WriteLine("YES");
                return;
            }
            if (line.Contains("+"))
            {
                Console.WriteLine("YES");
                return;
            }
            Console.WriteLine("NO");
        }
    }
}

//FelisDJ =*w*=

using System;

class Program
{
    static void Main(string[] args)
    {
        string p = Console.ReadLine();
        bool ck = false;
        for(int i =0 ;i<p.Length;i++)
        {
            if(p[i]=='H' || p[i]=='Q' || p[i]=='9' || p[i]=='+')
            {
                ck = true;
            }
        }
        if(ck)
            Console.WriteLine("YES");
        else
            Console.WriteLine("NO");
    }
}

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

namespace _133A_HQ
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var p = @"[H|Q|9]";
            Regex regex = new Regex(p);
            MatchCollection matches = regex.Matches(str);
            var t = new List<HashSet<string>>();
            if (matches.Count > 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            if (p.Contains("H") || p.Contains("Q") || p.Contains("+") || p.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            Console.ReadLine();

        }

    }
}

using System;

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

        foreach (var i in input)
        {
            if (i == 'H' || i == 'Q' || i == '9' || i == '+')
            {
                Console.WriteLine("YES");
                return;
            }
        }

        Console.WriteLine("NO");
    }
}

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

namespace codeforces2
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            for(int i=0; i < p.Length; i++)
            {
                if(p[i] == 'H' || p[i] == 'Q' || p[i] == '9' || p[i] == '+')
                {
                    Console.Write("YES");
                    break;
                }
                if(i == p.Length - 1)
                {
                    Console.Write("NO");
                }
            }
            Console.ReadLine();
        }
    }
}

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();
            bool z = false;
            for(int i=0; i<x.Length; i++){
                if(x[i]=='H' || x[i]=='Q' || x[i]=='9' || x[i]=='+'){
                    z = true;
                    break;
                }
            }

            if(z==false){
                Console.Write("NO");
            }
            else{
                Console.Write("YES");
            }
        }
    }
}

using System;

class Program
{
    static void Main(string[] args)
    {
        string input = Console.ReadLine();
        string output = "";
        for(int i = 0; i < input.Length; i++)
        {
            if (input[i] == 'H' || input[i] == 'Q' || input[i] == '9' || input[i] == '+')
            {
                output = "YES";
                break;
            }
            else if (i == input.Length - 1 && output != "YES")
            {
                output = "NO";
                break;
            }
        }
        Console.WriteLine(output);
    }

}

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

namespace mohity_bara_Csharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string g="",s = Console.ReadLine();
           bool flag=false;
            for (int i = 0; i < s.Length;i++ )
            {
               if(s.ElementAt(i)=='Q'||s.ElementAt(i)=='H'||s.ElementAt(i)=='9'
                   ||s.ElementAt(i)=='+')
               {
                   flag = true; break;
               }

            }
            if (flag == true) Console.Write("YES");
            else Console.Write("NO");

        }
    }
}

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

namespace shangool
{
    class Program
    {
        /*static int GetInt()
        {
            return Int32.Parse(Console.ReadLine());
        }

        static string[] GetArray()
        {
            return Console.ReadLine().Split(' ');
        }*/
        static void Main(string[] args)
        {
            string n;
            int i;
            n =Console.ReadLine();
            for (i = 0; i <n.Length; i++)
            {
                if (n[i] == 'H' || n[i] == 'h' || n[i]=='q' || n[i]=='Q' || n[i]=='9' || n[i]=='+') break;
            }
            if (i < n.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 Tram
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            HQ9Plus(input);

        }
        static void HQ9Plus(string input)
        {
            string instructions = "HQ9+";
            for (int i = 0; i < instructions.Length; i++)
            {
                if (input.Contains(instructions[i]))
                {
                    Console.WriteLine("YES");
                    break;
                }
                else
                {
                    if (i==instructions.Length-1)
                    {
                        Console.WriteLine("NO");
                    }

                }

            }

        }

    }
}

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

namespace HqPlus
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine(Regex.IsMatch(Console.ReadLine(), @"[HQhq9]") ? "YES" : "NO");
        }
    }
}

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

namespace Implemetation
{
    class Program
    {
        static void Main(string[] args)
        {
            //string input = Console.ReadLine();
            //Console.WriteLine(Football(input));
            //int result=Petya_and_Strings(Console.ReadLine(), Console.ReadLine());
            //Console.WriteLine(result);
            //Helpful_Maths(Console.ReadLine());
            //Word_Capitalization(Console.ReadLine());
            //Taxi(int.Parse(Console.ReadLine()));
            //Console.WriteLine(Math.Ceiling((double)13/5));

            //Console.WriteLine(Regex.IsMatch(Console.ReadLine(), @"[1-4]((\s[1-4])+)?"));

            //string text = Console.ReadLine();
            //string res=Chat_Room(text);
            //Console.WriteLine(res.Contains("hello") ? "YES" : "NO");

            //Console.WriteLine(CAPS_LOCK(Console.ReadLine()));

            //string input="";
            //for (int i = 0; i < 5; i++)
            //{
            //    input += Console.ReadLine();
            //    if (i != 4)
            //        input += "\n";
            //}

            //int NumberOfMoves= Beautiful_Matrix(input);
            //Console.WriteLine(input);

            Console.WriteLine(HQ9Plus(Console.ReadLine()));

        }

        static string HQ9Plus(string input)
        {
            if (!Regex.IsMatch(input, @"^[^\s]{1,100}$")) return "NO";
            if (input.Contains('H') ||
                input.Contains("Q") ||
                input.Contains('9') ||
                input.Contains('+') ||
                input.IndexOf("HQ") != -1 ||
                input.IndexOf("HQ9+") != -1)
                return "YES";
            return "NO";
        }

        //Not Solved yet
        static void Beautiful_Matrix(string TwoDimensionalArray)
        {
            //if (TwoDimensionalArray.Contains('1')) return 0;

            int[,] TwoDimensionalOfInts = new int[5,5];
            int [][] ar = TwoDimensionalArray.Split('\n')
                            .Select(row =>  row.Split(' ').Select(ite => int.Parse(ite)).ToArray())
                            .ToArray();

            for(int i = 0; i < ar.Length; i++)
            {
                for(int k = 0; k < ar[i].Length; k++)
                {

                }
            }

            //Recersion();
        }

        static int Recersion(string[] rows)
        {
            return 0;
        }

        static string CAPS_LOCK(string input)
        {

            if (!Regex.IsMatch(input, @"^[a-zA-Z ]{1,100}$")) return input;

                List<string> words = input.Split(' ').ToList();

                StringBuilder Result = new StringBuilder();
                foreach (string word in words)
                {

                    if (word == word.ToUpper() ||
                    (word.Substring(0, 1) == word.Substring(0, 1).ToLower()
                    && word.Substring(1, word.Length - 1) == word.Substring(1, word.Length - 1).ToUpper()
                    ))
                    {
                        StringBuilder temp = new StringBuilder();
                        foreach(char c in word)
                        {
                            if (char.IsLower(c))
                                temp.Append(char.ToUpper(c));
                            else
                                temp.Append(char.ToLower(c));
                        }
                        Result.Append(temp.ToString()+" ");
                    }
                    else
                    {
                        Result.Append(word + " ");
                    }

                }
                return Result.ToString();
        }
        static string Chat_Room(string text)
        {

            if (!Regex.IsMatch(text, @"^[a-z]{1,100}$")) return "";

            //string Result = "";
            Queue<char> StackResult = new Queue<char>();

            char[] word = { 'h', 'e', 'l', 'l', 'o' };
            int position = 0;

            foreach (char c in text)
            {

                if (word[position] == c)
                {
                    //Result += c;
                    StackResult.Enqueue(c);
                    position++;
                    if (position == word.Length) break;
                }
                else
                {
                    //if (Result != "")
                    if (StackResult.Count > 0)
                    {
                        if (StackResult.Peek() == c) continue;
                        //if (Result[position - 1] == c) continue;
                        //else break;
                    }
                }

            }

            //Console.WriteLine(Result.Contains("hello")?"YES":"NO");
            //Console.WriteLine(Result.Equals("hello")?"YES":"NO");
            return string.Join("", StackResult.ToArray());

        }
        static void Taxi(int input)
        {
            if (input < 1 || input > Math.Pow(10, 5)) return;
            string strnumbers = Console.ReadLine();
            if (!Regex.IsMatch(strnumbers, @"[1-4](\s[1-4])+")) return;

            int[] nums = strnumbers.Split(' ').Select(num => int.Parse(num)).ToArray();
            if (nums.Length != input) return;

            Console.WriteLine(Math.Ceiling((double)nums.Sum() / 4));

        }
        static void Word_Capitalization(string input)
        {
            if (input.Length > Math.Pow(10, 3)) return;

            string result;

            if (input[0] >= 97)
            {
                char c = input[0];
                int cint = c - 32;
                char res = (char)cint;
                result = res + input.Substring(1, input.Length - 1);
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(input);
            }
        }
        static void Helpful_Maths(string input)
        {
            string pattern = @"[1-3]{1,100}\+?";
            if (!Regex.IsMatch(input, pattern)) return;

            List<int> numbers = input.Split('+').Select(item => int.Parse(item)).ToList();
            numbers.Sort();
            string Result = "";

            foreach (int i in numbers)
                Result += i + "+";

            Console.WriteLine(Result.Substring(0, Result.Length - 1));
        }
        static int Petya_and_Strings(params string[] inputs)
        {
            if (inputs[0].Length != inputs[1].Length) return -1;

            return inputs[0].ToLower().CompareTo(inputs[1].ToLower());
        }
        static string Football(string input)
        {
            //string Pattern = @"^[0-1]{1,100}$";
            if (!Regex.IsMatch(input, @"^[0-1]{1,100}$")) return "NO";

            return input.Contains("0000000") || input.Contains("1111111") ? "YES" : "NO";
        }
        static bool Match(string text)
        {
            return Regex.IsMatch(text, @"^[0-1] [0-1] [0-1]$", RegexOptions.Singleline);
        }
        static int Team(int Problems)
        {
            string temp;
            int count = 0;
            string[] t = { "1 1 1", "1 1 0", "1 0 1", "0 1 1" };
            for (int i = 0; i < Problems; i++)
            {
                temp = Console.ReadLine();
                if (!Match(temp)) return 0;
                if (t.Contains(temp))
                {
                    count++;
                }
            }
            return count;
        }
        static int BitPlusPlus(int Operations)
        {

            int Result = 0;
            string temp;
            if (Operations >= 1 && Operations <= 150)
            {
                for (int i = 0; i < Operations; i++)
                {
                    temp = Console.ReadLine();
                    if (!Regex.IsMatch(temp, @"^([\+-]{2})?[a-zA-Z]([\+-]{2})?$")) return 0;

                    int index = temp.IndexOfAny(new char[] { '-', '+' });
                    if (index != -1 && index > 2)
                    {
                        if (temp[index] == '+')
                            Result++;
                        else
                            Result--;
                    }
                    else if (index != -1 && index < 2)
                    {
                        if (temp[index] == '+')
                            ++Result;
                        else
                            --Result;
                    }

                }
            }
            return Result;
        }
    }
}

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

namespace Implemetation
{
    class Program
    {
        static void Main(string[] args)
        {
            //string input = Console.ReadLine();
            //Console.WriteLine(Football(input));
            //int result=Petya_and_Strings(Console.ReadLine(), Console.ReadLine());
            //Console.WriteLine(result);
            //Helpful_Maths(Console.ReadLine());
            //Word_Capitalization(Console.ReadLine());
            //Taxi(int.Parse(Console.ReadLine()));
            //Console.WriteLine(Math.Ceiling((double)13/5));

            //Console.WriteLine(Regex.IsMatch(Console.ReadLine(), @"[1-4]((\s[1-4])+)?"));

            //string text = Console.ReadLine();
            //string res=Chat_Room(text);
            //Console.WriteLine(res.Contains("hello") ? "YES" : "NO");

            //Console.WriteLine(CAPS_LOCK(Console.ReadLine()));

            //string input="";
            //for (int i = 0; i < 5; i++)
            //{
            //    input += Console.ReadLine();
            //    if (i != 4)
            //        input += "\n";
            //}

            //int NumberOfMoves= Beautiful_Matrix(input);
            //Console.WriteLine(input);

            Console.WriteLine(HQ9Plus(Console.ReadLine()));

        }

        static string HQ9Plus(string input)
        {
            if (!Regex.IsMatch(input, @"^[^ \s]{1,100}$")) return "NO";
            if (input.Contains('H') ||
                input.Contains("Q") ||
                input.Contains('9') ||
                input.Contains('+'))
                return "YES";
            return "NO";
        }

        //Not Solved yet
        static void Beautiful_Matrix(string TwoDimensionalArray)
        {
            //if (TwoDimensionalArray.Contains('1')) return 0;

            int[,] TwoDimensionalOfInts = new int[5,5];
            int [][] ar = TwoDimensionalArray.Split('\n')
                            .Select(row =>  row.Split(' ').Select(ite => int.Parse(ite)).ToArray())
                            .ToArray();

            for(int i = 0; i < ar.Length; i++)
            {
                for(int k = 0; k < ar[i].Length; k++)
                {

                }
            }

            //Recersion();
        }

        static int Recersion(string[] rows)
        {
            return 0;
        }

        static string CAPS_LOCK(string input)
        {

            if (!Regex.IsMatch(input, @"^[a-zA-Z ]{1,100}$")) return input;

                List<string> words = input.Split(' ').ToList();

                StringBuilder Result = new StringBuilder();
                foreach (string word in words)
                {

                    if (word == word.ToUpper() ||
                    (word.Substring(0, 1) == word.Substring(0, 1).ToLower()
                    && word.Substring(1, word.Length - 1) == word.Substring(1, word.Length - 1).ToUpper()
                    ))
                    {
                        StringBuilder temp = new StringBuilder();
                        foreach(char c in word)
                        {
                            if (char.IsLower(c))
                                temp.Append(char.ToUpper(c));
                            else
                                temp.Append(char.ToLower(c));
                        }
                        Result.Append(temp.ToString()+" ");
                    }
                    else
                    {
                        Result.Append(word + " ");
                    }

                }
                return Result.ToString();
        }
        static string Chat_Room(string text)
        {

            if (!Regex.IsMatch(text, @"^[a-z]{1,100}$")) return "";

            //string Result = "";
            Queue<char> StackResult = new Queue<char>();

            char[] word = { 'h', 'e', 'l', 'l', 'o' };
            int position = 0;

            foreach (char c in text)
            {

                if (word[position] == c)
                {
                    //Result += c;
                    StackResult.Enqueue(c);
                    position++;
                    if (position == word.Length) break;
                }
                else
                {
                    //if (Result != "")
                    if (StackResult.Count > 0)
                    {
                        if (StackResult.Peek() == c) continue;
                        //if (Result[position - 1] == c) continue;
                        //else break;
                    }
                }

            }

            //Console.WriteLine(Result.Contains("hello")?"YES":"NO");
            //Console.WriteLine(Result.Equals("hello")?"YES":"NO");
            return string.Join("", StackResult.ToArray());

        }
        static void Taxi(int input)
        {
            if (input < 1 || input > Math.Pow(10, 5)) return;
            string strnumbers = Console.ReadLine();
            if (!Regex.IsMatch(strnumbers, @"[1-4](\s[1-4])+")) return;

            int[] nums = strnumbers.Split(' ').Select(num => int.Parse(num)).ToArray();
            if (nums.Length != input) return;

            Console.WriteLine(Math.Ceiling((double)nums.Sum() / 4));

        }
        static void Word_Capitalization(string input)
        {
            if (input.Length > Math.Pow(10, 3)) return;

            string result;

            if (input[0] >= 97)
            {
                char c = input[0];
                int cint = c - 32;
                char res = (char)cint;
                result = res + input.Substring(1, input.Length - 1);
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(input);
            }
        }
        static void Helpful_Maths(string input)
        {
            string pattern = @"[1-3]{1,100}\+?";
            if (!Regex.IsMatch(input, pattern)) return;

            List<int> numbers = input.Split('+').Select(item => int.Parse(item)).ToList();
            numbers.Sort();
            string Result = "";

            foreach (int i in numbers)
                Result += i + "+";

            Console.WriteLine(Result.Substring(0, Result.Length - 1));
        }
        static int Petya_and_Strings(params string[] inputs)
        {
            if (inputs[0].Length != inputs[1].Length) return -1;

            return inputs[0].ToLower().CompareTo(inputs[1].ToLower());
        }
        static string Football(string input)
        {
            //string Pattern = @"^[0-1]{1,100}$";
            if (!Regex.IsMatch(input, @"^[0-1]{1,100}$")) return "NO";

            return input.Contains("0000000") || input.Contains("1111111") ? "YES" : "NO";
        }
        static bool Match(string text)
        {
            return Regex.IsMatch(text, @"^[0-1] [0-1] [0-1]$", RegexOptions.Singleline);
        }
        static int Team(int Problems)
        {
            string temp;
            int count = 0;
            string[] t = { "1 1 1", "1 1 0", "1 0 1", "0 1 1" };
            for (int i = 0; i < Problems; i++)
            {
                temp = Console.ReadLine();
                if (!Match(temp)) return 0;
                if (t.Contains(temp))
                {
                    count++;
                }
            }
            return count;
        }
        static int BitPlusPlus(int Operations)
        {

            int Result = 0;
            string temp;
            if (Operations >= 1 && Operations <= 150)
            {
                for (int i = 0; i < Operations; i++)
                {
                    temp = Console.ReadLine();
                    if (!Regex.IsMatch(temp, @"^([\+-]{2})?[a-zA-Z]([\+-]{2})?$")) return 0;

                    int index = temp.IndexOfAny(new char[] { '-', '+' });
                    if (index != -1 && index > 2)
                    {
                        if (temp[index] == '+')
                            Result++;
                        else
                            Result--;
                    }
                    else if (index != -1 && index < 2)
                    {
                        if (temp[index] == '+')
                            ++Result;
                        else
                            --Result;
                    }

                }
            }
            return Result;
        }
    }
}

using System;

namespace Theatre_Square
{
    class Program
    {
         static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var output = "No";

            foreach(var s in str)
            {
                if (s == 'H' || s == 'Q' || s == '9' || s == '+')
                {
                    output =  "Yes";
                    break;
                }

            }
            Console.WriteLine(output);
            Console.ReadLine();
        }

    }

}

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

namespace PracticeForDummies
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
           for (int i = 0; i < str.Length; i++)
              {
                    if (str[i] == 'H' || str[i] == 'Q' || str[i] == '9' || str[i] == '+')
                    {
                        Console.WriteLine("YES");
                        break;
                    }

                    else
                    {
                        Console.WriteLine("NO");

                    }
               }

        }
    }
}

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

namespace Implemetation
{
    class Program
    {
        static void Main(string[] args)
        {
            //string input = Console.ReadLine();
            //Console.WriteLine(Football(input));
            //int result=Petya_and_Strings(Console.ReadLine(), Console.ReadLine());
            //Console.WriteLine(result);
            //Helpful_Maths(Console.ReadLine());
            //Word_Capitalization(Console.ReadLine());
            //Taxi(int.Parse(Console.ReadLine()));
            //Console.WriteLine(Math.Ceiling((double)13/5));

            //Console.WriteLine(Regex.IsMatch(Console.ReadLine(), @"[1-4]((\s[1-4])+)?"));

            //string text = Console.ReadLine();
            //string res=Chat_Room(text);
            //Console.WriteLine(res.Contains("hello") ? "YES" : "NO");

            //Console.WriteLine(CAPS_LOCK(Console.ReadLine()));

            //string input="";
            //for (int i = 0; i < 5; i++)
            //{
            //    input += Console.ReadLine();
            //    if (i != 4)
            //        input += "\n";
            //}

            //int NumberOfMoves= Beautiful_Matrix(input);
            //Console.WriteLine(input);

            Console.WriteLine(HQ9Plus(Console.ReadLine()));

        }

        static string HQ9Plus(string input)
        {
            if (!Regex.IsMatch(input, @"^[^\s]{1,100}$")) return "NO";
            return string.Join(" ", input.Select(c => c).Where(c => c.Equals('H') || c.Equals('Q') || c.Equals('9') || c.Equals('+')).Distinct().ToArray());
        }

        //Not Solved yet
        static void Beautiful_Matrix(string TwoDimensionalArray)
        {
            //if (TwoDimensionalArray.Contains('1')) return 0;

            int[,] TwoDimensionalOfInts = new int[5,5];
            int [][] ar = TwoDimensionalArray.Split('\n')
                            .Select(row =>  row.Split(' ').Select(ite => int.Parse(ite)).ToArray())
                            .ToArray();

            for(int i = 0; i < ar.Length; i++)
            {
                for(int k = 0; k < ar[i].Length; k++)
                {

                }
            }

            //Recersion();
        }

        static int Recersion(string[] rows)
        {
            return 0;
        }

        static string CAPS_LOCK(string input)
        {

            if (!Regex.IsMatch(input, @"^[a-zA-Z ]{1,100}$")) return input;

                List<string> words = input.Split(' ').ToList();

                StringBuilder Result = new StringBuilder();
                foreach (string word in words)
                {

                    if (word == word.ToUpper() ||
                    (word.Substring(0, 1) == word.Substring(0, 1).ToLower()
                    && word.Substring(1, word.Length - 1) == word.Substring(1, word.Length - 1).ToUpper()
                    ))
                    {
                        StringBuilder temp = new StringBuilder();
                        foreach(char c in word)
                        {
                            if (char.IsLower(c))
                                temp.Append(char.ToUpper(c));
                            else
                                temp.Append(char.ToLower(c));
                        }
                        Result.Append(temp.ToString()+" ");
                    }
                    else
                    {
                        Result.Append(word + " ");
                    }

                }
                return Result.ToString();
        }
        static string Chat_Room(string text)
        {

            if (!Regex.IsMatch(text, @"^[a-z]{1,100}$")) return "";

            //string Result = "";
            Queue<char> StackResult = new Queue<char>();

            char[] word = { 'h', 'e', 'l', 'l', 'o' };
            int position = 0;

            foreach (char c in text)
            {

                if (word[position] == c)
                {
                    //Result += c;
                    StackResult.Enqueue(c);
                    position++;
                    if (position == word.Length) break;
                }
                else
                {
                    //if (Result != "")
                    if (StackResult.Count > 0)
                    {
                        if (StackResult.Peek() == c) continue;
                        //if (Result[position - 1] == c) continue;
                        //else break;
                    }
                }

            }

            //Console.WriteLine(Result.Contains("hello")?"YES":"NO");
            //Console.WriteLine(Result.Equals("hello")?"YES":"NO");
            return string.Join("", StackResult.ToArray());

        }
        static void Taxi(int input)
        {
            if (input < 1 || input > Math.Pow(10, 5)) return;
            string strnumbers = Console.ReadLine();
            if (!Regex.IsMatch(strnumbers, @"[1-4](\s[1-4])+")) return;

            int[] nums = strnumbers.Split(' ').Select(num => int.Parse(num)).ToArray();
            if (nums.Length != input) return;

            Console.WriteLine(Math.Ceiling((double)nums.Sum() / 4));

        }
        static void Word_Capitalization(string input)
        {
            if (input.Length > Math.Pow(10, 3)) return;

            string result;

            if (input[0] >= 97)
            {
                char c = input[0];
                int cint = c - 32;
                char res = (char)cint;
                result = res + input.Substring(1, input.Length - 1);
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(input);
            }
        }
        static void Helpful_Maths(string input)
        {
            string pattern = @"[1-3]{1,100}\+?";
            if (!Regex.IsMatch(input, pattern)) return;

            List<int> numbers = input.Split('+').Select(item => int.Parse(item)).ToList();
            numbers.Sort();
            string Result = "";

            foreach (int i in numbers)
                Result += i + "+";

            Console.WriteLine(Result.Substring(0, Result.Length - 1));
        }
        static int Petya_and_Strings(params string[] inputs)
        {
            if (inputs[0].Length != inputs[1].Length) return -1;

            return inputs[0].ToLower().CompareTo(inputs[1].ToLower());
        }
        static string Football(string input)
        {
            //string Pattern = @"^[0-1]{1,100}$";
            if (!Regex.IsMatch(input, @"^[0-1]{1,100}$")) return "NO";

            return input.Contains("0000000") || input.Contains("1111111") ? "YES" : "NO";
        }
        static bool Match(string text)
        {
            return Regex.IsMatch(text, @"^[0-1] [0-1] [0-1]$", RegexOptions.Singleline);
        }
        static int Team(int Problems)
        {
            string temp;
            int count = 0;
            string[] t = { "1 1 1", "1 1 0", "1 0 1", "0 1 1" };
            for (int i = 0; i < Problems; i++)
            {
                temp = Console.ReadLine();
                if (!Match(temp)) return 0;
                if (t.Contains(temp))
                {
                    count++;
                }
            }
            return count;
        }
        static int BitPlusPlus(int Operations)
        {

            int Result = 0;
            string temp;
            if (Operations >= 1 && Operations <= 150)
            {
                for (int i = 0; i < Operations; i++)
                {
                    temp = Console.ReadLine();
                    if (!Regex.IsMatch(temp, @"^([\+-]{2})?[a-zA-Z]([\+-]{2})?$")) return 0;

                    int index = temp.IndexOfAny(new char[] { '-', '+' });
                    if (index != -1 && index > 2)
                    {
                        if (temp[index] == '+')
                            Result++;
                        else
                            Result--;
                    }
                    else if (index != -1 && index < 2)
                    {
                        if (temp[index] == '+')
                            ++Result;
                        else
                            --Result;
                    }

                }
            }
            return Result;
        }
    }
}

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

namespace MainProgram
{

    class Program
    {
        static void Main(string[] args)
        {
            var d = Console.ReadLine();
            var found = false;
            foreach(var a in d)
            {
                if(a == 'H' || a == 'Q' || a == '9')
                    found = true;
                break;
            }
            Console.WriteLine(found ? "YES" : "NO");
        }

        static long[] ParseStringIntoArrayOfInts(string input)
        {
            var list = new List<long>();
            var splittedOut = input.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            foreach(var s in splittedOut)
            {
                list.Add(long.Parse(s));
            }
            return list.ToArray();
        }
    }
}

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

namespace Hulk
{
    class Program
    {
        static void Main(string[] args)
        {
          here:  string p = Console.ReadLine();
            if(p.Length<1||p.Length>100)
            {
                goto here;
            }
            char[] arr = p.ToCharArray();
            bool check = false;
            for(int i=0;i<arr.Length;i++)
            {
                if(arr[i]=='H'||arr[i]=='Q'||arr[i]=='+'||arr[i]=='9')
                {
                    check=true;
                    break;
                }
            }
            if(check==true)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace codeforces
{
    class HQ9_
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            for(int i = 0; i < a.Length; i++)
            {
                if(a[i] == 'H' || a[i] == 'Q' || a[i] == '9')
                {
                    Console.WriteLine("YES");
                    break;
                }
                else if(i+1 == a.Length && a[i] != 'H' || a[i] != 'Q' || a[i] != '9')
                {
                    Console.WriteLine("NO");
                    break;
                }
            }
            //Console.ReadKey();
        }
    }
}

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

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        bool w = false;
        for (int p = 0; p < str.Length; p++) {
            char c = str[p];
            if (c == 'H' | c == 'Q' | c == '9' | c == '+')
            {
                w = true;
                break;
            }
        }
        if (w) {
            Console.WriteLine("YES");
        }
        else
            Console.WriteLine("NO");
    }
}

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

namespace hq9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains('H') || s.Contains('Q') || s.Contains('9') || s.Contains('+'))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().solve();
        }
        void solve()
        {
            string s = nextToken();
            bool good = s.IndexOf('H') != -1 || s.IndexOf('9') != -1;
            System.Console.WriteLine(good ? "YES" : "NO");
        }
        String[] tokens;
        int pointer;
        public long nextLong()
        {
            return long.Parse(nextToken());
        }
        public int nextInt()
        {
            return int.Parse(nextToken());
        }
        public string nextToken()
        {
            while (tokens == null || tokens.Length == 0 || pointer >= tokens.Length)
            {
                tokens = System.Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                pointer = 0;
            }
            return tokens[pointer++];
        }
    }
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string p= Console.ReadLine();
            if (p.Contains("H") || p.Contains("Q")||p.Contains("9")||p.Contains("+"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

using System;

namespace CP14HQ
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            if(a.Contains("H") || a.Contains("Q") || a.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else if(a.Contains("+"))
            {
                int ind = a.IndexOf('+');
                if(a.IndexOf('+') ==0)
                {
                    Console.WriteLine("NO");
                }
                else if(char.IsDigit(a[ind-1]) || char.IsLetter(a[ind-1]))
                {
                    Console.WriteLine("NO");
                }
                else
                {
                    Console.WriteLine("YES");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = Console.ReadLine();
            if (p != "")
            {
                if ((p.Contains("H") == true) || (p.Contains("Q") == true) || (p.Contains("9") == true) ||
                    (p.Contains("+") == true))
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

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

namespace Hulk
{
    class Program
    {
        static void Main(string[] args)
        {
          here:  string p = Console.ReadLine();
            if(p.Length<1||p.Length>100)
            {
                goto here;
            }
            char[] arr = p.ToCharArray();
            bool check = false;
            for(int i=0;i<arr.Length;i++)
            {
                if (arr[i] == 'H' || arr[i] == 'Q' || arr[i] == '+' || arr[i] == '9')
                {
                    check=true;
                    break;
                }
            }
            if(check==true)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;

namespace hw010219
{
    class Program
    {
        static void Main(string[] args)
        {
            #region CodeForces: 282A
            /*
            int x = 0;
            int n = 0;
            string str;

            do
            {
                n = int.Parse(Console.ReadLine());
            } while (!(n>=1 && n<=150));

            while (n!=0) {
                str = Console.ReadLine();
                if (str == "++x" || str == "++X" || str == "x++" || str == "X++")
                {
                    ++x;
                    --n;
                }
                else if (str == "--x" || str == "--X" || str == "x--" || str == "X--") {
                    --x;
                    --n;
                }
            }

            Console.WriteLine($"{x}");
            */
            #endregion

            #region CodeForce: 112A
            /*
            string str1, str2;
            Console.WriteLine(String.Compare(str1=(Console.ReadLine()).ToLower(),str2=(Console.ReadLine()).ToLower()));
            */
            #endregion

            #region CodeForce: 116A
            /*
            int n = 0;

            do
            {
                n = int.Parse(Console.ReadLine());
            } while (!(n >= 2 && n <= 1000));

            int length = n;

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

            int temp = 0;
            string[] str;

            while (n != 0)
            {
                if (n == length)
                {
                    do
                    {
                        str = Console.ReadLine().Split();
                        a[0] = int.Parse(str[0]);
                        b[0] = int.Parse(str[1]);
                    } while (a[0] != 0);
                }
                else if (n == 1)
                {
                    temp = 0;
                    do
                    {
                        for (int i = 0; i <= length - 2; i++)
                        {
                            temp += (b[i] - a[i]);
                        }
                        str = Console.ReadLine().Split();
                        a[length - 1] = int.Parse(str[0]);
                        b[length - 1] = int.Parse(str[1]);
                    } while (!(b[length - 1] == 0 && a[length - 1] == temp));
                }
                else
                {
                    temp = 0;
                    do
                    {
                        for (int i = 0; i <= length - n - 1; i++)
                        {
                            temp += (b[i] - a[i]);
                        }
                        str = Console.ReadLine().Split();
                        a[length - n] = int.Parse(str[0]);
                        b[length - n] = int.Parse(str[1]);
                    } while (!(a[length - n] <= temp));
                }
                --n;
            }

            int max = 0;
            temp = 0;
            for (int i = 0; i < length; i++)
            {
                temp += b[i] - a[i];
                if (temp > max) max = temp;
            }
            Console.WriteLine($"{max}");
            */
            #endregion

            #region CodeForce: 133A
            string p = Console.ReadLine();
            for (int i = 0; i < p.Length; i++) {
                if (p[i] == 'H' || p[i] == 'Q' || p[i] == '9') {
                    Console.WriteLine("YES");
                    break;
                }
                else
                {
                    Console.WriteLine("NO");
                    break;
                }
            }
            #endregion
        }
    }
}

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

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();
        bool w = false;
        for (int p = 0; p < str.Length; p++) {
            char c = str[p];
            if (c > 33 & c <= 126) c = '!';
            if (c == 'H' | c == 'Q' | c == '9' | c == '+')
            {
                w = true;
                break;
            }
        }
        if (w) {
            Console.WriteLine("YES");
        }
        else
            Console.WriteLine("NO");
    }
}

using System;
using System.Linq;

namespace Application
{
    class Program
    {
        static void Main(string[] args)
        {
            string inp = Console.ReadLine();

        	Console.WriteLine
        		(
        			inp.Contains('H')
        			|| inp.Contains('Q')
        			|| inp.Contains('9')
        			&& inp.Contains('+') ?
        			"YES" : "NO"
        		);
        }
    }
}

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

namespace _133A_HQ
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            var p = @"[H|Q|9|+]";
            Regex regex = new Regex(p);
            MatchCollection matches = regex.Matches(str);
            var t = new List<HashSet<string>>();
            if (matches.Count > 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace HQ_Code
{
    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            if (p.Contains('H') || p.Contains('Q') || p.Contains('9') || p.Contains('+'))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            if ((str.Contains("H") == true) || (str.Contains("H") == true) || (str.Contains("9") == true) || (str.Contains("+") == true))
            {
                Console.WriteLine("YES");
            }
            else { Console.WriteLine("NO"); };
        }
    }
}

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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string [] symbols = new string[] {"H","Q","+","9"};

            {
                if (line.Contains(symbols[0]))
                {

                    Console.WriteLine("YES");
                }

                else if (line.Contains(symbols[1]))
                {

                    Console.WriteLine("YES");
                }

                else if (line.Contains(symbols[2]))
                {

                    Console.WriteLine("YES");
                }

               else if (line.Contains(symbols[3]))
                {

                    Console.WriteLine("YES");
                }

                else

                    Console.WriteLine("NO");
                }

                Console.ReadLine();
            }
        }
    }

using System;

namespace Problem___122A___A._HQ9Plus
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = Console.ReadLine().ToUpper();
            if (p.Length>=1 && p.Length<=100)
            {
                bool b = false;
                for (int i = 0; i < p.Length; i++)
                {
                    if (p[i]=='H' || p[i]=='Q' || p[i]=='9')
                    {
                        b = true;
                    }
                }

                if (b!=false)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

using System;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        string c = Console.ReadLine();
        RunCode( c);
        Console.ReadLine();
    }
    static void RunCode(string code)
    {
        int c = 0;
        for (int i = 0; i < code.Length; i++)
        {
            char l = code[i];
            l = char.ToUpperInvariant(l);
            if (l == 'H')
            {
                c = 1;
            }
            else if (l == 'Q')
            {
                c = 1;
            }
            else if (l == '9')
            {
                c = 1;
            }
            else if (l == '+')
            {
                c = 1;
            }
        }
        if (c == 1)
        {
            Console.WriteLine("YES");
        }
        else {
            Console.WriteLine("NO");
        }
    }

}

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

namespace ProgrammingContest
{
    class Program
    {
        public static void Main(string[] args)
        {
            var p = Console.ReadLine();

            if (p[0] == 'H' || p[0] == 'Q' || p[0] == '9')
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

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

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9") || s.Contains("+"))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
            Console.ReadLine();
        }
    }
}

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

namespace ConsoleApplication166
{

    class Program
    {
        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            Console.WriteLine(p.Contains('H') | p.Contains('Q') | p.Contains('9') ? "Yes" : "No");
        }
    }
}

using System;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main()
        {
            string x = Console.ReadLine();
            char c = x.FirstOrDefault();

            if (c.ToString() == "H" || c.ToString() == "Q" || c.ToString() == "9" || c.ToString() == "+")
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;

class TheProgrammingContestDivTwo
{
    public static void Main()
    {
        var command = Console.ReadLine();
        char[] ch = new char[] { 'H', 'Q', '9', '+' };
        if (res(command, ch))
            Console.WriteLine("YES");
        else
            Console.WriteLine("NO");
    }

    private static bool res(string command, char[] ch)
    {
        for (int i = 0; i < command.Length; i++)
            for (int j = 0; j < ch.Length; j++)
                if (command[i] == ch[j]) return true;
        return false;
    }
}

using System;

namespace CodeForces
{
    class Program
    {
        static void Main(string[] args)
        {
            string lines = Console.ReadLine();

            string result = "NO";

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i] == 'H' || lines[i] == 'Q' || lines[i] == '9' || lines[i] == '+' || lines.Contains("72") || lines.Contains("81") || lines.Contains("57") || lines.Contains("43"))
                {
                    result = "YES";
                    break;
                }
            }

            Console.WriteLine(result);
        }
    }
}

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

namespace ConsoleApplication1
{
    class Program
    {
        public static void Main()
        {
            var command = Console.ReadLine();
            var result = "NO";
            for(var i = 0; i < command.Length; i++)
            {
                if (command[i] == 'H' || command[i] == 'Q' || command[i] == '+' || command[i] == '9')
                    result = "YES";
            }
            Console.WriteLine(result);
        }
    }
}

using System;
using System.Text;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string s;
            s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("+") || s.Contains("9")) Console.WriteLine("YES");
            else Console.WriteLine("NO");

        }
    }

}

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

namespace HQ9____Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (s.Contains("H"))
            {
                Console.WriteLine("YES");
            }
            else if (s.Contains("Q"))
            {
                Console.WriteLine("YES");
            }
            else if (s.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            else if (s.Contains("+"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }
    }
}

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

namespace Codeforces
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine(); ;
            string[] arr = { "H", "Q" , "+", "9"};
            var answer = "";
            foreach (var c in arr)
            {
                if (input.Contains(c))
                    answer += "YES";
                else
                    answer += "NO";
            }
            if (answer.Contains("YES"))
                Console.Write("YES");
            else
                Console.Write("NO");
            //Console.ReadKey();
        }
    }
}

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

namespace A_HQ9
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string s = Console.ReadLine();
            char[] find = { 'H', 'Q', '9', };
            string temp = s.Trim(find);
            s = s.Trim(temp.ToCharArray());
            if (s.Length == 0)
                Console.WriteLine("NO");
            else
                Console.WriteLine("YES");

        }
    }
}

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

namespace c96a
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            bool ans=false;
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9' || s[i] == '+')
                {
                    ans = true;
                }
            }
            if (ans)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

namespace o
{
    using System;

    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            if (s.Contains("H") || s.Contains("Q") || s.Contains("9") || s.Contains("+"))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ProgrammingContest
{
    class Program
    {
        public static void Main(string[] args)
        {
            var p = Console.ReadLine();

            if ((p[0] == 'H' || p[0] == 'Q' || p[0] == '9' || p[0] == '+')&& p.Length>1)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

        }
    }
}

using System;

namespace _133a
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = s.Length;
            bool ok = true;
            for (int i = 0; i < n; ++i)
                if (s[i] == 'H' || s[i] == 'Q' || s[i] == '9' || s[i] == '+')
                { ok = false; break; }
            Console.WriteLine(ok ? "NO" : "YES");
        }
    }
}

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

namespace Timus
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var str = GetStr();
            string res = str.Contains('H') || str.Contains('Q') || str.Contains('9') || str.Contains('+') ? "YES" : "NO";
            Console.WriteLine(res);
            Console.ReadLine();
        }

        #region Utils
        private const double Epsilon = double.Epsilon;

        private static string GetStr()
        {

            return Console.ReadLine();
        }

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

        private static string[] GetStrs(int cnt)
        {
            var s = new string[cnt];
            for (var i = 0; i < cnt; ++i)
                s[i] = GetStr();
            return s;
        }

        private static int GetInt()
        {
            return int.Parse(GetStr());
        }

        private static void GetInts(out int a, out int b)
        {
            var q = GetInts();
            a = q[0];
            b = q[1];
        }

        private static void GetInts(out int a, out int b, out int c)
        {
            var q = GetInts();
            a = q[0];
            b = q[1];
            c = q[2];
        }

        private static int[] GetInts()
        {
            var s = GetStrs();
            var a = new int[s.Length];
            for (var i = 0; i < s.Length; ++i)
                a[i] = int.Parse(s[i]);
            return a;
        }

        private static long GetLong()
        {
            return long.Parse(GetStr());
        }

        private static IEnumerable<long> GetLongs()
        {
            return GetStrs().Select(long.Parse);
        }

        private static void WriteDouble<T>(T d)
        {
            Console.WriteLine(string.Format("{0:0.000000000}", d).Replace(',', '.'));
        }

        private static void WL<T>(T s)
        {
            Console.WriteLine(s);
        }

        private static void W<T>(T s)
        {
            Console.Write(s);
        }

        private static void Assert(bool b)
        {
            if (!b) throw new Exception();
        }

        private static void Swap<T>(ref T a, ref T b)
        {
            var temp = a;
            a = b;
            b = temp;
        }

        #endregion
    }
    public class  Money
    {
        public int Position { get; set; }
        public int MinCountForChange { get; set; }
        public int HigherValue { get; set; }
    }

}

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

namespace HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            bool x = false;

            for (int i = 0 ; i<= line.Length-1; i++)
            {
                if (line[0] == '+')
                {
                    x = false;

                }

                 if (line[i] == 'H' || line[i] == 'Q' || line[i] == '9')
                {
                    x = true;

                }

            }
            if (x == true)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            }
        }
    }

using System;

namespace Test
{
    class Program
    {
      static void Main(string[] args)
        {
            string word = Console.ReadLine();
            if (word.Contains("H") || word.Contains("Q") || word.Contains("9") || word.Contains("+"))
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");
        }
    }
}

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

class Program
{
    public static void Main(string[] args)
    {
        string str = Console.ReadLine();
        int i;
        bool test = false;
        for (i = 0; i < str.Length; i++)
        {
            if (str[i] == 'H' || str[i] == 'Q' || str[i] == '9' || str[i] == '+')
            {
                test = true;
                break;
            }
        }
        if (test) Console.Write("Yes");
        else Console.Write("No");
        //Console.ReadKey();
    }
}

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

namespace HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            var Word = Console.ReadLine();
            var Code = "HQ9";

            foreach (var c in Word)
            {
                if (!Code.Contains(c.ToString()))
                    Console.WriteLine("YES");
                else
                    Console.WriteLine("NO");

            }

            //if (Word.Contains("H") || Word.Contains("Q") || Word.Contains("9"))
                //Console.WriteLine("YES");
           // else
               // Console.WriteLine("NO");
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace CodeForces
{
    public class Test
    {
        public static void Main()
        {
            string num = Console.ReadLine();
            int count = 0;
            for (int t = 0; t < num.Length; t++)
            {
                if (num[t] == 'H' || num[t] == 'Q' || num[t] == '9')
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    count++;
                }
            }
            if(count==num.Length)
            Console.WriteLine("NO");
        }
    }
}

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

namespace PracticeForDummies
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
            for ( int i=0; i<str.Length; i++)
            {

                if (str[i] == 'H' || str[i] == 'Q' || str[i] == '9' || str[i] == '+')
                {
                    Console.WriteLine("YES");
                    break;
                }

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

            }

        }
    }
}

using System;

public class Test
{
	public static void Main()
	{
		string input = Console.ReadLine();

		Console.WriteLine(GetHQ9p(input));
	}

	public static string GetHQ9p(string input)
	{
		char[] alphabet = new char[]{'H','Q','9','+'};

		foreach(char a in input){
			foreach(char a2 in alphabet){
				if(a==a2){
					return "YES";
				}
			}
		}
		return "NO";
	}
}

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

namespace A.HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            input = input.ToUpper();
            char[] pro = "HQ9".ToCharArray();
            int sum=0;
            for(int j=0;j<pro.Length;j++)
            {
                if (input.Contains(pro[j]))
                {
                    Console.WriteLine("YES");
                    break;
                }
                else
                    sum++;
            }
            if (sum == pro.Length)
                Console.WriteLine("NO");

        }
    }
}

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

namespace ConsoleApplication8
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string [] symbols = new string[] {"H","Q","+","9"};

            {
                if (line.Contains(symbols[0]))
                {

                    Console.WriteLine("YES");
                }

                else if (line.Contains(symbols[1]))
                {

                    Console.WriteLine("YES");
                }

                else if (line.Contains(symbols[2]))
                {

                    Console.WriteLine("YES");
                }

               else if (line.Contains(symbols[3]))
                {

                    Console.WriteLine("YES");
                }

                else

                    Console.WriteLine("NO");
                }

            }
        }
    }

using System;

namespace Problem___122A___A._HQ9Plus
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = Console.ReadLine().ToUpper();
            if (p.Length>=1 && p.Length<=100)
            {
                bool b = false;
                for (int i = 0; i < p.Length; i++)
                {
                    if (p[i]=='H' || p[i]=='Q' || p[i]=='9')
                    {
                        b = true;
                    }
                }

                if (b!=false)
                {
                    Console.WriteLine("YES");
                }
                else
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

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

namespace HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            if(input.ToUpper()[0]=='H' || input.ToUpper()[0]=='Q')
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

using System;

namespace CP14HQ
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            if(a.Contains("H") || a.Contains("Q") || a.Contains("9"))
            {
                Console.WriteLine("YES");
            }
            if(a.Contains("+"))
            {
                int ind = a.IndexOf('+');
                if(char.IsDigit(a[ind-1]) || char.IsLetter(a[ind-1]))
                {
                    Console.WriteLine("NO");
                }
                else
                {
                    Console.WriteLine("YES");
                }
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

public class Program
{
	public static void Main()
	{
		string str=Console.ReadLine();
		if(str.Contains("H") || str.Contains("h") || str.Contains("Q") || str.Contains("q") || str.Contains("9") || str.Contains("+"))
			Console.WriteLine("YES");
		else
			Console.WriteLine("NO");
	}
}

using System;

public class Program
{
    static void Main()
    {
        string input = Console.ReadLine();
        if (input.Contains("H") ||
            input.Contains("Q") ||
            input.Contains("9") ||
            input.Contains("+"))
            Console.WriteLine("YES");
        else Console.WriteLine("NO");
    }
}

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

namespace ConsoleApplication10
{
    class Program
    {

        static void Main(string[] args)
        {
            string p = Console.ReadLine();
            if ((p.Contains("H") || (p.Contains("Q")) || (p.Contains("+")) || (p.Contains("9"))))
            {
                Console.WriteLine("YES");
            }
            else
                Console.WriteLine("NO");
        }
    }
}

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

namespace HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            bool x = false;

            for (int i = 0 ; i<= line.Length-1; i++)
            {
                if (line[0] == '+')
                {
                    x = false;
                    break;
                }

                 if (line[i] == 'H' || line[i] == 'Q' || line[i] == '9')
                {
                    x = true;

                }

            }
            if (x == true)
                Console.WriteLine("YES");
            else
                Console.WriteLine("NO");

            }
        }
    }

using System;
using System.Collections.Generic;
class Program
{
    static void Main()
    {
        string c = Console.ReadLine();
        RunCode( c);
        Console.ReadLine();
    }
    static void RunCode(string code)
    {
        int c = 0;
        if(code[code.Length-1] !='+'){
        for (int i = 0; i < code.Length; i++)
        {

            char l = code[i];
            //l = char.ToUpperInvariant(l);
            if (l == 'H')
            {
                c ++;
            }
            else if (l == 'Q')
            {
                c++;
            }
            else if (l == '9')
            {
                c++;
            }
        }
        }
        if (code.Length>1 &&code[code.Length-1] == '+')
        {
            string sub=code.Substring(0,code.Length-2);
            try
            {
                int cc = Convert.ToInt32(sub);

            }
            catch
            {
                if(sub.Length>0)
                c++;
            }

        }

     if(c>0)
      {
        Console.WriteLine("YES");
      }
       if (c == 0)
       {
           Console.WriteLine("NO");
       }
    }

}

using System;

public class Program
{
	public static void Main()
	{
		string str = Console.ReadLine();
		string res = "NO";
		for(int i=0; i<str.Length; i++){
			if(str[i]=='H' || str[i]=='Q' || str[i]=='9' || str[i]=='+'){
				res = "YES";
			}
		}
		Console.WriteLine(res);
	}
}

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

namespace PracticeForDummies
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = Console.ReadLine();
           for (int i = 0; i < str.Length; i++)
              {
                    if (str[i] == 'H' || str[i] == 'Q' || str[i] == '9' || str[i] == '+')
                    {
                        Console.WriteLine("YES");
                        break;
                    }

                    else
                    {
                        Console.WriteLine("NO");

                    }
               }

        }
    }
}

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

namespace Implemetation
{
    class Program
    {
        static void Main(string[] args)
        {
            //string input = Console.ReadLine();
            //Console.WriteLine(Football(input));
            //int result=Petya_and_Strings(Console.ReadLine(), Console.ReadLine());
            //Console.WriteLine(result);
            //Helpful_Maths(Console.ReadLine());
            //Word_Capitalization(Console.ReadLine());
            //Taxi(int.Parse(Console.ReadLine()));
            //Console.WriteLine(Math.Ceiling((double)13/5));

            //Console.WriteLine(Regex.IsMatch(Console.ReadLine(), @"[1-4]((\s[1-4])+)?"));

            //string text = Console.ReadLine();
            //string res=Chat_Room(text);
            //Console.WriteLine(res.Contains("hello") ? "YES" : "NO");

            //Console.WriteLine(CAPS_LOCK(Console.ReadLine()));

            //string input="";
            //for (int i = 0; i < 5; i++)
            //{
            //    input += Console.ReadLine();
            //    if (i != 4)
            //        input += "\n";
            //}

            //int NumberOfMoves= Beautiful_Matrix(input);
            //Console.WriteLine(input);

            Console.WriteLine(HQ9Plus(Console.ReadLine()));

        }

        static string HQ9Plus(string input)
        {
            if (!Regex.IsMatch(input, @"^[^ ]{1,100}$")) return "NO";
            //string Filterd=string.Join("", input.Select(c => c)
            //                    //.Where(c => c.Equals('H') || c.Equals('Q') || c.Equals('9') || c.Equals('+'))
            //                    .Where(c=> c > 33 && c <= 126)
            //                    .Distinct()
            //                    .ToArray());
            string temp = "";
            foreach (char c in input)
            {
                if (c < 33 || c > 126)
                    temp += c;
            }
            return temp.IndexOfAny(new char[] { 'Q', 'H', '9', '+' }) >= 0 ? "YES" : "NO";
            //if (Filterd.IndexOfAny(new char[] { 'Q','H','+','9'}) != -1)
            //    return "YES\t" + Filterd;
            //return "NO\t" +Filterd;

        }

        //Not Solved yet
        static void Beautiful_Matrix(string TwoDimensionalArray)
        {
            //if (TwoDimensionalArray.Contains('1')) return 0;

            int[,] TwoDimensionalOfInts = new int[5, 5];
            int[][] ar = TwoDimensionalArray.Split('\n')
                            .Select(row => row.Split(' ').Select(ite => int.Parse(ite)).ToArray())
                            .ToArray();

            for (int i = 0; i < ar.Length; i++)
            {
                for (int k = 0; k < ar[i].Length; k++)
                {

                }
            }

            //Recersion();
        }

        static int Recersion(string[] rows)
        {
            return 0;
        }

        static string CAPS_LOCK(string input)
        {

            if (!Regex.IsMatch(input, @"^[a-zA-Z ]{1,100}$")) return input;

            List<string> words = input.Split(' ').ToList();

            StringBuilder Result = new StringBuilder();
            foreach (string word in words)
            {

                if (word == word.ToUpper() ||
                (word.Substring(0, 1) == word.Substring(0, 1).ToLower()
                && word.Substring(1, word.Length - 1) == word.Substring(1, word.Length - 1).ToUpper()
                ))
                {
                    StringBuilder temp = new StringBuilder();
                    foreach (char c in word)
                    {
                        if (char.IsLower(c))
                            temp.Append(char.ToUpper(c));
                        else
                            temp.Append(char.ToLower(c));
                    }
                    Result.Append(temp.ToString() + " ");
                }
                else
                {
                    Result.Append(word + " ");
                }

            }
            return Result.ToString();
        }
        static string Chat_Room(string text)
        {

            if (!Regex.IsMatch(text, @"^[a-z]{1,100}$")) return "";

            //string Result = "";
            Queue<char> StackResult = new Queue<char>();

            char[] word = { 'h', 'e', 'l', 'l', 'o' };
            int position = 0;

            foreach (char c in text)
            {

                if (word[position] == c)
                {
                    //Result += c;
                    StackResult.Enqueue(c);
                    position++;
                    if (position == word.Length) break;
                }
                else
                {
                    //if (Result != "")
                    if (StackResult.Count > 0)
                    {
                        if (StackResult.Peek() == c) continue;
                        //if (Result[position - 1] == c) continue;
                        //else break;
                    }
                }

            }

            //Console.WriteLine(Result.Contains("hello")?"YES":"NO");
            //Console.WriteLine(Result.Equals("hello")?"YES":"NO");
            return string.Join("", StackResult.ToArray());

        }
        static void Taxi(int input)
        {
            if (input < 1 || input > Math.Pow(10, 5)) return;
            string strnumbers = Console.ReadLine();
            if (!Regex.IsMatch(strnumbers, @"[1-4](\s[1-4])+")) return;

            int[] nums = strnumbers.Split(' ').Select(num => int.Parse(num)).ToArray();
            if (nums.Length != input) return;

            Console.WriteLine(Math.Ceiling((double)nums.Sum() / 4));

        }
        static void Word_Capitalization(string input)
        {
            if (input.Length > Math.Pow(10, 3)) return;

            string result;

            if (input[0] >= 97)
            {
                char c = input[0];
                int cint = c - 32;
                char res = (char)cint;
                result = res + input.Substring(1, input.Length - 1);
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(input);
            }
        }
        static void Helpful_Maths(string input)
        {
            string pattern = @"[1-3]{1,100}\+?";
            if (!Regex.IsMatch(input, pattern)) return;

            List<int> numbers = input.Split('+').Select(item => int.Parse(item)).ToList();
            numbers.Sort();
            string Result = "";

            foreach (int i in numbers)
                Result += i + "+";

            Console.WriteLine(Result.Substring(0, Result.Length - 1));
        }
        static int Petya_and_Strings(params string[] inputs)
        {
            if (inputs[0].Length != inputs[1].Length) return -1;

            return inputs[0].ToLower().CompareTo(inputs[1].ToLower());
        }
        static string Football(string input)
        {
            //string Pattern = @"^[0-1]{1,100}$";
            if (!Regex.IsMatch(input, @"^[0-1]{1,100}$")) return "NO";

            return input.Contains("0000000") || input.Contains("1111111") ? "YES" : "NO";
        }
        static bool Match(string text)
        {
            return Regex.IsMatch(text, @"^[0-1] [0-1] [0-1]$", RegexOptions.Singleline);
        }
        static int Team(int Problems)
        {
            string temp;
            int count = 0;
            string[] t = { "1 1 1", "1 1 0", "1 0 1", "0 1 1" };
            for (int i = 0; i < Problems; i++)
            {
                temp = Console.ReadLine();
                if (!Match(temp)) return 0;
                if (t.Contains(temp))
                {
                    count++;
                }
            }
            return count;
        }
        static int BitPlusPlus(int Operations)
        {

            int Result = 0;
            string temp;
            if (Operations >= 1 && Operations <= 150)
            {
                for (int i = 0; i < Operations; i++)
                {
                    temp = Console.ReadLine();
                    if (!Regex.IsMatch(temp, @"^([\+-]{2})?[a-zA-Z]([\+-]{2})?$")) return 0;

                    int index = temp.IndexOfAny(new char[] { '-', '+' });
                    if (index != -1 && index > 2)
                    {
                        if (temp[index] == '+')
                            Result++;
                        else
                            Result--;
                    }
                    else if (index != -1 && index < 2)
                    {
                        if (temp[index] == '+')
                            ++Result;
                        else
                            --Result;
                    }

                }
            }
            return Result;
        }
    }
}

using System;
using System.Linq;

    class Program
    {
        static void Main()
        {

string input = Console.ReadLine();
            char[] input_to_char = input.ToCharArray();
            int char_count_ = 0;
            foreach(char s in input_to_char)
            {
                if(s.ToString().ToUpper() == "H")
                {
                    char_count_++;
                }else if(s.ToString().ToUpper() == "Q")
                {
                    char_count_++;
                }
                else if(s.ToString().ToUpper() == "9")
                {
                    char_count_++;
                }
                else if(s.ToString().ToUpper() == "+")
                {
                    char_count_++;
                }
            }

            if(char_count_ != 0 && char_count_ > 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }

        }

    }

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

namespace Implemetation
{
    class Program
    {
        static void Main(string[] args)
        {
            //string input = Console.ReadLine();
            //Console.WriteLine(Football(input));
            //int result=Petya_and_Strings(Console.ReadLine(), Console.ReadLine());
            //Console.WriteLine(result);
            //Helpful_Maths(Console.ReadLine());
            //Word_Capitalization(Console.ReadLine());
            //Taxi(int.Parse(Console.ReadLine()));
            //Console.WriteLine(Math.Ceiling((double)13/5));

            //Console.WriteLine(Regex.IsMatch(Console.ReadLine(), @"[1-4]((\s[1-4])+)?"));

            //string text = Console.ReadLine();
            //string res=Chat_Room(text);
            //Console.WriteLine(res.Contains("hello") ? "YES" : "NO");

            //Console.WriteLine(CAPS_LOCK(Console.ReadLine()));

            //string input="";
            //for (int i = 0; i < 5; i++)
            //{
            //    input += Console.ReadLine();
            //    if (i != 4)
            //        input += "\n";
            //}

            //int NumberOfMoves= Beautiful_Matrix(input);
            //Console.WriteLine(input);

            Console.WriteLine(HQ9Plus(Console.ReadLine()));

        }

        static string HQ9Plus(string input)
        {
            if (!Regex.IsMatch(input, @"^[^\s]{1,100}$")) return "NO";
            string Filterd=string.Join(" ", input.Select(c => c).Where(c => c.Equals('H') || c.Equals('Q') || c.Equals('9') || c.Equals('+')).Distinct().ToArray());
            if (Filterd.Equals("HQ9+")) return "YES";
            return "NO";

        }

        //Not Solved yet
        static void Beautiful_Matrix(string TwoDimensionalArray)
        {
            //if (TwoDimensionalArray.Contains('1')) return 0;

            int[,] TwoDimensionalOfInts = new int[5,5];
            int [][] ar = TwoDimensionalArray.Split('\n')
                            .Select(row =>  row.Split(' ').Select(ite => int.Parse(ite)).ToArray())
                            .ToArray();

            for(int i = 0; i < ar.Length; i++)
            {
                for(int k = 0; k < ar[i].Length; k++)
                {

                }
            }

            //Recersion();
        }

        static int Recersion(string[] rows)
        {
            return 0;
        }

        static string CAPS_LOCK(string input)
        {

            if (!Regex.IsMatch(input, @"^[a-zA-Z ]{1,100}$")) return input;

                List<string> words = input.Split(' ').ToList();

                StringBuilder Result = new StringBuilder();
                foreach (string word in words)
                {

                    if (word == word.ToUpper() ||
                    (word.Substring(0, 1) == word.Substring(0, 1).ToLower()
                    && word.Substring(1, word.Length - 1) == word.Substring(1, word.Length - 1).ToUpper()
                    ))
                    {
                        StringBuilder temp = new StringBuilder();
                        foreach(char c in word)
                        {
                            if (char.IsLower(c))
                                temp.Append(char.ToUpper(c));
                            else
                                temp.Append(char.ToLower(c));
                        }
                        Result.Append(temp.ToString()+" ");
                    }
                    else
                    {
                        Result.Append(word + " ");
                    }

                }
                return Result.ToString();
        }
        static string Chat_Room(string text)
        {

            if (!Regex.IsMatch(text, @"^[a-z]{1,100}$")) return "";

            //string Result = "";
            Queue<char> StackResult = new Queue<char>();

            char[] word = { 'h', 'e', 'l', 'l', 'o' };
            int position = 0;

            foreach (char c in text)
            {

                if (word[position] == c)
                {
                    //Result += c;
                    StackResult.Enqueue(c);
                    position++;
                    if (position == word.Length) break;
                }
                else
                {
                    //if (Result != "")
                    if (StackResult.Count > 0)
                    {
                        if (StackResult.Peek() == c) continue;
                        //if (Result[position - 1] == c) continue;
                        //else break;
                    }
                }

            }

            //Console.WriteLine(Result.Contains("hello")?"YES":"NO");
            //Console.WriteLine(Result.Equals("hello")?"YES":"NO");
            return string.Join("", StackResult.ToArray());

        }
        static void Taxi(int input)
        {
            if (input < 1 || input > Math.Pow(10, 5)) return;
            string strnumbers = Console.ReadLine();
            if (!Regex.IsMatch(strnumbers, @"[1-4](\s[1-4])+")) return;

            int[] nums = strnumbers.Split(' ').Select(num => int.Parse(num)).ToArray();
            if (nums.Length != input) return;

            Console.WriteLine(Math.Ceiling((double)nums.Sum() / 4));

        }
        static void Word_Capitalization(string input)
        {
            if (input.Length > Math.Pow(10, 3)) return;

            string result;

            if (input[0] >= 97)
            {
                char c = input[0];
                int cint = c - 32;
                char res = (char)cint;
                result = res + input.Substring(1, input.Length - 1);
                Console.WriteLine(result);
            }
            else
            {
                Console.WriteLine(input);
            }
        }
        static void Helpful_Maths(string input)
        {
            string pattern = @"[1-3]{1,100}\+?";
            if (!Regex.IsMatch(input, pattern)) return;

            List<int> numbers = input.Split('+').Select(item => int.Parse(item)).ToList();
            numbers.Sort();
            string Result = "";

            foreach (int i in numbers)
                Result += i + "+";

            Console.WriteLine(Result.Substring(0, Result.Length - 1));
        }
        static int Petya_and_Strings(params string[] inputs)
        {
            if (inputs[0].Length != inputs[1].Length) return -1;

            return inputs[0].ToLower().CompareTo(inputs[1].ToLower());
        }
        static string Football(string input)
        {
            //string Pattern = @"^[0-1]{1,100}$";
            if (!Regex.IsMatch(input, @"^[0-1]{1,100}$")) return "NO";

            return input.Contains("0000000") || input.Contains("1111111") ? "YES" : "NO";
        }
        static bool Match(string text)
        {
            return Regex.IsMatch(text, @"^[0-1] [0-1] [0-1]$", RegexOptions.Singleline);
        }
        static int Team(int Problems)
        {
            string temp;
            int count = 0;
            string[] t = { "1 1 1", "1 1 0", "1 0 1", "0 1 1" };
            for (int i = 0; i < Problems; i++)
            {
                temp = Console.ReadLine();
                if (!Match(temp)) return 0;
                if (t.Contains(temp))
                {
                    count++;
                }
            }
            return count;
        }
        static int BitPlusPlus(int Operations)
        {

            int Result = 0;
            string temp;
            if (Operations >= 1 && Operations <= 150)
            {
                for (int i = 0; i < Operations; i++)
                {
                    temp = Console.ReadLine();
                    if (!Regex.IsMatch(temp, @"^([\+-]{2})?[a-zA-Z]([\+-]{2})?$")) return 0;

                    int index = temp.IndexOfAny(new char[] { '-', '+' });
                    if (index != -1 && index > 2)
                    {
                        if (temp[index] == '+')
                            Result++;
                        else
                            Result--;
                    }
                    else if (index != -1 && index < 2)
                    {
                        if (temp[index] == '+')
                            ++Result;
                        else
                            --Result;
                    }

                }
            }
            return Result;
        }
    }
}

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

namespace CodeForces
{
    class _133_A___HQ9_
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            if (s.Contains('H') || s.Contains('Q') || s.Contains('9') || s.Contains('+'))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

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

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            string frase = Console.ReadLine();
            int contador = 0;
            for (int i = 0; i < frase.Length; i++)
            {
                if ((frase[i] == 'H') || (frase[i] == 'Q') || (frase[i] == '9') || (frase[i] == '+'))
                {
                    contador++;
                }
                else
                {
                    contador++;

                }

            }
            if (contador >= 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 _20180625
{

    class Program
    {
        static bool checkCode(string code)
        {
            char[] symbols = { 'H', 'Q', '9', '+' };
            foreach (var item in symbols)
            {
                if (code.Contains(item))
                    return true;
            }
            return false;
        }
        static void Main(string[] args)
        {
            string hello = "Allo retard!";
            Console.WriteLine(checkCode(hello));

        }
    }
}

using System;

namespace Problem___122A___A._HQ9Plus
{
    class Program
    {
        static void Main(string[] args)
        {
            var p = Console.ReadLine().ToUpper();
            if (p.Length>=1 && p.Length<=100)
            {
                bool b = false;
                for (int i = 0; i < p.Length; i++)
                {
                    if (p[i]=='H' || p[i]=='Q' || p[i]=='9')
                    {
                        Console.WriteLine("YES");
                        b = true;
                    }
                }

                if (b!=true)
                {
                    Console.WriteLine("NO");
                }
            }
        }
    }
}

using System;
namespace Zadachi
{
    class Program
    {
        static void Main(){
        string input = Console.ReadLine();
            for (int i = 0; i < input.Length; i++)
            {
                if (input[i] == 'H' || input[i] == 'Q') {
                    Console.WriteLine("YES");
                    return ;
                }

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

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Threading;
using System.Collections;
class Source
{
    static void Main(string[] args)
    {
        string s = Console.ReadLine();

        for ( int i = 0 ; i < s.Length ; ++ i )
            if (s[i] == 'H' | s[i] == 'Q' | s[i] == '9' | s[i] == '+')
            {
                Console.WriteLine("YES");
                return;
            }
        Console.WriteLine("NO");

        return;
    }

}

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

namespace Squares
{
    class joke
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            if (line.Contains("H") || line.Contains("Q") || line.Contains("9") || line.Contains("+"))
            {
                Console.WriteLine("YES");
            }
            else

            {
                Console.WriteLine("NO");
            }

            Console.ReadLine();
        }
    }
}

using System;
using System.Linq;

namespace A.HQ9_
{
    class Program
    {
        static void Main(string[] args)
        {
            string text = Console.ReadLine();

            if (text.Contains('H') || text.Contains('Q') || text.Contains('9') || text.Contains('+'))
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
            Console.ReadLine();
        }
    }
}

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

namespace CSharp_Shell
{

    public static class Program
    {
        public static void Main()
        {
            int kaka=0;
           string palo=Console.ReadLine();
           for(int k=0 ; k<palo.Length-1 ; k++)
           {
               char holas=palo[k];
               string palodios=Char.ToString(holas);
               if(palodios=="H")
               {
                   kaka++;
               }
               else if(palodios=="Q")
               {
                   kaka++;
               }
               else if(palodios=="9")
               {
                   kaka++;
               }
               else if(palodios=="+")
               {
                   kaka++;
               }
           }
           if(kaka>=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 _20180625
{

    class Program
    {
        static bool checkCode(string code)
        {
            char[] symbols = { 'H', 'Q', '9', '+' };
            foreach (var item in symbols)
            {
                if (code.Contains(item))
                    return true;
            }
            return false;
        }
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            Console.WriteLine(checkCode(input));
        }
    }
}