import java.io.DataInputStream;
import java.io.IOException;

public class Task939F {

    public static class FastScanner {

        protected DataInputStream dataInputStream;
        protected byte[] buffer = new byte[0x10000];
        protected int bufferOffset;
        protected int bufferLength;
        protected boolean isEndOfFile;

        public FastScanner() throws IOException {
            dataInputStream = new DataInputStream(System.in);
            Read();
        }

        protected void Read() throws IOException {
            final int length = dataInputStream.read(buffer);
            if (length > 0) {
                bufferLength = length;
            } else {
                bufferLength = 0;
                isEndOfFile = true;
            }
            bufferOffset = 0;
        }

        protected byte nextByte() throws IOException {
            if (bufferOffset == bufferLength) {
                if (!isEndOfFile) Read();
                if (isEndOfFile) return 0;
            }
            return buffer[bufferOffset++];
        }

        public int nextInt() throws IOException {
            int a = 0;
            boolean isNegative = false;

            byte b = nextByte();
            while (b <= ' ') b = nextByte();
            if (b == '-') {
                isNegative = true;
                b = nextByte();
            }
            while (b > ' ') {
                a = a * 10 + (b - '0');
                b = nextByte();
            }
            return isNegative ? -a : a;
        }

    }

    public static void SaveRotates(final int num) {
        if (minNumRotates == 0) minNumRotates = num;
        else minNumRotates = Math.min(minNumRotates, num);
    }

    public static void CalcRotates(int side, final int[] tmin, final int[] tmax,
                                  int noffset, int koffset, boolean isInterval) {
        if (tmin[0] > n || tmin[1] > n) return;
        else if ((tmin[0] <= n && tmax[0] >= n) || (tmin[1] <= n && tmax[1] >= n)) {
            if ((tmax[0] < n && side == 1) || (tmax[1] < n && side == 0)) {
                SaveRotates(numRotates + 1);
            } else {
                SaveRotates(numRotates);
            }
            return;
        } else if (koffset == k) return;

        if (isInterval) {
            if (kbeg[koffset] == kend[koffset]) {
                // no rotate
                CalcRotates(side, tmin, tmax, noffset, koffset + 1, false);

                // rotate
                numRotates++;
                CalcRotates(1 - side, tmin, tmax, noffset, koffset + 1, false);
                numRotates--;

            } else {
                // no rotate
                tmin[side] += kend[koffset] - kbeg[koffset];
                tmax[side] += kend[koffset] - kbeg[koffset];
                CalcRotates(side, tmin, tmax, kend[koffset], koffset + 1, false);
                tmin[side] -= kend[koffset] - kbeg[koffset];
                tmax[side] -= kend[koffset] - kbeg[koffset];

                // rotate once
                tmax[side] += kend[koffset] - kbeg[koffset];
                tmax[1 - side] += kend[koffset] - kbeg[koffset];
                numRotates++;
                CalcRotates(1 - side, tmin, tmax, kend[koffset], koffset + 1, false);
                numRotates--;
                tmax[side] -= kend[koffset] - kbeg[koffset];
                tmax[1 - side] -= kend[koffset] - kbeg[koffset];

                // rotate twice
                tmax[side] += kend[koffset] - kbeg[koffset];
                tmin[1 - side] += 1;
                tmax[1 - side] += kend[koffset] - kbeg[koffset] - 1;
                numRotates += 2;
                CalcRotates(side, tmin, tmax, kend[koffset], koffset + 1, false);
                numRotates -= 2;
                tmax[side] -= kend[koffset] - kbeg[koffset];
                tmin[1 - side] -= 1;
                tmax[1 - side] -= kend[koffset] - kbeg[koffset] - 1;

            }

        } else {
            tmin[side] += kbeg[koffset] - noffset;
            tmax[side] += kbeg[koffset] - noffset;
            CalcRotates(side, tmin, tmax, kbeg[koffset], koffset, true);
            tmin[side] -= kbeg[koffset] - noffset;
            tmax[side] -= kbeg[koffset] - noffset;
        }
    }

    public static int[] kbeg;
    public static int[] kend;
    public static int n = 0;
    public static int k = 0;
    public static int numRotates = 0;
    public static int minNumRotates = 0;

    public static void main(final String[] args) throws IOException {
        final FastScanner scanner = new FastScanner();
        n = scanner.nextInt();
        k = scanner.nextInt();

        kbeg = new int[k];
        kend = new int[k];

        for (int i = 0; i < k; i++) {
            kbeg[i] = scanner.nextInt();
            kend[i] = scanner.nextInt();
        }
        final int[] tmin = new int[2];
        final int[] tmax = new int[2];

        CalcRotates(0, tmin, tmax, 0, 0, false);
        if (minNumRotates > 0) {
            System.out.println("Full");
            System.out.println(minNumRotates);
        } else {
            System.out.println("Hungry");
        }
    }
}


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

/*
TASK: cutlet
LANG: JAVA
 */
public class cutlet {
    static int n , k , lo , hi;
    static int[][] segs;
    static int[] l , delt;
    static int[][][] dp;
    static ArrayList<int[]> finSeg = new ArrayList<int[]>();
    public static void main(String[] args) throws IOException {
        FastScanner in = new FastScanner(System.in);
        n = in.nextInt();
        k = in.nextInt();
        segs = new int[k][2];
        for(int i = 0;i < k; i++){
            segs[i][0] = in.nextInt();
            segs[i][1] = in.nextInt();
        }
        Arrays.sort(segs, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0] - o2[0];
            }
        });
        for(int i = 0;i < k; i++){
            lo = segs[i][0];
            hi = segs[i][0];
            while(i < k && segs[i][0] <= hi)hi = Math.max(hi , segs[i++][1]);
            int[] add = {lo , hi};
            finSeg.add(add);
            i--;
        }
        k = finSeg.size();
        segs = new int[k][2];
        l = new int[k];
        delt = new int[k];
        for(int i = 0;i < k; i++)segs[i] = finSeg.get(i);
        for(int i = 0;i < k; i++){
            l[i] = segs[i][1] - segs[i][0];
            delt[i] = i < k-1 ? segs[i+1][0] - segs[i][1] : 2*n - segs[i][1];
        }
        dp = new int[2][k+1][2*n+1];
        for(int i = 0;i < 2*n+1; i++){
            dp[0][k][i] = n;
            dp[1][k][i] = n;
        }
        dp[0][k][n] = 0;
        dp[1][k][n] = 0;
        RMQ[] rmq = new RMQ[2];
        rmq[0] = new RMQ(dp[0][k]);
        rmq[1] = new RMQ(dp[1][k]);
        for(int i = k-1; i >= 0; i--){
            for(int j = 0;j <= 2*n; j++){
                dp[0][i][j] = j+l[i]+delt[i] <= 2*n ? dp[0][i+1][j+l[i]+delt[i]] : n;
                dp[1][i][j] = dp[1][i+1][j];
                dp[0][i][j] = Math.min(dp[0][i][j] , 1 + rmq[1].min(j , Math.min(j+l[i] , 2*n)));
                if(j + delt[i] <= 2*n)dp[1][i][j] = Math.min(dp[1][i][j] , 1 + rmq[0].min(j + delt[i] , Math.min(j+l[i] + delt[i] , 2*n)));
                if(j + delt[i] <= 2*n)dp[0][i][j] = Math.min(dp[0][i][j] , 2 + rmq[0].min(j + delt[i] , Math.min(j+l[i] + delt[i] , 2*n)));
                dp[1][i][j] = Math.min(dp[1][i][j] , 2 + rmq[1].min(j , Math.min(j+l[i] , 2*n)));
            }
            rmq[0] = new RMQ(dp[0][i]);
            rmq[1] = new RMQ(dp[1][i]);
        }
        int ans = dp[1][0][0];
        if(ans == n)System.out.println("Hungry");
        else {
            System.out.println("Full");
            System.out.println(ans);
        }

    }
    public static class RMQ{
        int n , k;
        int[][] min;
        public RMQ(int[] a){
            n = a.length;
            k = Integer.numberOfTrailingZeros(Integer.highestOneBit(n))+1;
            min = new int[k][n];
            for(int i = 0;i < n; i++)
                min[0][i] = a[i];
            for(int i = 1; i < k; i++){
                for(int j = 0;j + (1 << i-1) < n; j++){
                    min[i][j] = Math.min(min[i-1][j] , min[i-1][j + (1 << i-1)]);
                }
            }
        }
        public int min(int a , int b){
            int z = Integer.numberOfTrailingZeros(Integer.highestOneBit(b-a+1));
            return Math.min(min[z][a] , min[z][b - (1<<z) + 1]);
        }
    }
    private static class FastScanner {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

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

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

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

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

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

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

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

        public String next() {
            int c = read();
            while (isSpaceChar(c)) c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));
            return res.toString();
        }

        public String nextLine() {
            int c = read();
            while (isEndline(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isEndline(c));
            return res.toString();
        }
    }
}


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

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

    static class TaskF {
        int MAX = (int) (1e9);

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int k = in.nextInt();
            ArrayList<int[]> interval = new ArrayList<>();
            for (int i = 0; i < k; i++) {
                interval.add(new int[]{in.nextInt(), in.nextInt()});
            }
            interval.add(new int[]{2 * N, 2 * N});
            int cur = 0;
            SegmentTree[] dp = new SegmentTree[2]; //how many sides are fried on the front, 0 is currently on front, 1 is currently on back
            dp[0] = new SegmentTree(N + 1);
            dp[1] = new SegmentTree(N + 1);
            dp[0].assign(0, 0);
            for (int i = 0; i < interval.size(); i++) {
                for (int j = N; j >= 0; j--) {
                    dp[0].assign(j, dp[0].getVal(j - (interval.get(i)[0] - cur)));
                }
                cur = interval.get(i)[1];
                int sz = interval.get(i)[1] - interval.get(i)[0];
                for (int j = N; j >= 0; j--) {
                    int[] put = new int[2];
                    for (int z = 0; z <= 1; z++) {
                        int twoSwaps = dp[z].query(j - sz, j);
                        int oneSwap = dp[(z + 1) % 2].query(j - sz, j);
                        int noSwap;
                        if (z == 1) {
                            noSwap = dp[z].getVal(j);
                        } else {
                            noSwap = dp[z].getVal(j - sz);
                        }
                        put[z] = Math.min(twoSwaps + 2, Math.min(oneSwap + 1, noSwap));
                    }
                    dp[0].assign(j, put[0]);
//                out.println(j + " " + put[0] + " " + put[1]);
                    dp[1].assign(j, put[1]);
                }
            }
            int ans = Math.min(dp[0].query(N, N), dp[1].query(N, N));
            if (ans >= MAX) {
                out.println("Hungry");
            } else {
                out.println("Full");
                out.println(ans);
            }
        }

        class SegmentTree {
            int[] tree;
            int[] arr;
            int size = 0;

            public SegmentTree(int N) {
                tree = new int[4 * N];
                arr = new int[N];
                Arrays.fill(arr, MAX);
                size = N;
                for (int i = 0; i < 4 * N; i++) {
                    tree[i] = MAX;
                }
            }

            public int query(int l, int r) {
                if (r < 0) {
                    return MAX;
                }
                return queryUtil(1, 0, size - 1, Math.max(0, l), r);
            }

            public int queryUtil(int n, int tl, int tr, int l, int r) {
                //node number, cur range of node, cur range of query
                if (l > r) {
                    return MAX;
                }
                if (tl == l && tr == r) {
                    return tree[n];
                }
                int tm = (tl + tr) / 2;
                return Math.min(queryUtil(2 * n, tl, tm, l, Math.min(r, tm)), queryUtil(2 * n + 1, tm + 1, tr, Math.max(tm + 1, l), r));
            }

            public void assign(int n, int val) {
                arr[n] = val;
                int tl = 0;
                int tr = size - 1;
                int a = 1;
                while (tl < tr) {
                    int tm = (tl + tr) >> 1;
                    if (n <= tm) {
                        tr = tm;
                        a = 2 * a;
                    } else {
                        tl = tm + 1;
                        a = 2 * a + 1;
                    }
                }
                tree[a] = val;
                a >>= 1;
                while (a > 0) {
                    tree[a] = Math.min(tree[2 * a], tree[2 * a + 1]);
                    a >>= 1;
                }
            }

            int getVal(int i) {
                if (i < 0) {
                    return MAX;
                }
                return arr[i];
            }

        }

    }

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

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

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

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

    }
}


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

/**
 * Created by dalt on 2018/3/14.
 */
public class CF939F {
    public static final int INF = (int) 1e8;
    public static BlockReader input;
    public static PrintStream output;

    public static void main(String[] args) throws FileNotFoundException {
        if (System.getProperty("ONLINE_JUDGE") == null) {
            input = new BlockReader(new FileInputStream("D:\\DataBase\\TESTCASE\\codeforces\\CF939F.in"));
            output = System.out;
        } else {
            input = new BlockReader(System.in);
            output = new PrintStream(new BufferedOutputStream(System.out), false);
        }

        solve();

        output.flush();
    }

    public static void solve() {
        int n = input.nextInteger();
        int k = input.nextInteger();

        int[][] intervals = new int[k + 2][2];
        for (int i = 1; i <= k; i++) {
            intervals[i][0] = input.nextInteger();
            intervals[i][1] = input.nextInteger();
        }
        intervals[k + 1][0] = 2 * n;
        intervals[k + 1][1] = 2 * n;

        k++;

        Node[] loop = new Node[2];
        loop[0] = Node.build(0, n);
        loop[1] = Node.build(0, n);

        int[] data = new int[n + 1];

        for (int i = 1; i <= k; i++) {
            Node curDp = loop[i & 1];

            Node lastDp = loop[(i - 1) & 1];

            int[] interval = intervals[i];
            int intervalLength = interval[1] - interval[0];
            int middleLength = interval[0] - intervals[i - 1][1];

            Node.toArray(0, n, data, lastDp);
            System.arraycopy(data, 0, data, Math.min(data.length, intervalLength + middleLength), Math.max(0, n + 1 - (intervalLength + middleLength)));
            Arrays.fill(data, 0, Math.min(data.length, intervalLength + middleLength), INF);

            //No flip
/*            for (int j = intervalLength + middleLength; j <= n; j++) {
                int lastFryTotalTime = j - intervalLength - middleLength;
                int minNeedTime = Node.query(lastFryTotalTime, lastFryTotalTime, 0, n, lastDp);
                Node.update(j, 0, n, minNeedTime, curDp);
            }*/

            int minX = interval[1] - middleLength - intervalLength;
            int maxX = interval[1] - middleLength;
            for (int j = 0; j <= n; j++) {
                //Flip once
                int minNeedTime = Node.query(minX - j, maxX - j, 0, n, lastDp);
                data[j] = Math.min(data[j], minNeedTime + 1);
               // Node.update(j, 0, n, minNeedTime + 1, curDp);
            }

            for (int j = 0; j <= n; j++) {
                //Flip twice
                int minNeedTime = Node.query(j - middleLength - intervalLength, j - middleLength, 0, n, lastDp);
                //Node.update(j, 0, n, minNeedTime + 2, curDp);
                data[j] = Math.min(data[j], minNeedTime + 2);
            }

            Node.fromArray(0, n, data, curDp);
        }

        int minFlipTime = Node.query(n, n, 0, n, loop[k & 1]);

        if (minFlipTime < INF) {
            output.println("Full");
            output.println(minFlipTime);
        } else {
            output.println("Hungry");
        }
    }

    public static class Node {
        Node left;
        Node right;
        int batchSetValue;
        boolean dirty;
        int min;

        public static void setValue(int f, int t, int l, int r, int val, Node node) {
            if (f > r || t < l) {
                return;
            }
            if (f <= l && t >= r) {
                node.setValue(val);
                return;
            }

            node.pushDown();
            int m = (l + r) >> 1;
            setValue(f, t, l, m, val, node.left);
            setValue(f, t, m + 1, r, val, node.right);

            node.pushUp();
        }

        public static Node build(int l, int r) {
            Node node = new Node();
            if (l != r) {
                int m = (l + r) >> 1;
                node.left = build(l, m);
                node.right = build(m + 1, r);
            }
            return node;
        }

        public static int query(int f, int t, int l, int r, Node node) {
            if (f > r || t < l) {
                return INF;
            }
            if (f <= l && r <= t) {
                return node.min;
            }
            node.pushDown();
            int m = (l + r) >> 1;
            return Math.min(query(f, t, l, m, node.left), query(f, t, m + 1, r, node.right));
        }

        public static void update(int i, int l, int r, int val, Node node) {
            if (i > r || i < l) {
                return;
            }
            if (i <= l && i >= r) {
                node.min = Math.min(node.min, val);
                return;
            }

            node.pushDown();
            int m = (l + r) >> 1;
            update(i, l, m, val, node.left);
            update(i, m + 1, r, val, node.right);

            node.pushUp();
        }

        public static void toArray(int l, int r, int[] data, Node node) {
            if (l == r) {
                data[l] = node.min;
                return;
            }
            node.pushDown();
            int m = (l + r) >> 1;
            toArray(l, m, data, node.left);
            toArray(m + 1, r, data, node.right);
        }

        public static void fromArray(int l, int r, int[] data, Node node) {
            if (l == r) {
                node.min = data[l];
                return;
            }

            node.dirty = false;
            int m = (l + r) >> 1;
            fromArray(l, m, data, node.left);
            fromArray(m + 1, r, data, node.right);
            node.pushUp();
        }

        public void pushUp() {
            this.min = Math.min(left.min, right.min);
        }

        public void setValue(int val) {
            this.min = val;
            this.batchSetValue = val;
            this.dirty = true;
        }

        public void pushDown() {
            if (dirty) {
                left.setValue(batchSetValue);
                right.setValue(batchSetValue);
                dirty = false;
            }
        }

        @Override
        public String toString() {
            int t = 100;
            int[] data = new int[t + 1];
            for (int i = 0; i <= t; i++) {
                data[i] = query(i, i, 0, t, this);
            }
            return Arrays.toString(data);
        }
    }

    public static class BlockReader {
        static final int EOF = -1;
        InputStream is;
        byte[] dBuf;
        int dPos, dSize, next;
        StringBuilder builder = new StringBuilder();

        public BlockReader(InputStream is) {
            this(is, 4096);
        }

        public BlockReader(InputStream is, int bufSize) {
            this.is = is;
            dBuf = new byte[bufSize];
            next = nextByte();
        }

        public int nextByte() {
            while (dPos >= dSize) {
                if (dSize == -1) {
                    return EOF;
                }
                dPos = 0;
                try {
                    dSize = is.read(dBuf);
                } catch (Exception e) {
                }
            }
            return dBuf[dPos++];
        }

        public String nextBlock() {
            builder.setLength(0);
            skipBlank();
            while (next != EOF && !Character.isWhitespace(next)) {
                builder.append((char) next);
                next = nextByte();
            }
            return builder.toString();
        }

        public void skipBlank() {
            while (Character.isWhitespace(next)) {
                next = nextByte();
            }
        }

        public int nextInteger() {
            skipBlank();
            int ret = 0;
            boolean rev = false;
            if (next == '+' || next == '-') {
                rev = next == '-';
                next = nextByte();
            }
            while (next >= '0' && next <= '9') {
                ret = (ret << 3) + (ret << 1) + next - '0';
                next = nextByte();
            }
            return rev ? -ret : ret;
        }

        public int nextBlock(char[] data, int offset) {
            skipBlank();
            int index = offset;
            int bound = data.length;
            while (next != EOF && index < bound && !Character.isWhitespace(next)) {
                data[index++] = (char) next;
                next = nextByte();
            }
            return index - offset;
        }

        public boolean hasMore() {
            skipBlank();
            return next != EOF;
        }
    }
}


//package round464;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.InputMismatchException;

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

	void solve()
	{
		int n = ni(), K = ni();
		int[][] ts = new int[K][];
		long all = 0;
		for(int i = 0;i < K;i++){
			ts[i] = na(2);
			all += ts[i][1] - ts[i][0];
		}
		int[] dpe = new int[n+1];
		int[] dpo = new int[n+1];
		Arrays.fill(dpe, 99999999);
		Arrays.fill(dpo, 99999999);
		if(ts[0][0] > n){
			out.println("Hungry");
			return;
		}
		dpe[ts[0][0]] = 0;
		for(int i = 0;i < K;i++){
			int[] ndpo = new int[n+1];
			int[] ndpe = new int[n+1];
			Arrays.fill(ndpo, 99999999);
			Arrays.fill(ndpe, 99999999);
			Deque<Integer> dq = new ArrayDeque<>();
			int w = ts[i][1] - ts[i][0];
			for(int j = 0;j <= n;j++){
				while(dq.size() > 0 && dpe[dq.peekLast()] >= dpe[j]){
					dq.pollLast();
				}
				while(dq.size() > 0 && dq.peekFirst() < j-w)dq.pollFirst();
				dq.add(j);
				ndpo[j] = Math.min(ndpo[j], dpe[dq.peekFirst()] + 1);
				if(j+w <= n)ndpe[j+w] = Math.min(ndpe[j+w], dpe[j]);
			}
			dq.clear();
			for(int j = 0;j <= n;j++){
				while(dq.size() > 0 && dpo[dq.peekLast()] >= dpo[j]){
					dq.pollLast();
				}
				while(dq.size() > 0 && dq.peekFirst() < j-w)dq.pollFirst();
				dq.add(j);
				ndpe[j] = Math.min(ndpe[j], dpo[dq.peekFirst()] + 1);
				ndpo[j] = Math.min(ndpo[j], dpo[j]);
			}
			dpo = ndpo;
			dpe = ndpe;

			for(int j = 0;j <= n;j++){
				dpe[j] = Math.min(dpe[j], dpo[j] + 1);
				dpo[j] = Math.min(dpo[j], dpe[j] + 1);
			}

			int s = (i == K-1 ? 2*n : ts[i+1][0]) - ts[i][1];
			for(int j = n;j >= s;j--){
				dpe[j] = dpe[j-s];
			}
			for(int j = Math.min(n, s-1);j >= 0;j--)dpe[j] = 99999999;

		}
		int ans = Math.min(dpe[n], dpo[n]);
		if(ans >= 9999999){
			out.println("Hungry");
		}else{
			out.println("Full");
			out.println(ans);
		}
	}

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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


//some updates in import stuff
import static java.lang.Math.max;
import static java.lang.Math.min;
import static java.lang.Math.abs;
import java.util.*;
import java.io.*;
import java.math.*;

//key points learned
//max space ever that could be alloted in a program to pass in cf
//int[][] prefixSum = new int[201][200_005];   -> not a single array more!!!
//never allocate memory again again to such bigg array, it will give memory exceeded for sure
//believe in your fucking solution and keep improving it!!! (sometimes)

public class Main{

    static int mod = (int) (Math.pow(10, 9)+7);
	static final int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
	static final int[] dx8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, dy8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int[] dx9 = { -1, -1, -1, 0, 0, 0, 1, 1, 1 }, dy9 = { -1, 0, 1, -1, 0, 1, -1, 0, 1 };

	static final double eps = 1e-10;
	static List<Integer> primeNumbers = new ArrayList<>();
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();
        out = new PrintWriter(new BufferedOutputStream(System.out));

        //code below
        String str = sc.nextLine();
        char[] inp = str.toCharArray();
        int n = str.length();

        //since i have the input ready bois
        //keep solving until, there is no until keep solving bruh!! (simple)
        String[] pos = {"00", "25", "50", "75"};
        int count = 0;

        if(inp.length == 1){
            if(inp[0] == '0' || inp[0] == 'X' || inp[0] == '_') count++;
        }else{

            for(String cstr : pos){
                int X = -1;

                int idx = 0;
                boolean possible = true;
                for(int i = n-2; i < n; i++){
                    char curr = inp[i];
                    char strcurr = cstr.charAt(idx);
                    idx++;

                    if(curr == '_') continue;
                    else if(curr == 'X'){
                        if(X == -1){
                            X = (strcurr - '0');
                        }else{
                            if(X != strcurr - '0'){
                                possible = false;
                                break;
                            }
                        }
                    }else{
                        if(curr != strcurr){
                            possible = false;
                            break;
                        }
                    }

                }

                if(!possible) continue; //don't increase the count simple

                //to handle one small edge case which was this
                if(str.length() == 2){
                    if(cstr.charAt(0) == '0') continue;
                    // System.out.println(cstr);
                    count++;
                    continue;
                }

                //now yaha tak question done hai boss for sure!! We have the required X and stuff and all
                //now make all possible outcomes for X
                //if X == -1 && X == 0 else what else we can do?? - think about it for sure
                //if X is fixed , then simple
                //if X is zero then also simple
                //if X is not fixed, and X is not zero
                //make temp inp
                char[] ninp = Arrays.copyOf(inp, str.length());

                int cntX = 0;
                for(char ch : inp){
                    if(ch == 'X') cntX++;
                }

                if(X != -1 || cntX == 0){
                    if(X != -1){
                        for(int k = 0; k < str.length(); k++){
                            ninp[k] = inp[k] == 'X' ? (char)(X + '0') : inp[k];
                        }
                    }

                    if(ninp[0] == '0') continue;
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    count += counter;
                }else{

                    if(ninp[0] == '0') continue;  //simimlar to before

                    //now either 'X' or '_' or
                    int counter = 1;
                    for(int k = 0; k < str.length() - 2; k++){
                        if(ninp[k] == '_'){
                            if(k == 0){
                                counter = counter * 9;
                            }else{
                                counter = counter * 10;
                            }
                        }
                    }

                    //after this it is pretty simple, multiply X also
                    if(ninp[0] == 'X'){
                        counter = counter * 9;
                    }else{
                        counter = counter * 10;
                    }

                    count += counter;
                }
            }
        }

        System.out.println(count);

        out.close();
    }

    //new stuff to learn (whenever this is need for them, then only)
    //Lazy Segment Trees
    //Persistent Segment Trees
    //Square Root Decomposition
    //Geometry & Convex Hull
    //High Level DP -- yk yk
    //String Matching Algorithms
    //Heavy light Decomposition

    //Updation Required
    //Fenwick Tree - both are done (sum)
    //Segment Tree - both are done (min, max, sum)

    //-----CURRENTLY PRESENT-------//
    //Graph
    //DSU
    //powerMODe
    //power
    //Segment Tree (work on this one)
    //Prime Sieve
    //Count Divisors
    //Next Permutation
    //Get NCR
    //isVowel
    //Sort (int)
    //Sort (long)
    //Binomial Coefficient
    //Pair
    //Triplet
    //lcm (int & long)
    //gcd (int & long)
    //gcd (for binomial coefficient)
    //swap (int & char)
    //reverse
    //primeExponentCounts

    //Fast input and output

    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------
    //-------------------------------------------------------------------

    //GRAPH (basic structure)
    public static class Graph{
        public int V;
        public ArrayList<ArrayList<Integer>> edges;

        //2 -> [0,1,2] (current)
        Graph(int V){
            this.V  = V;
            edges = new ArrayList<>(V+1);
            for(int i= 0; i <= V; i++){
                edges.add(new ArrayList<>());
            }
        }

        public void addEdge(int from , int to){
            edges.get(from).add(to);
            edges.get(to).add(from);
        }
    }

    //DSU (path and rank optimised)
    public static class DisjointUnionSets {
        int[] rank, parent;
        int n;

        public DisjointUnionSets(int n)
        {
            rank = new int[n];
            parent = new int[n];
            Arrays.fill(rank, 1);
            Arrays.fill(parent,-1);
            this.n = n;
        }

        public int find(int curr){
            if(parent[curr] == -1)
                return curr;

            //path compression optimisation
            return parent[curr] = find(parent[curr]);
        }

        public void union(int a, int b){
            int s1 = find(a);
            int s2 = find(b);

            if(s1 != s2){
                //union by size
                if(rank[s1] < rank[s2]){
                    parent[s1] = s2;
                    rank[s2] += rank[s1];
                }else{
                    parent[s2] = s1;
                    rank[s1] += rank[s2];
                }
            }
        }
    }

    //with mod
    public static long powerMOD(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                x %= mod;
                res %= mod;
                res = (res * x)%mod;
            }
            // y must be even now
            y = y >> 1; // y = y/2
            x%= mod;
            x = (x * x)%mod;  // Change x to x^2
        }
        return res%mod;
    }

    //without mod
    public static long power(long x, long y)
    {
        long res = 1L;
        while (y > 0)
        {
            // If y is odd, multiply x with result
            if ((y & 1) != 0){
                res = (res * x);
            }
            // y must be even now
            y = y >> 1; // y = y/
            x = (x * x);
        }
        return res;
    }

    public static class segmentTree{

        //so let's make a constructor function for this bad boi for sure!!!
        public long[] arr;
        public long[] tree;

        //COMPLEXITY (normal segment tree, stuff)
        //build -> O(n)
        //query -> O(logn)
        //update -> O(logn)
        //update-range -> O(n) (worst case)

        //simple iteration and stuff for sure
        public segmentTree(long[] arr){
            int n = arr.length;
            this.arr = new long[n];
            for(int i= 0; i < n; i++){
                this.arr[i] = arr[i];
            }

            tree = new long[4*n + 1];
        }

        //pretty basic idea if you read the code once
        //first make child node once
        //then form the parent node using them
        public void buildTree(int s, int e, int index){
            if(s == e){
                tree[index] = arr[s];
                return;
            }

            //recursive case
            int mid = (s + e)/2;
            buildTree(s, mid, 2 * index);
            buildTree(mid + 1, e, 2*index + 1);

            //the condition we want from children be like this
            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //definitely index based 0 query!!!
        //only int index = 1!!
        //baaki everything is simple as fuck
        public long query(int s, int e, int qs , int qe, int index){
            //complete overlap
            if(s >= qs && e <= qe){
                return tree[index];
            }

            //no overlap
            if(qe < s || qs > e){
                return Long.MAX_VALUE;
            }

            //partial overlap
            int mid = (s + e)/2;
            long left = query( s, mid , qs, qe, 2*index);
            long right = query( mid + 1, e, qs, qe, 2*index + 1);

            return min(left, right);
        }

        //updates are pretty cool
        //point update and range update!!!
        public void updateNode(int s, int e, int i, long increment, int index){

            //case where I is out of bounds
            if(i < s || i > e){
                return;
            }

            if(s == e){
                //making increment
                tree[index] += increment;
                return;
            }

            //otherwise
            int mid = (s + e)/2;
            updateNode(s, mid, i, increment, 2 * index);
            updateNode(mid + 1, e, i, increment, 2 * index + 1);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
            return;
        }

        //gonna do range updates for sure now!!
        //let's do this bois!!! (solve this problem for sure)
        public void updateRange(int s, int e, int l, int r, long increment, int index){

            //out of bounds
            if(l > e || r < s){
                return;
            }

            //leaf node
            if(s == e){
                tree[index] += increment;
            }

            //recursive case
            int mid = (s + e)/2;
            updateRange(s, mid, l, r, increment, 2 * index);
            updateRange(mid + 1, e, l, r, increment, 2 * index);

            tree[index] = min(tree[2 * index], tree[2 * index + 1]);
        }

    }

    //prime sieve
    public static void primeSieve(int n){
        BitSet bitset = new BitSet(n+1);
        for(long i = 0; i < n ; i++){
            if (i == 0 || i == 1) {
                bitset.set((int) i);
                continue;
            }
            if(bitset.get((int) i)) continue;
            primeNumbers.add((int)i);
            for(long j = i; j <= n ; j+= i)
                bitset.set((int)j);
        }
    }

    //number of divisors
    public static int countDivisors(long number){
        if(number == 1) return 1;
        List<Integer> primeFactors = new ArrayList<>();
        int index = 0;
        long curr = primeNumbers.get(index);
        while(curr * curr <= number){
            while(number % curr == 0){
                number = number/curr;
                primeFactors.add((int) curr);
            }
            index++;
            curr = primeNumbers.get(index);
        }

        if(number != 1) primeFactors.add((int) number);
        int current = primeFactors.get(0);
        int totalDivisors = 1;
        int currentCount = 2;
        for (int i = 1; i < primeFactors.size(); i++) {
            if (primeFactors.get(i) == current) {
                currentCount++;
            } else {
                totalDivisors *= currentCount;
                currentCount = 2;
                current = primeFactors.get(i);
            }
        }
        totalDivisors *= currentCount;
        return totalDivisors;
    }

    //primeExponentCounts
    public static int primeExponentsCount(int n) {
        if (n <= 1)
            return 0;
        int sqrt = (int) Math.sqrt(n);
        int remainingNumber = n;
        int result = 0;
        for (int i = 2; i <= sqrt; i++) {
            while (remainingNumber % i == 0) {
                result++;
                remainingNumber /= i;
            }
        }
        //in case of prime numbers this would happen
        if (remainingNumber > 1) {
            result++;
        }
        return result;
    }

    //now adding next permutation function to java hehe
    public static boolean next_permutation(int[] p) {
        for (int a = p.length - 2; a >= 0; --a)
          if (p[a] < p[a + 1])
            for (int b = p.length - 1;; --b)
              if (p[b] > p[a]) {
                int t = p[a];
                p[a] = p[b];
                p[b] = t;
                for (++a, b = p.length - 1; a < b; ++a, --b) {
                  t = p[a];
                  p[a] = p[b];
                  p[b] = t;
                }
                return true;
              }
        return false;
    }

    //finding the value of NCR in O(RlogN) time and O(1) space
    public static long getNcR(int n, int r)
    {
        long p = 1, k = 1;
        if (n - r < r) r = n - r;

        if (r != 0) {
            while (r > 0) {
                p *= n;
                k *= r;
                long m = __gcd(p, k);
                p /= m;
                k /= m;
                n--;
                r--;
            }
        }
        else {
            p = 1;
        }
        return p;
    }

    //is vowel function
    public static boolean isVowel(char c)
    {
        return (c=='a' || c=='A' || c=='e' || c=='E' || c=='i' || c=='I' || c=='o' || c=='O' ||     c=='u' || c=='U');
    }

    //to sort the array with better method
	public static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //sort long
    public static void sort(long[] a) {
		ArrayList<Long> l=new ArrayList<>();
		for (long i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}

    //for calculating binomialCoeff
    public static int binomialCoeff(int n, int k)
    {
        int C[] = new int[k + 1];
        // nC0 is 1
        C[0] = 1;
        for (int i = 1; i <= n; i++) {
            // Compute next row of pascal
            // triangle using the previous row
            for (int j = Math.min(i, k); j > 0; j--)
                C[j] = C[j] + C[j - 1];
        }
        return C[k];
    }

    //Pair with int int
    public static class Pair{
        public int a;
        public int b;
        public int hashCode;

        Pair(int a , int b){
            this.a = a;
            this.b = b;
            this.hashCode = Objects.hash(a, b);
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }

        @Override
        public boolean equals(Object o) {
            if (this == o)
                return true;
            if (o == null || getClass() != o.getClass())
                return false;
            Pair that = (Pair) o;
            return a == that.a && b == that.b;
        }

        @Override
        public int hashCode() {
            return this.hashCode;
        }
    }

    //Triplet with int int int
    public static class Triplet{

        public int a;
        public int b;
        public int c;

        Triplet(int a , int b, int c){
            this.a = a;
            this.b = b;
            this.c = c;
        }

        @Override
        public String toString(){
            return a + " -> " + b;
        }
    }

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

    //let's make one for calculating lcm basically
    public static int lcm(int a , int b){
        return (a * b)/gcd(a,b);
    }

    //int version for gcd
    public static int gcd(int a, int b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

    //long version for gcd
    public static long gcd(long a, long b){
        if(b == 0)
            return a;

        return gcd(b , a%b);
    }

     //for ncr calculator(ignore this code)
     public static long __gcd(long n1, long n2)
     {
         long gcd = 1;
         for (int i = 1; i <= n1 && i <= n2; ++i) {
             // Checks if i is factor of both integers
             if (n1 % i == 0 && n2 % i == 0) {
                 gcd = i;
             }
         }
         return gcd;
     }

    //swapping two elements in an array
    public static void swap(int[] arr, int left , int right){
        int temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //for char array
    public static void swap(char[] arr, int left , int right){
        char temp = arr[left];
        arr[left] = arr[right];
        arr[right] = temp;
    }

    //reversing an array
    public static void reverse(int[] arr){
        int left = 0;
        int right = arr.length-1;

        while(left <= right){
            swap(arr, left,right);
            left++;
            right--;
        }
    }

    public static long expo(long a, long b, long mod) {
        long res = 1;
        while (b > 0) {
            if ((b & 1) == 1L) res = (res * a) % mod;  //think about this one for a second
            a = (a * a) % mod;
            b = b >> 1;
        }
        return res;
    }

    //SOME EXTRA DOPE FUNCTIONS
    public static long mminvprime(long a, long b) {
        return expo(a, b - 2, b);
    }

    public static long mod_add(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a + b) % m) + m) % m;
    }

    public static long mod_sub(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a - b) % m) + m) % m;
    }

    public static long mod_mul(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (((a * b) % m) + m) % m;
    }

    public static long mod_div(long a, long b, long m) {
        a = a % m;
        b = b % m;
        return (mod_mul(a, mminvprime(b, m), m) + m) % m;
    }

    //O(n) every single time remember that
    public static long nCr(long N, long K , long mod){
        long upper = 1L;
        long lower = 1L;
        long lowerr = 1L;

        for(long i = 1; i <= N; i++){
            upper = mod_mul(upper, i, mod);
        }

        for(long i = 1; i <= K; i++){
            lower = mod_mul(lower, i, mod);
        }

        for(long i = 1; i <= (N - K); i++){
            lowerr = mod_mul(lowerr, i, mod);
        }

        // out.println(upper + " " + lower + " " + lowerr);
        long answer = mod_mul(lower, lowerr, mod);
        answer = mod_div(upper, answer, mod);

        return answer;
    }

    // long[] fact = new long[2 * n + 1];
    // long[] ifact = new long[2 * n + 1];
    // fact[0] = 1;
    // ifact[0] = 1;
    // for (long i = 1; i <= 2 * n; i++)
    // {
    //     fact[(int)i] = mod_mul(fact[(int)i - 1], i, mod);
    //     ifact[(int)i] = mminvprime(fact[(int)i], mod);
    // }
    //ifact is basically inverse factorial in here!!!!!(imp)
    public static long combination(long n, long r, long m, long[] fact, long[] ifact) {
        long val1 = fact[(int)n];
        long val2 = ifact[(int)(n - r)];
        long val3 = ifact[(int)r];
        return (((val1 * val2) % m) * val3) % m;
    }

    //-----------PrintWriter for faster output---------------------------------
    public static PrintWriter out;

    //-----------MyScanner class for faster input----------
    public static class MyScanner {
      BufferedReader br;
      StringTokenizer st;

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

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

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

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

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

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

    }
   //--------------------------------------------------------
}


import java.util.*;

public class Hello {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine().trim();
        assert str.length() >= 1 && str.length() <= 8 : "Length of S not in range";
        if (str.charAt(0) == '0') {
            System.out.println(str.length() > 1 ? "0" : "1");
            return;
        }
        int fromVal = Integer.parseInt("1" + "0".repeat(str.length() - 1));
        if (fromVal == 1) {
            fromVal = 0;
        } else if (fromVal == 10) {
            fromVal = 25;
        }
        int toVal = Integer.parseInt("9".repeat(str.length()));
        int count = 0;
        for (int val = fromVal; val <= toVal; val += 25) {
            if (canFormInteger(val, str)) {
                count++;
            }
        }
        System.out.println(count);
    }

    private static boolean canFormInteger(int num, String str) {
        String strNum = String.valueOf(num);
        char xVal = '*';
        for (int index = 0; index < str.length(); index++) {
            if (str.charAt(index) == '_') {
                continue;
            } else if (str.charAt(index) == 'X') {
                if (xVal != '*' && xVal != strNum.charAt(index)) {
                    return false;
                }
                xVal = strNum.charAt(index);
            } else if (str.charAt(index) != strNum.charAt(index)) {
                return false;
            }
        }
        return true;
    }
}


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

public class Main {

	static AReader scan = new AReader();
	static char[] cs;
	static int res = 0;
	static int X = 0;
	static int n;

	static void dfs(int u,int s){
		if(u >= n){
			if(s % 25 == 0) res++;
			return;
		}
		int t = cs[u] - '0';
		if(t>=0 && t <= 9) dfs(u+1,s*10+t);
		else if(cs[u] == 'X') dfs(u+1,s*10+X);
		else {
			if (u == n - 1) {
				dfs(u + 1, s * 10 + 5);
				dfs(u + 1, s * 10);
			} else {
				for (int i = 0; i < 10; i++) {
					if (i == 0 && u == 0) continue;
					dfs(u + 1, s * 10 + i);
				}
			}
		}
	}

	static void solve() {
		cs = scan.next().toCharArray();
		n = cs.length;
		boolean flag = false;
		for(char c:cs){
			if(c == 'X'){
				flag = true;
				break;
			}
		}
		if(cs[0] == '0' && n != 1){
			System.out.println(0);
			return;
		}
		if(flag){
		for(int i = 0;i<10;i++) {
			if(cs[0] == 'X' && n > 1 && i == 0) continue;
			X = i;
			dfs(0,0);
		}
		}else dfs(0,0);
		System.out.println(res);
	}

	public static void main(String[] args)  {
		//int T = scan.nextInt();
		//while (T-- > 0) {
		solve();
		//}
		//System.out.print(sb.toString());
	}
}

class AReader {
	private BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
	private StringTokenizer tokenizer = new StringTokenizer("");

	private String innerNextLine() {
		try {
			return reader.readLine();
		} catch (IOException ex) {
			return null;
		}
	}

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

	public String nextLine() {
		tokenizer = new StringTokenizer("");
		return innerNextLine();
	}

	public String next() {
		hasNext();
		return tokenizer.nextToken();
	}

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

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

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

class Pair {
	int x,y;

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


import java.util.*;

import java.io.*;
import java.math.*;
import java.sql.Array;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.SQLIntegrityConstraintViolationException;

public class Main {
	 private static class MyScanner {
	        private static final int BUF_SIZE = 2048;
	        BufferedReader br;

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

	        private boolean isSpace(char c) {
	            return c == '\n' || c == '\r' || c == ' ';
	        }

	        String next() {
	            try {
	                StringBuilder sb = new StringBuilder();
	                int r;
	                while ((r = br.read()) != -1 && isSpace((char)r));
	                if (r == -1) {
	                    return null;
	                }

	                sb.append((char) r);
	                while ((r = br.read()) != -1 && !isSpace((char)r)) {
	                    sb.append((char)r);
	                }
	                return sb.toString();
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            return null;
	        }

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

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

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

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

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

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

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

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

	  static long mod = (long)(1e9 + 7);

	static void sort(long[] arr ) {
		 ArrayList<Long> al = new ArrayList<>();
		 for(long e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }
	static void sort(int[] arr ) {
		 ArrayList<Integer> al = new ArrayList<>();
		 for(int e:arr) al.add(e);
		 Collections.sort(al);
		 for(int i = 0 ; i<al.size(); i++) arr[i] = al.get(i);
	 }

	static void sort(char[] arr) {
		ArrayList<Character> al = new ArrayList<Character>();
		for(char cc:arr) al.add(cc);
		Collections.sort(al);
		for(int i = 0 ;i<arr.length ;i++) arr[i] = al.get(i);
	}

	static long mod_mul(  long... a) {
		long ans = a[0]%mod;
		for(int i = 1 ; i<a.length ; i++) {
			ans = (ans * (a[i]%mod))%mod;
		}

		return ans;
	}
	static long mod_sum( long... a) {
		long ans = 0;
		for(long e:a) {
			ans = (ans + e)%mod;
		}
		return ans;
	}
	 static long gcd(long a, long b)
	  {
	     if (b == 0)
	        return a;
	     return gcd(b, a % b);
	  }
	 static boolean[] prime(int num) {
			boolean[] bool = new boolean[num];

		      for (int i = 0; i< bool.length; i++) {
		         bool[i] = true;
		      }
		      for (int i = 2; i< Math.sqrt(num); i++) {
		         if(bool[i] == true) {
		            for(int j = (i*i); j<num; j = j+i) {
		               bool[j] = false;
		            }
		         }
		      }
		      if(num >= 0) {
		    	  bool[0] = false;
		    	  bool[1] = false;
		      }

		      return bool;
		}

	 static long modInverse(long a, long m)
	    {
	        long g = gcd(a, m);

	          return   power(a, m - 2, m);

	    }
	   static long lcm(long a , long b) {
		   return (a*b)/gcd(a, b);
	   }
	   static int lcm(int a , int b) {
		   return (int)((a*b)/gcd(a, b));
	   }
	 static long power(long x, long y, long m){
	        if (y == 0) return 1; long p = power(x, y / 2, m) % m; p = (int)((p * (long)p) % m);
	        if (y % 2 == 0) return p; else return (int)((x * (long)p) % m); }

     static class Combinations{
	    	 private long[] z;
	    	 private long[] z1;
	    	 private long[] z2;
	    	 private long mod;
	    	  public Combinations(long N , long mod) {
	    		  this.mod = mod;
				z = new long[(int)N+1];
				z1 = new long[(int)N+1];
				z[0] = 1;
				for(int i =1 ; i<=N ; i++) z[i] = (z[i-1]*i)%mod;
			     z2 = new long[(int)N+1];
				z2[0] = z2[1] = 1;
			    for (int i = 2; i <= N; i++)
			        z2[i] = z2[(int)(mod % i)] * (mod - mod / i) % mod;

			    z1[0] = z1[1] = 1;

			    for (int i = 2; i <= N; i++)
			        z1[i] = (z2[i] * z1[i - 1]) % mod;
			}
	    	  long fac(long n) {
	    		  return z[(int)n];
	    	  }
	    	  long invrsNum(long n) {
	    		  return z2[(int)n];
	    	  }
	    	  long invrsFac(long n) {
	    		  return invrsFac((int)n);
	    	  }
	    	  long ncr(long N, long R)
	    	  {		if(R<0 || R>N ) return 0;
	    		    long ans = ((z[(int)N] * z1[(int)R])
	    		              % mod * z1[(int)(N - R)])
	    		             % mod;
	    		    return ans;
	    		}
	      }
	      static class DisjointUnionSets {
			    int[] rank, parent;
			    int n;

			    public DisjointUnionSets(int n)
			    {
			        rank = new int[n];
			        parent = new int[n];
			        this.n = n;
			        makeSet();
			    }

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

			            parent[i] = i;
			        }
			    }

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

			            parent[x] = find(parent[x]);

			        }

			        return parent[x];
			    }

			    void union(int x, int y)
			    {
			        int xRoot = find(x), yRoot = find(y);

			        if (xRoot == yRoot)
			            return;

			        if (rank[xRoot] < rank[yRoot])

			            parent[xRoot] = yRoot;

			        else if (rank[yRoot] < rank[xRoot])

			            parent[yRoot] = xRoot;

			        else
			        {
			            parent[yRoot] = xRoot;

			            rank[xRoot] = rank[xRoot] + 1;
			        }
			    }
			}
	      static int max(int... a ) {
	    	  int max = a[0];
	    	  for(int e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static long max(long... a ) {
	    	  long max = a[0];
	    	  for(long e:a) max = Math.max(max, e);
	    	  return max;
	      }
	      static int min(int... a ) {
	    	  int min = a[0];
	    	  for(int e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static long min(long... a ) {
	    	  long min = a[0];
	    	  for(long e:a) min = Math.min(e, min);
	    	  return min;
	      }
	      static int[] KMP(String str) {
	    	  int n = str.length();
	    	  int[] kmp = new int[n];
	    	  for(int i = 1 ; i<n ; i++) {
	    		  int j = kmp[i-1];
	    		  while(j>0 && str.charAt(i) != str.charAt(j)) {
	    			  j = kmp[j-1];
	    		  }
	    		  if(str.charAt(i) == str.charAt(j)) j++;
	    		  kmp[i] = j;
	    	  }

	    	  return kmp;
	      }

/************************************************ Query **************************************************************************************/

/***************************************** 		Sparse Table	********************************************************/
	      static class SparseTable{

	    		private long[][] st;

	    		SparseTable(long[] arr){
	    			int n = arr.length;
	    			st = new long[n][25];
	    			log = new int[n+2];
	    			build_log(n+1);
	    			build(arr);
	    		}

	    		private void build(long[] arr) {
	    			int n = arr.length;

	    			for(int i = n-1 ; i>=0 ; i--) {
	    				for(int j = 0 ; j<25 ; j++) {
	    					int r = i + (1<<j)-1;
	    					if(r>=n) break;
	    					if(j == 0 ) st[i][j] = arr[i];
	    					else st[i][j] = Math.min(st[i][j-1] , st[ i + ( 1 << (j-1) ) ][ j-1 ] );
	    				}
	    			}
	    		}
	    		public long gcd(long a  ,long b) {
	    			if(a == 0) return b;
	    			return gcd(b%a , a);
	    		}
	    		public long query(int l ,int r) {
	    			int w = r-l+1;
	    			int power = log[w];
	    			return Math.min(st[l][power],st[r - (1<<power) + 1][power]);
	    		}
	    		private int[] log;
	    		void build_log(int n) {
	    			log[1] = 0;
	    			for(int i = 2 ; i<=n ; i++) {
	    				log[i] = 1 + log[i/2];
	    			}
	    		}
	    	}

/********************************************************	Segement Tree	*****************************************************/
/**
	 	 static class SegmentTree{
			 long[] tree;
			 long[] arr;
			 int n;
			 SegmentTree(long[] arr){
				 this.n = arr.length;
				 tree = new long[4*n+1];
				 this.arr = arr;
				 buildTree(0, n-1, 1);
			 }

			  void buildTree(int s ,int e  ,int index ) {
					if(s == e) {
						tree[index] = arr[s];
						return;
					}

					int mid = (s+e)/2;

					buildTree( s,  mid, 2*index);
					buildTree( mid+1, e, 2*index+1);

					tree[index] = Math.min(tree[2*index] , tree[2*index+1]);
				}

			 long query(int si ,int ei) {
				 return query(0 ,n-1 , si ,ei , 1   );
			 }
			 private long query( int ss ,int se ,int qs , int qe,int index) {

					if(ss>=qs && se<=qe) return tree[index];

					if(qe<ss || se<qs) return (long)(1e17);

					int mid = (ss + se)/2;
					long left = query( ss , mid , qs ,qe , 2*index);
					long right= query(mid + 1 , se , qs ,qe , 2*index+1);
					return Math.min(left, right);
				}
			 public void update(int index , int val) {
				 arr[index] = val;
				 for(long e:arr) System.out.print(e+" ");
				 update(index , 0 , n-1 , 1);
			 }
			 private void update(int id ,int si , int ei , int index) {
				 if(id < si || id>ei) return;
				 if(si == ei ) {
					 tree[index] = arr[id];
					 return;
				 }
				 if(si > ei) return;
				 int mid = (ei + si)/2;

					update( id,  si, mid , 2*index);
					update( id , mid+1, ei , 2*index+1);

					tree[index] = Math.min(tree[2*index] ,tree[2*index+1]);
			 }

		 }
		 */

/* ***************************************************************************************************************************************************/

//	      static MyScanner sc = new MyScanner(); // only in case of less memory
	      static Reader sc = new Reader();
	 static StringBuilder sb = new StringBuilder();
	 public static void main(String args[]) throws IOException {

		 int tc = 1;
//		  tc = sc.nextInt();

		 for(int i = 1 ; i<=tc ; i++) {

//			 sb.append("Case #" + i + ": "  );	// During KickStart && HackerCup
			 TEST_CASE();

		 }
		 System.out.print(sb);
	 }
	 static void TEST_CASE() {
		char[] arr = sc.next().toCharArray();

		int n = arr.length;
		if(n == 1) {
			if(arr[0] == '0' || arr[0] == '_' || arr[0] == 'X' ) sb.append("1\n");
			else sb.append("0\n");
			return;
		}
		if(arr[0] == '0') {
			sb.append("0\n");
			return;
		}
		boolean bool = false;
		for(char cc:arr) {
			if(cc == 'X') {
				bool = true;
				break;
			}
		}
		long tot = 0;
		if(bool) {

			for(int i = 0 ; i<10;  i++) {
				char[] temp = new char[n];
				for(int j = 0 ; j<n ; j++)
					temp[j] = arr[j];
				if(temp[0] == 'X' && i == 0) continue;
				for(int j = 0 ; j<n ; j++) {
					if(temp[j] == 'X') {
						temp[j] = (char)(i + '0');
					}
				}

				// we have arr without X
				flag = false;
				long back = back(temp);
				long pre = 1;
				for(int j = 0 ; j<n-2 ; j++) {
					if(temp[j] == '_') {
						if(j == 0) pre *= 9;
						else pre *= 10;
					}
				}
				tot += pre*back;
				if(pre == 1 && flag) {
					tot--;
				}
			}
		}else {
			flag = false;
			long back = back(arr);
			long pre = 1;
			for(int j = 0 ;j<n-2 ; j++) {
				if(arr[j] == '_') {
					if(j == 0) pre *= 9;
					else pre *= 10;
				}
			}
			tot += pre*back;
			if(pre == 1 && flag) {
				tot--;
			}
		}

		sb.append(tot+"\n");

	 }
	 static boolean flag;
	 static long back(char[] arr ) {
//		 System.out.println(String.valueOf(arr));
		 long tot = 0;
		 int n = arr.length;
		 if(fnc(arr, n-1) && fnc(arr , n-2)) {
			 long num = Long.parseLong(""+arr[n-2] + arr[n-1]);
			 if(num%25 == 0) {
				 if(num == 0) flag = true;
				 return 1;
			 }
			 else return 0;
		 }else if(arr[n-1] == '_' && arr[n-2] == '_') {
			 flag = true;
			 return 4;
		 }else if(arr[n-1] == '_' ) {
			 if(arr[n-2] == '2' || arr[n-2] == '0' || arr[n-2] == '7' || arr[n-2] == '5')
			 {	if(arr[n-2] == '0') flag=  true;
				 return 1;
			 }

			 else return 0;
		 }else {
			 if(arr[n-1] == '0' || arr[n-1] == '5')
				 {
				 if(arr[n-1] == '0') flag = true;
				 return 2;
				 }
			 else return 0;
		 }
		 }
	 static boolean fnc(char[] arr , int i) {
		 return arr[i] != '_' ;
	 }
}
/*******************************************************************************************************************************************************/

/**

 */


import java.io.*;
import java.util.*;
// Problem Link: https://codeforces.com/problemset/problem/1575/D
public class div25 {
    public static char[] str;
    public static int S;
    public static void main (String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        str = in.readLine().toCharArray();
        S = str.length;
        int ans = 0;
        if (S==1) {
            if (str[0]=='X' || str[0] == '_' || Integer.parseInt(String.valueOf(str[0])) == 0) ans = 1;
        }
        else {
            ans += count_possibilities(2, 5);
            ans += count_possibilities(5, 0);
            ans += count_possibilities(7, 5);
            ans += count_possibilities(0, 0); }
        System.out.println(ans);

    }
    static int count_possibilities(int end1, int end2) {
        //System.out.println(end1 + " " + end2);
        if (S==2 && end1==0) return 0;
        int X_val = -1;
        if (str[S-2]=='X') X_val = end1;
        else {
            if (str[S-2]!='_') {
                if (value(S-2) != end1) return 0; } }
        //System.out.println("reached here");
        if (str[S-1]=='X') {
            if (X_val != -1 && end2 != X_val) return 0;
            else X_val = end2; }
        else {
            if (str[S-1]!='_') {
                if (value(S-1) != end2) return 0; } }
        //System.out.println("reached HERE");
        int total = 1;
        for (int i=0;i<S-2;i++) {
//            System.out.println(total);
//            System.out.println(X_val);
//            System.out.println(i + " " + str[i]);
            if (i==0) {
                if (str[i]=='X' && X_val==0) return 0;
                if (value(0) == 0) return 0; }
            if (str[i]=='_') {
                if (i==0) total *= 9;
                else total *= 10; }
            if (str[i]=='X') {
                if (X_val != -1) continue;
                else {
                    X_val = 10; // represents that X can be any integer from 0 to 9 (or possibly 1 to 9)
                    if (i==0) total *= 9;
                    else total *= 10;
                }
            }
        }
        //System.out.println(total);
        return total;
    }

    static boolean isDigit(int pos) {
        if (str[pos]=='_' || str[pos]=='X') return false;
        else return true;
    }

    static int value(int pos) {
        if (!isDigit(pos)) return -1;
        return Integer.parseInt(String.valueOf(str[pos]));
    }
}


import java.io.*;
import java.lang.reflect.Array;
import java.util.*;

public class Main {
    private static int solve(char[] s, char x) {
        for(int i = 0; i < s.length; i++) {
            if(s[i] == 'X') {
                s[i] = x;
            }
        }
        if(s[0] == '0') {
            return 0;
        }
        int ans = 1;
        boolean first = true;
        for(int i = 0; i < s.length; i++) {
            if(s[i] == '_') {
                ans *= i == 0 ? 9 : 10;
            } else if(s[i] == 'X' && first) {
                ans *= i == 0 ? 9 : 10;
                first = false;
            }
        }
        return ans;
    }
    private static boolean canReplace(char[] s, char a, char b) {
        if(s[s.length-2] >= '0' && s[s.length-2] <= '9' && s[s.length-2] != a) {
            return false;
        }
        if(s[s.length-1] >= '0' && s[s.length-1] <= '9' && s[s.length-1] != b) {
            return false;
        }
        if(s[s.length-2] == 'X' && s[s.length-1] == 'X' && a != b) {
            return false;
        }
        return true;
    }
    public static void main(String[] args) throws IOException{
        //BufferedReader f = new BufferedReader(new FileReader("cowjump.in"));
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        //PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("cowjump.out")));
        PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
        char[] s = f.readLine().toCharArray();
        if(s.length < 2) {
            out.println(s[0] == '0' || s[0] == '_' || s[0] == 'X' ? 1 : 0);
        } else {
            int ans = 0;
            if(canReplace(s, '0', '0')) {
                char[] t = s.clone();
                t[t.length-2] = '0';
                t[t.length-1] = '0';
                if(s[s.length-2] == 'X') {
                    ans += solve(t, t[t.length-2]);
                } else if(s[s.length-1] == 'X') {
                    ans += solve(t, t[t.length-1]);
                } else {
                    ans += solve(t, 'X');
                }
            }
            if(canReplace(s, '2', '5')) {
                char[] t = s.clone();
                t[t.length-2] = '2';
                t[t.length-1] = '5';
                if(s[s.length-2] == 'X') {
                    ans += solve(t, t[t.length-2]);
                } else if(s[s.length-1] == 'X') {
                    ans += solve(t, t[t.length-1]);
                } else {
                    ans += solve(t, 'X');
                }
            }
            if(canReplace(s, '5', '0')) {
                char[] t = s.clone();
                t[t.length-2] = '5';
                t[t.length-1] = '0';
                if(s[s.length-2] == 'X') {
                    ans += solve(t, t[t.length-2]);
                } else if(s[s.length-1] == 'X') {
                    ans += solve(t, t[t.length-1]);
                } else {
                    ans += solve(t, 'X');
                }
            }
            if(canReplace(s, '7', '5')) {
                char[] t = s.clone();
                t[t.length-2] = '7';
                t[t.length-1] = '5';
                if(s[s.length-2] == 'X') {
                    ans += solve(t, t[t.length-2]);
                } else if(s[s.length-1] == 'X') {
                    ans += solve(t, t[t.length-1]);
                } else {
                    ans += solve(t, 'X');
                }
            }
            out.println(ans);
        }
        f.close();
        out.close();
    }
}