/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

import java.util.*;

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic
        Scanner s = new Scanner(System.in);
        String ss =s.next();
        int s1 = ss.length()-1,f1=0;
       for(int i = 0 ; i<ss.length();i++)
        {
           if(i==s1 || ss.length()/2==i)
        {break;}

        if(ss.charAt(i)!=ss.charAt(s1))
        {
        f1++;

        }

        s1--;

        }
       if(f1==1)
       {
       System.out.println("YES");
       }
       else        System.out.println("NO");

    }

}
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package javaapplication16;
import java.util.*;

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

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic
        Scanner s = new Scanner(System.in);
        String ss =s.next();
        int s1 = ss.length()-1,f1=0;
       for(int i = 0 ; i<ss.length();i++)
        {
           if(i==s1 || ss.length()/2==i)
        {break;}

        if(ss.charAt(i)!=ss.charAt(s1))
        {
        f1++;

        }

        s1--;

        }
       if(f1==1)
       {
       System.out.println("YES");
       }
       else        System.out.println("NO");

    }

}


/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import javafx.util.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
    static class Reader {
        final private int BUFFER_SIZE = 1 << 16;
        private DataInputStream din;
        private byte[] buffer;
        private int bufferPointer, bytesRead;

        public Reader()
        {
            din = new DataInputStream(System.in);
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public Reader(String file_name) throws IOException
        {
            din = new DataInputStream(
                new FileInputStream(file_name));
            buffer = new byte[BUFFER_SIZE];
            bufferPointer = bytesRead = 0;
        }

        public String readLine() throws IOException
        {
            byte[] buf = new byte[64]; // line length
            int cnt = 0, c;
            while ((c = read()) != -1) {
                if (c == '\n') {
                    if (cnt != 0) {
                        break;
                    }
                    else {
                        continue;
                    }
                }
                buf[cnt++] = (byte)c;
            }
            return new String(buf, 0, cnt);
        }

        public int nextInt() throws IOException
        {
            int ret = 0;
            byte c = read();
            while (c <= ' ') {
                c = read();
            }
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (neg)
                return -ret;
            return ret;
        }

        public long nextLong() throws IOException
        {
            long ret = 0;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();
            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');
            if (neg)
                return -ret;
            return ret;
        }

        public double nextDouble() throws IOException
        {
            double ret = 0, div = 1;
            byte c = read();
            while (c <= ' ')
                c = read();
            boolean neg = (c == '-');
            if (neg)
                c = read();

            do {
                ret = ret * 10 + c - '0';
            } while ((c = read()) >= '0' && c <= '9');

            if (c == '.') {
                while ((c = read()) >= '0' && c <= '9') {
                    ret += (c - '0') / (div *= 10);
                }
            }

            if (neg)
                return -ret;
            return ret;
        }

        private void fillBuffer() throws IOException
        {
            bytesRead = din.read(buffer, bufferPointer = 0,
                                 BUFFER_SIZE);
            if (bytesRead == -1)
                buffer[0] = -1;
        }

        private byte read() throws IOException
        {
            if (bufferPointer == bytesRead)
                fillBuffer();
            return buffer[bufferPointer++];
        }

        public void close() throws IOException
        {
            if (din == null)
                return;
            din.close();
        }
    }

    static int parent(int a , int p[])
    {
           if(a == p[a])
           return a;

           return p[a] = parent(p[a],p);
    }

    static void union(int a , int b , int p[] , int sz[])
    {

           a = parent(a,p);
           b = parent(b,p);

           if(a == b)
           return;

           if(sz[a] < sz[b])
           {
                  int tmp = a;
                  a = b;
                  b = tmp;
           }
           p[b] = a;
           sz[a] += sz[b];

    }

    static long pow(long a , long b , long c)
    {
           if(b == 0)
           return 1;

           long ans = pow(a,b/2,c);
           if(b%2 == 0)
           return ans*ans%c;

           return ans*ans%c*a%c;
    }

  static long st[];
  static long lazy[];
  static int sz;
  static void setMax(int l , int r , long v , int lx , int rx , int x)
  {
         if(lazy[x] != Long.MIN_VALUE)
         {
                st[x] = Math.max(st[x],lazy[x]);
                if(lx != rx)
                {
                       lazy[2*x+1] = Math.max(lazy[2*x+1],lazy[x]);
                       lazy[2*x+2] = Math.max(lazy[2*x+2],lazy[x]);
                }
                lazy[x] = Long.MIN_VALUE;
         }

         if(lx > r || rx < l)
         return;

         if(lx >= l && rx <= r)
         {
                st[x] = Math.max(st[x],v);
                if(lx != rx)
                {
                     lazy[2*x+1] = Math.max(lazy[2*x+1],v);
                       lazy[2*x+2] = Math.max(lazy[2*x+2],v);
                }
                return;
         }

         int mid = (lx+rx)/2;
         setMax(l,r,v,lx,mid,2*x+1);
         setMax(l,r,v,mid+1,rx,2*x+2);

         st[x] = Math.max(st[2*x+1],st[2*x+2]);
  }

  static long getMax(int l , int r , int lx , int rx , int x)
  {
       if(lazy[x] != Long.MIN_VALUE)
         {
                st[x] = Math.max(st[x],lazy[x]);
                if(lx != rx)
                {
                       lazy[2*x+1] = Math.max(lazy[2*x+1],lazy[x]);
                       lazy[2*x+2] = Math.max(lazy[2*x+2],lazy[x]);
                }
                lazy[x] = Long.MIN_VALUE;
         }

           if(lx > r || rx < l)
           return -1000000000000000L;

           if(lx >= l && rx <= r)
           return st[x];

           int mid = (lx+rx)/2;

           return Math.max(getMax(l,r,lx,mid,2*x+1),getMax(l,r,mid+1,rx,2*x+2));
  }

   static boolean check(int x , int a[] , int b[] , int g[][] , long s , int k)
   {
          long aa = Long.MAX_VALUE;
          long bb = Long.MAX_VALUE;

          for(int i = 1 ; i <= x ; i++)
          {
                 aa = Math.min(aa,a[i]);
                 bb = Math.min(bb,b[i]);
          }

          long cost[] = new long[g.length];
          for(int i = 0 ; i < g.length ; i++)
          {
                 if(g[i][0] == 1)
                 cost[i] = aa*(long)g[i][1];

                 else
                 cost[i] = bb*(long)g[i][1];
          }

          Arrays.sort(cost);
          for(int i = 0 ; i < k ; i++)
          {
                 s -= cost[i];
                 if(s < 0)
                 return false;
          }

          return true;
   }

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

        return gcd(b%a, a);
    }

       static void dfs(int n , ArrayList<Integer> arr[] , int p , int dp1[][] , long dp2[][])
       {
              dp1[n][0] = 1;
              dp2[n][0] = arr[n].size();
              dp2[n][1] = 1;

              for(Integer v : arr[n])
              {
                     if(v != p)
                     {
                            dfs(v,arr,n,dp1,dp2);
                            dp1[n][0] += dp1[v][1];
                            dp1[n][1] += Math.max(dp1[v][0],dp1[v][1]);

                            dp2[n][0] += dp2[v][1];
                            if(dp1[v][0] > dp1[v][1])
                            {
                                   dp2[n][1] += dp2[v][0];
                            }

                            else if(dp1[v][1] > dp1[v][0])
                            {
                                   dp2[n][1] += dp2[v][1];
                            }

                            else
                            {
                                   dp2[n][1] += Math.min(dp2[v][0],dp2[v][1]);
                            }
                     }
              }
       }

       static void dfs2(int n , ArrayList<Integer> arr[] , int p , int dp1[][] , long dp2[][],
       long ans[] , int last)
       {
           if(last == 0)
           {
                  ans[n] = 1;
                  for(Integer v : arr[n])
                  {
                         if(v != p)
                         {
                                dfs2(v,arr,n,dp1,dp2,ans,1);
                         }
                  }
                  return;
           }

           int fn = -1;
           if(dp1[n][0] > dp1[n][1])
           fn = 0;

           else if(dp1[n][1] > dp1[n][0])
           fn = 1;

           else
           {
                  if(dp2[n][0] < dp2[n][1])
                  fn = 0;

                  else
                  fn = 1;
           }

           if(fn == 0)
           ans[n] = arr[n].size();

           else
           ans[n] = 1;

           for(Integer v : arr[n])
           {
                  if(v != p)
                  {
                         dfs2(v,arr,n,dp1,dp2,ans,fn);
                  }
           }
       }

    public static void main(String []args) throws IOException
    {
           Reader sc = new Reader();
           int n = sc.nextInt();
           double p = sc.nextDouble();
           int ans = 0;
           for(int i = 0 ; i <= n ; i++)
           {
                  long xx = i*(n-i)*(n-i-1)+3*(i)*(i-1)*(n-i)+i*(i-1)*(i-2);
                  double dd = p*n*(n-1)*(n-2);

                  if(xx >= dd)
                  {
                         ans = i;
                         break;
                  }
           }
           System.out.println(ans);
    }
}


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

public class I {

    public static boolean DEBUG = true;
    public static String name = "I";

    public static void main(String[] args) throws IOException {
    	FastScanner scan;
    	PrintWriter out;
    	if (DEBUG) {
    		scan = new FastScanner(System.in);
        	out = new PrintWriter(System.out);
    	}
    	else {
        	scan = new FastScanner(name + ".in");
        	out = new PrintWriter(new BufferedWriter(new FileWriter(name + ".out")));
    	}

		float N = Float.parseFloat(scan.nextString());
		float P = Float.parseFloat(scan.nextString());

        for(float i=3; i<N; i+=1) {

            float val = i*(i-1)*(i-2)/6 + i*(i-1)*(N-i)/2 + (1/3)*i*(N-i)*(N-i-1)/2;
            val = val / (N*(N-1)*(N-2)/6);

            if(val >= P) {
                out.println((int)i);
                break;
            }
        }

        out.close();
    }

    static class BIT {
        public int[] tree;

        public BIT(int len) {
          tree = new int[len+5];
        }

        // updates tree by adding val to index
        public void update(int index, int val) {
          index++;
          while(index < tree.length) {
            tree[index] ^= val;
            index += index & -index;
          }
        }

        public int query(int index) {
          int result = 0;
          index++;
          while(index > 0) {
            result ^= tree[index];
            index -= index & -index;
          }

          return result;
        }

        public int rangeSum(int low, int high) {
          return query(high) - query(low-1);
        }

      }

    /* BINARY LIFTING - Preprocess O(NlogN) - Query O(logN)*/
    static ArrayList<Integer>[] adjList;
    static int[] tin, tout;
    static int[][] BL;
    static int ct;

    public static void preprocess(int root) {
        ct = 0;
        tin = new int[adjList.length];
        tout = new int[adjList.length];
        BL = new int[adjList.length][log2(adjList.length)+1];

        recur_bl(root,root);
    }

    public static void recur_bl(int v, int p) {
        tin[v] = ++ct;
        BL[v][0] = p;
        for (int i=1; i <= log2(adjList.length); ++i) BL[v][i] = BL[BL[v][i-1]][i-1];

        for (int i=0; i<adjList[v].size(); i++) if(adjList[v].get(i) != p) recur_bl(adjList[v].get(i), v);

        tout[v] = ++ct;
    }

    public static boolean is_ancestor(int u, int v) {
        return tin[u] <= tin[v] && tout[u] >= tout[v];
    }

    public static int lca(int u, int v) {
        if(is_ancestor(u, v)) return u;
        if(is_ancestor(v, u)) return v;

        for(int i=log2(adjList.length); i >= 0; --i) if(!is_ancestor(BL[u][i], v)) u = BL[u][i];

        return BL[u][0];
    }

    public static int log2(int n) {
        return (int)Math.ceil(Math.log10(n)/Math.log10(2));
    }

    static class FastScanner {

		// Is your Fast I/O being bad?

		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;

		public FastScanner (String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}

		public FastScanner (InputStream is) throws IOException {
			dis = is;
		}

		int nextInt() throws IOException {
			int ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		long nextLong() throws IOException {
			long ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}

		String nextString() throws IOException {
			StringBuffer ret = new StringBuffer();

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}

			return ret.toString();
		}

	}
}


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

public class Codeforces
{
    public static void main(String args[])throws Exception
    {
        BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        String s[]=bu.readLine().split(" ");
        int n=Integer.parseInt(s[0])-1;
        int i,x=(int)(Double.parseDouble(s[1])*10000),y=10000;

        for(i=1;i<=n;i++)
        if(1l*i*y>=1l*n*x) break;
        System.out.println(i);
    }
}


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

public class I {

    public static boolean DEBUG = true;
    public static String name = "I";

    public static void main(String[] args) throws IOException {
    	FastScanner scan;
    	PrintWriter out;
    	if (DEBUG) {
    		scan = new FastScanner(System.in);
        	out = new PrintWriter(System.out);
    	}
    	else {
        	scan = new FastScanner(name + ".in");
        	out = new PrintWriter(new BufferedWriter(new FileWriter(name + ".out")));
    	}

		float N = Float.parseFloat(scan.nextString());
		float P = Float.parseFloat(scan.nextString());

        for(int i=0; i<=N; i+=1) {

            double val = i*(i-1)*(i-2)/6 + i*(i-1)*(N-i)/2 + *i*(N-i)*(N-i-1)/4;
            val = val / (N*(N-1)*(N-2)/6);

            if(val >= P) {
                out.println((int)i);
                break;
            }
        }

        out.close();
    }

    static class BIT {
        public int[] tree;

        public BIT(int len) {
          tree = new int[len+5];
        }

        // updates tree by adding val to index
        public void update(int index, int val) {
          index++;
          while(index < tree.length) {
            tree[index] ^= val;
            index += index & -index;
          }
        }

        public int query(int index) {
          int result = 0;
          index++;
          while(index > 0) {
            result ^= tree[index];
            index -= index & -index;
          }

          return result;
        }

        public int rangeSum(int low, int high) {
          return query(high) - query(low-1);
        }

      }

    /* BINARY LIFTING - Preprocess O(NlogN) - Query O(logN)*/
    static ArrayList<Integer>[] adjList;
    static int[] tin, tout;
    static int[][] BL;
    static int ct;

    public static void preprocess(int root) {
        ct = 0;
        tin = new int[adjList.length];
        tout = new int[adjList.length];
        BL = new int[adjList.length][log2(adjList.length)+1];

        recur_bl(root,root);
    }

    public static void recur_bl(int v, int p) {
        tin[v] = ++ct;
        BL[v][0] = p;
        for (int i=1; i <= log2(adjList.length); ++i) BL[v][i] = BL[BL[v][i-1]][i-1];

        for (int i=0; i<adjList[v].size(); i++) if(adjList[v].get(i) != p) recur_bl(adjList[v].get(i), v);

        tout[v] = ++ct;
    }

    public static boolean is_ancestor(int u, int v) {
        return tin[u] <= tin[v] && tout[u] >= tout[v];
    }

    public static int lca(int u, int v) {
        if(is_ancestor(u, v)) return u;
        if(is_ancestor(v, u)) return v;

        for(int i=log2(adjList.length); i >= 0; --i) if(!is_ancestor(BL[u][i], v)) u = BL[u][i];

        return BL[u][0];
    }

    public static int log2(int n) {
        return (int)Math.ceil(Math.log10(n)/Math.log10(2));
    }

    static class FastScanner {

		// Is your Fast I/O being bad?

		InputStream dis;
		byte[] buffer = new byte[1 << 17];
		int pointer = 0;

		public FastScanner (String fileName) throws IOException {
			dis = new FileInputStream(fileName);
		}

		public FastScanner (InputStream is) throws IOException {
			dis = is;
		}

		int nextInt() throws IOException {
			int ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		long nextLong() throws IOException {
			long ret = 0;

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			boolean negative = false;
			if (b == '-') {
				negative = true;
				b = nextByte();
			}
			while (b >= '0' && b <= '9') {
				ret = 10 * ret + b - '0';
				b = nextByte();
			}

			return (negative) ? -ret : ret;
		}

		byte nextByte() throws IOException {
			if (pointer == buffer.length) {
				dis.read(buffer, 0, buffer.length);
				pointer = 0;
			}
			return buffer[pointer++];
		}

		String nextString() throws IOException {
			StringBuffer ret = new StringBuffer();

			byte b;
			do {
				b = nextByte();
			} while (b <= ' ');
			while (b > ' ') {
				ret.appendCodePoint(b);
				b = nextByte();
			}

			return ret.toString();
		}

	}
}


package codeforces;

import java.util.Scanner;

public class WorldCup {

	public static void main(String[] args) {
		Scanner input=new Scanner(System.in);
		int n =input.nextInt();
		int a = input.nextInt();
		int b = input.nextInt();

		if(a>b) {
			int store = a;
			a = b;
			b = store;
		}

		int log = log(n);
		int r = log;
		int half = n/2;
		int h1 = half/2;
		int ans = 0;

		while(half>=1) {
			if(a%2 == 1 && b-a == 1) {
				ans = 1;
				break;
			}

			if(b>half&&a<=half) {
				ans = r;
				break;
			}

			half -=h1;

			if(a>half&&b>half) {
				half +=h1*2;
			}

			r--;
			h1/=2;
		}

		if(ans == log){
			System.out.println("Final!");
		}
		else {
			System.out.println(ans);
		}

		input.close();
     }

	static int log(int x){
	    return (int) (Math.log(x) / Math.log(2));
	}

}


import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskE solver = new TaskE();
        solver.solve(1, in, out);
        out.flush();out.close();
    }
        static class TaskE {
         int rec(int a,int b,int n,int l,int r){
          int L=r-l+1;
          if(a<=L/2+l-1&&b>L/2+l-1)return n/2;
          if(a>L/2)return rec(a,b,n/2,L/2+l,r);
          return rec(a,b,n/2,l,L/2+l-1);
         }
         public void solve(int testNumber, InputReader in, PrintWriter out) {
             int n=in.nextInt();int a=in.nextInt(),b=in.nextInt();
             if(a>b){
              a^=b;b^=a;a^=b;
             }
             int ans=rec(a,b,n,1,n);
             if(ans==n/2){out.print("Final!");return;}
             int v=(int)(Math.log(ans)/Math.log(2))+1;
             out.print(v);
         }
         /*pair ja[][];long w[];int from[],to[],c[];
             void make(int n,int m,InputReader in){
              ja=new pair[n+1][];w=new long[m];from=new int[m];to=new int[m];c=new int[n+1];
              for(int i=0;i<m;i++){
               int u=in.nextInt(),v=in.nextInt();long wt=in.nextLong();
               c[u]++;c[v]++;from[i]=u;to[i]=v;w[i]=wt;
              }
              for(int i=1;i<=n;i++){
               ja[i]=new pair[c[i]];c[i]=0;
              }
              for(int i=0;i<m;i++){
               ja[from[i]][c[from[i]]++]=new pair(to[i],w[i]);
               ja[to[i]][c[to[i]]++]=new pair(from[i],w[i]);
              }
             }*/
        int[] radixSort(int[] f){ return radixSort(f, f.length); }
	int[] radixSort(int[] f, int n)
	{
		int[] to = new int[n];
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(f[i]&0xffff)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[f[i]&0xffff]++] = f[i];
			int[] d = f; f = to;to = d;
		}
		{
			int[] b = new int[65537];
			for(int i = 0;i < n;i++)b[1+(f[i]>>>16)]++;
			for(int i = 1;i <= 65536;i++)b[i]+=b[i-1];
			for(int i = 0;i < n;i++)to[b[f[i]>>>16]++] = f[i];
			int[] d = f; f = to;to = d;
		}
		return f;
	}
    }
    static class InputReader {
        BufferedReader br;
        StringTokenizer st;
        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

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

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

        public int nextInt() {
            return Integer.parseInt(next());
        }
        public long nextLong() {
            return Long.parseLong(next());
        }
        public double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner (System.in);

        int [] array = {0 , 2 , 4 , 8 , 16 , 32 , 64 , 128 , 256};

        int n = input.nextInt();
        int a = input.nextInt();
        int b = input.nextInt();

        int ans = (Math.abs(a - b)/2)+1;
        int m = -1;

        for(int i = 1 ; i < array.length ; i++)
            if(array[i] == n)
            {
                m = i;
                break;
            }

        if(m == ans || ans > m)
            System.out.println("Final!");
        else
            System.out.println(ans);

    }


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // TODO code application logic here
        Scanner leer = new Scanner(System.in);
        int n, a, b, contador;
        n = leer.nextInt();
        a = leer.nextInt();
        b = leer.nextInt();
        int y = (int) (Math.log((double) n) / Math.log(2));
        int[] vector = new int[n+1];
        for (int i = 1; i <= n; i++) {
            vector[i]=i;
        }
        for (int i = 1; i <= y; i++) {
            contador = 0;
            for (int j = 1; j <= n / (i); j+=2) {
                contador++;
                if ((vector[j] == a && vector[j + 1] == b) || (vector[j] == b && vector[j + 1] == a)) {
                    if (i == y) {
                        System.out.println("Final!");
                        i=y;
                        j=n/i;
                    } else {
                        System.out.println("" + i);
                        i=y;
                        j=n/i;
                    }
                } else {
                    if (vector[j] == a || vector[j + 1] == a) {
                        vector[contador] = a;
                    } else {
                        if (vector[j] == b || vector[j + 1] == b) {
                            vector[contador] = b;
                        } else {
                            vector[contador] = vector[j];
                        }
                    }
                }
            }
        }
    }

}

            }
        }
    }

}


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

public class Main {public static void main(String[] args) throws Exception {new Solve();}}

class Solve { public Solve() throws Exception {solve();}

    void solve() throws Exception {
        int n = NI();
        int m = NI();
        int k = NI();
        String[] a = new String[n];
       // boolean[][] a = new boolean[n][m];
        for (int i = 0; i < n; i++)
            //for (int j = 0; j < m; j++)
                a[i] = NS();
        int[] res = new int[n];
        for (int i = 0; i < k; i++) {
            int c = NI();
            int t = NI() - 1;
            for (int j = 0; j < n; j++)
                if (a[j].charAt(t * 2) == '1' && j != c)
                    res[j]++;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++)
            sb.append(res[i]).append(" ");
        System.out.println(sb.toString());
    }

    class Cell {
        int i;
        boolean blocked;
    }

    static BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st = new StringTokenizer("");
    static Scanner sc = new Scanner(System.in);
    int min(int i1,int i2){return i1<i2?i1:i2;}
    long min(long i1,long i2){return i1<i2?i1:i2;}
    int max(int i1,int i2){return i1>i2?i1:i2;}
    long max(long i1,long i2){return i1>i2?i1:i2;}
    String NS()throws Exception{while(!st.hasMoreTokens())st=new StringTokenizer(stdin.readLine());return st.nextToken();}
    String NLn() throws Exception {return stdin.readLine();}
    int NI()throws Exception{return Integer.parseInt(NS());}
    long NL()throws Exception{return Long.parseLong(NS());}
    double ND()throws Exception{return Double.parseDouble(NS());}
    int abs(int x){return x<0?-x:x;}
}


import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.Arrays;
public class A {
    public static void main(String[] args) throws IOException {
        BufferedReader input =
			new BufferedReader(new InputStreamReader(System.in));
		String[] temp = input.readLine().split(" ");
		int n = Integer.parseInt(temp[0]);
		int m = Integer.parseInt(temp[1]);
		int min = Integer.parseInt(temp[2]);
		int max = Integer.parseInt(temp[3]);
		int[] arr = new int[m];
		for (int i = 0; i < m; i++) {
		    arr[i] = Integer.parseInt(input.readLine());
		}
	    Arrays.sort(arr);
	    int minArr = arr[0];
	    int maxArr = arr[arr.length - 1];
	    if (minArr < min || maxArr > max) {
	        System.out.println("Incorrect");
	    }
	    if (minArr > min && maxArr == max) {
	        if (n - m >= 1) System.out.println("Correct");
	        else System.out.println("Incorrect");
	    }
	    if (minArr == min && maxArr < max) {
	        if (n - m >= 1) System.out.println("Correct");
	        else System.out.println("Incorrect");
	    }
	    if (minArr > min && maxArr < max) {
	        if (n - m >= 2) System.out.println("Correct");
	        else System.out.println("Incorrect");
	    }
    }
}


package hehe;

import java.util.Scanner;
import java.io.PrintWriter;

public class TaskA {
    public void solve(int testNumber, Scanner in, PrintWriter out) {
        System.out.println("FUCK");
    }
}


import java.io.BufferedReader;
import java.io.InputStreamReader;

public class DataRecovery{
        public static void main(String[] argv) throws Exception{
                BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
                String[] words=br.readLine().trim().split(" ");
                int n=Integer.parseInt(words[0]), m=Integer.parseInt(words[1]), min=Integer.parseInt(words[2]), max=Integer.parseInt(words[3]);
                boolean maxFound=false, minFound=false;
                int cur;
                for(int i=0; i<m; i++){
                        cur=Integer.parseInt(br.readLine().trim());
                        if(cur==min){
                                minFound=true;
                        }else if(cur==max){
                                maxFound=true;
                        }
                }
                if(minFound && maxFound){
                        System.out.println("Correct");
                }else if((minFound || maxFound) && n-m>=1){
                        System.out.println("Correct");
                }else if(n-m>=2){
                        System.out.println("Correct");
                }else{
                        System.out.println("Incorrect");
                }
        }
}


import java.io.*;
import java.util.*;
public class Quest
{
    public static void main(String[] args) throws IOException
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        int n=Integer.parseInt(br.readLine());
        int t=n,s=0;
        while(t>0)
        {
            s+=t%10;
            t=t/10;
        }
        if(s%4==0)
        System.out.println(n);
        else
        {
            int r=0
            while(s%4!=0)
            {
            int m=s/4;
            int d=(((m+1)*4)-s);
            t=n+d;
            r=n+d;
            while(t>0)
            {
            s+=t%10;
            t=t/10;
            }
            }
            System.out.println(r);
        }
    }
}


 */
public class Codeforces {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here

        Scanner in = new Scanner(System.in);

        boolean B[] = new boolean[1005];

        for (int i = 0; i <= 1001; i++) {
            int Sum = 0;
            int k = i;
            while (k != 0) {
                Sum += k % 10;
                k = k / 10;
            }
            if (Sum%4==0) {

                B[i] = false;
            }
            else{
            B[i] = true;
                //System.out.println("HI");
        }
        }
        int N = in.nextInt();

        while(B[N]){
            N++;
    }
        System.out.println(N);

}
}


/* package codechef; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws IOException
	{
		// your code goes here
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int orig = Integer.parseInt(br.readLine());
        while(checkDivBy4(orig) % 4 != 0){
            orig++;
        }
        System.out.println(orig);
	    br.close();
	}
	public static boolean checkDivBy4(int n){
	    int sum = 0;
	    while(n > 0){
	        sum += n % 10;
	        n /= 10;
	    }
	    return sum;
	}
}


public class Div3_570 {
	public static int inter(int n) {

		int sum = 0;
		int temp = n;
		while (n > 0) {

			sum += (n % 10);
			n /= 10;

		}
		if (sum % 4 == 0) {
			return temp;
		} else {
			return inter(temp + 1);
		}

	}

	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int t = scn.nextInt();
		while (t-- > 0) {
			int n = scn.nextInt();
			System.out.println(inter(n));
		}

	}

}


public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();

        int flag = 0;
        int pos = 0;
        int ans = 0;
        for (int i = 0; i < input.length(); ) {
            if (i+1 < input.length() && input.charAt(i) == 'V' && input.charAt(i + 1) == 'K') {
                i += 2;
                ans++;
                pos = ans;
            } else if (i > pos && input.charAt(i) == input.charAt(i-1)) {
                flag = 1;
                i += 2;
            } else i++;
        }

        System.out.println(ans + flag);
    }
}


import java.util.;
public class Main
{

	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		int n = 0;
		while(s.contains(VK))
		{
			s = s.replaceFirst(VK, CC);
			n++;
		}
		for(int i = 0; i  s.length(); i++)
		{
			if(s.charAt(i) == 'V'  s.charAt(i) == 'K')
			{
				if((i - 1 = 0 && s.charAt(i - 1) != 'C')  (i + 1  s.length() && s.charAt(i + 1) != 'C'))
				{
					n++;
					break;
				}
			}
		}
		System.out.println(n);
		sc.close();
	}
}


import java.util.Scanner;

public class A801 {
    static int countVK(String tempString) {
        int counter = 0;
        tempString = tempString.toUpperCase();
        char[] letters = tempString.toCharArray();
        if (letters.length == 2) {
            if letters[0] == letters[1] {
                    counter++;
            }
        } else {
            for(int i = 0; i < letters.length - 1; i++) {
                if (letters[i] == 'V') {
                    if (letters[i+1] == 'K') {
                        counter++;
                    }
                }
            }
            if (tempString.contains("VVV") || tempString.contains("KKK")) {
                counter++;
            }
        }
        return counter;
    }

    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        String inputString = input.next();
        System.out.println(countVK(inputString));
    }
}


//Бодлого 41: Vicious Keyboard.

import java.util.Scanner;

public class Main {

    static Scanner scanner = new Scanner(System.in);
    static int count = 0;
    static int chance = 1;

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

        String thisIsInputBox = new String();

        thisIsInputBox = scanner.nextLine();

        if(thisIsInputBox.length() > 100)
        {
            break;
        }

        char[] thisIsInput = thisIsInputBox.toCharArray();

        for(int i = 0; i < thisIsInput.length - 1; i++)
        {
            if(thisIsInput[i] == 'V')
            {
                if(thisIsInput[i+1] == 'K')
                {
                    count++;

                }

                else
                {
                    if(chance == 1)
                    {
                        count++;
                        chance = chance - 1;
                    }

                }
			}
		}

		System.out.println(count);

	}
}


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

public class Main{
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        if(x == 0 || y==0)
        {
            System.out.println("Black");
            return;
        }
        int tmp = Math.max(x,y);
        if(x * y > 0){
           if((tmp & 1) == 0){
               System.out.println("White");
           }else
           {
               System.out.println("Black");
           }

        }else
        {
           if((tmp & 1) == 0){
               System.out.println("Black");
           }else
           {
               System.out.println("White");
           }
        }
    }
}


import java.util.*;
public class susbus{
   public static void main(String[] args){
     Scanner in = new Scanner (System.in);

    	    int a = in.nextInt();
    	       int b = in.nextInt();

    	       if(Math.floor(Math.hypot(a,b))==Math.hypot(a,b))
    	       	 System.out.print("black");

    	       	 else if(a*b>0){

    	       	 	double d=Math.hypot(a,b);

    	       	 	if(Math.floor(d)%2==1)
    	       	 		System.out.print("white");

    	       	 	else if(Math.floor(d)%2==0)
                     	System.out.print("black");

    	       	 }

    	       	 else if(a*b<0){

    	       	 		double d=Math.hypot(a,b);

    	       	 	if(Math.floor(d)%2==0)
    	       	 		System.out.print("white");

    	       	 	else if(Math.floor(d)%2==1)
                     	System.out.print("black");
      }
      }
   }
}


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

public class FindColor
{
	Scanner in;
	PrintWriter out;

	FindColor()
	{
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
	}

	FindColor(String i, String o) throws FileNotFoundException
	{
		in = new Scanner(new File(i));
		out = new PrintWriter(new File(o));
	}

	public void finalize()
	{
		out.flush();
		in.close();
		out.close();
	}

	void solve()
	{
		int
			x = in.nextInt(),
			y = in.nextInt();
		double d = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

		//if the distance from origin is integral, it's black
		if(d == (int)d)
			out.println("black");
		else
		{
			//if one point is on the origin, it's black
			if(x * y == 0)
				out.println("black");
			//if it is in 1st or 3rd quadrant
			else if(x * y > 0)
				//if the distance is 'even' it's black
				if((int)r % 2 == 0)
					out.println("black");
				//else white
				else
					out.println("white");
			//if it is in 2nd or 4th quadrant
			else
				//if the distance is 'even' it's white
				if((int)r % 2 == 0)
					out.println("white");
				//else black
				else
					out.println("black");
		}
	}

	public static void main(String[] args) throws FileNotFoundException
	{
		FindColor t = new FindColor();
		t.solve();
		t.finalize();
	}
}


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

public class FindColor
{
	Scanner in;
	PrintWriter out;

	FindColor()
	{
		in = new Scanner(System.in);
		out = new PrintWriter(System.out);
	}

	FindColor(String i, String o) throws FileNotFoundException
	{
		in = new Scanner(new File(i));
		out = new PrintWriter(new File(o));
	}

	public void finalize()
	{
		out.flush();
		in.close();
		out.close();
	}

	void solve()
	{
		int
			x = in.nextInt(),
			y = in.nextInt();
		double d = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

		//if the distance from origin is integral, it's black
		if(d == (int)d)
			out.println("black");
		else
		{
			//if one point is on the origin, it's black
			if(x * y == 0)
				out.println("black");
			//if it is in 1st or 3rd quadrant
			else if(x * y > 0)
				//if the distance is 'even' it's black
				if((int)r % 2 == 0)
					out.println("black")
				//else white
				else
					out.println("white");
			//if it is in 2nd or 4th quadrant
			else
				//if the distance is 'even' it's white
				if((int)r % 2 == 0)
					out.println("white");
				//else black
				else
					out.println("black");
		}
	}

	public static void main(String[] args) throws FileNotFoundException
	{
		FindColor t = new FindColor();
		t.solve();
		t.finalize();
	}
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            CBearAndCompany solver = new CBearAndCompany();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class CBearAndCompany {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            char[] s = in.readString().toCharArray();
            int[][][] prev = new int[n + 1][n + 1][n + 1];
            int[][][] next = new int[n + 1][n + 1][n + 1];

            int[] lastNoWord = new int[n];
            int[] nextNoWord = new int[n];
            for (int i = 0; i < n; i++) {
                lastNoWord[i] = -1;
                if (s[i] != 'V' && s[i] != 'K') {
                    lastNoWord[i] = i;
                } else if (i > 0) {
                    lastNoWord[i] = lastNoWord[i - 1];
                }
            }
            for (int i = n - 1; i >= 0; i--) {
                nextNoWord[i] = -1;
                if (s[i] != 'V' && s[i] != 'K') {
                    nextNoWord[i] = i;
                } else if (i + 1 < n) {
                    nextNoWord[i] = nextNoWord[i + 1];
                }
            }
            IntegerPreSum ips = new IntegerPreSum(i -> s[i] == 'V' ? 1 : 0, n);

            int inf = (int) 1e9;
            SequenceUtils.deepFill(prev, inf);
            prev[0][0][0] = 0;
            for (int i = 0; i < n; i++) {
                SequenceUtils.deepFill(next, inf);
                for (int j = 0; j <= n; j++) {
                    for (int k = 0; k <= n; k++) {
                        for (int t = 0; t <= n; t++) {
                            if (s[i] == 'V') {
                                //do nothing
                                if (j + 1 <= n) {
                                    next[j + 1][k][t] = Math.min(next[j + 1][k][t], prev[j][k][t]);
                                }
                                //move first
                                if (lastNoWord[i] != -1) {
                                    next[j][k][t] = Math.min(next[j][k][t], prev[j][k][t] + j + k + 1);
                                }
                            } else if (s[i] == 'K') {
                                //move before all V
                                if (k + 1 <= n && t == 0) {
                                    next[j][k + 1][t] = Math.min(next[j][k + 1][t], prev[j][k][t] + j);
                                }
                                //move after
                                if (t + 1 <= n && nextNoWord[i] != -1) {
                                    next[j][k][t + 1] = Math.min(next[j][k][t + 1], prev[j][k][t] + ips.intervalSum(i, nextNoWord[i]));
                                }
                            } else {
                                next[0][t][0] = Math.min(next[0][t][0], prev[j][k][t] + t);
                            }
                        }
                    }
                }

                int[][][] tmp = next;
                next = prev;
                prev = tmp;
            }

            int ans = inf;
            for (int i = 0; i <= n; i++) {
                for (int j = 0; j <= n; j++) {
                    ans = Math.min(ans, prev[i][j][0]);
                }
            }

            out.println(ans);
        }

    }

    static class SequenceUtils {
        public static void deepFill(Object array, int val) {
            if (!array.getClass().isArray()) {
                throw new IllegalArgumentException();
            }
            if (array instanceof int[]) {
                int[] intArray = (int[]) array;
                Arrays.fill(intArray, val);
            } else {
                Object[] objArray = (Object[]) array;
                for (Object obj : objArray) {
                    deepFill(obj, val);
                }
            }
        }

    }

    static class FastInput {
        private final InputStream is;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

    }

    static class IntegerPreSum {
        private int[] pre;
        private int n;

        public IntegerPreSum(int n) {
            pre = new int[n];
        }

        public void populate(IntToIntegerFunction a, int n) {
            this.n = n;
            if (n == 0) {
                return;
            }
            pre[0] = a.apply(0);
            for (int i = 1; i < n; i++) {
                pre[i] = pre[i - 1] + a.apply(i);
            }
        }

        public IntegerPreSum(IntToIntegerFunction a, int n) {
            this(n);
            populate(a, n);
        }

        public int intervalSum(int l, int r) {
            return prefix(r) - prefix(l - 1);
        }

        public int prefix(int i) {
            if (i < 0) {
                return 0;
            }
            return pre[Math.min(i, n - 1)];
        }

    }

    static interface IntToIntegerFunction {
        int apply(int x);

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}


import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Arrays;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.io.Closeable;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) throws Exception {
        Thread thread = new Thread(null, new TaskAdapter(), "", 1 << 29);
        thread.start();
        thread.join();
    }

    static class TaskAdapter implements Runnable {
        @Override
        public void run() {
            InputStream inputStream = System.in;
            OutputStream outputStream = System.out;
            FastInput in = new FastInput(inputStream);
            FastOutput out = new FastOutput(outputStream);
            CBearAndCompany solver = new CBearAndCompany();
            solver.solve(1, in, out);
            out.close();
        }
    }

    static class CBearAndCompany {
        public void solve(int testNumber, FastInput in, FastOutput out) {
            int n = in.readInt();
            char[] s = in.readString().toCharArray();
            int V = 0;
            int K = 0;
            for (int i = 0; i < n; i++) {
                if (s[i] == 'V') {
                    V++;
                }
                if (s[i] == 'K') {
                    K++;
                }
            }

            int[][][][] prev = new int[V + 1][K + 1][K + 1][V + 1];
            int[][][][] next = new int[V + 1][K + 1][K + 1][V + 1];

            int[] lastNoWord = new int[n];
            int[] nextNoWord = new int[n];
            for (int i = 0; i < n; i++) {
                lastNoWord[i] = -1;
                if (s[i] != 'V' && s[i] != 'K') {
                    lastNoWord[i] = i;
                } else if (i > 0) {
                    lastNoWord[i] = lastNoWord[i - 1];
                }
            }
            for (int i = n - 1; i >= 0; i--) {
                nextNoWord[i] = -1;
                if (s[i] != 'V' && s[i] != 'K') {
                    nextNoWord[i] = i;
                } else if (i + 1 < n) {
                    nextNoWord[i] = nextNoWord[i + 1];
                }
            }

            int inf = (int) 1e9;
            SequenceUtils.deepFill(prev, inf);
            prev[0][0][0][0] = 0;
            for (int i = 0; i < n; i++) {
                SequenceUtils.deepFill(next, inf);
                for (int j = 0; j <= V; j++) {
                    for (int k = 0; k <= K; k++) {
                        for (int t = 0; t <= K; t++) {
                            for (int a = 0; a <= V; a++) {
                                if (s[i] == 'V') {
                                    //do nothing
                                    if (j + 1 <= V && a == 0) {
                                        next[j + 1][k][t][a] = Math.min(next[j + 1][k][t][a], prev[j][k][t][a] + t + a);
                                    }
                                    //move first
                                    if (lastNoWord[i] != -1 && j == 0 && a == 0) {
                                        next[j][k][t][a] = Math.min(next[j][k][t][a], prev[j][k][t][a] + j + k + t + a + 1);
                                    }
                                    //add to
                                    if (a + 1 <= V && nextNoWord[i] != -1) {
                                        next[j][k][t][a + 1] = Math.min(next[j][k][t][a + 1], prev[j][k][t][a]);
                                    }
                                } else if (s[i] == 'K') {
                                    //move before all V
                                    if (k + 1 <= K && t == 0) {
                                        next[j][k + 1][t][a] = Math.min(next[j][k + 1][t][a], prev[j][k][t][a] + j + a + t);
                                    }
                                    //move after
                                    if (t + 1 <= K && nextNoWord[i] != -1) {
                                        next[j][k][t + 1][a] = Math.min(next[j][k][t + 1][a], prev[j][k][t][a] + a);
                                    }
                                } else {
                                    next[a][t][0][0] = Math.min(next[a][t][0][0], prev[j][k][t][a] + t + a);
                                }
                            }
                        }
                    }
                }

                int[][][][] tmp = next;
                next = prev;
                prev = tmp;
            }

            int ans = inf;
            for (int i = 0; i <= V; i++) {
                for (int j = 0; j <= K; j++) {
                    ans = Math.min(ans, prev[i][j][0][0]);
                }
            }

            out.println(ans);
        }

    }

    static class SequenceUtils {
        public static void deepFill(Object array, int val) {
            if (!array.getClass().isArray()) {
                throw new IllegalArgumentException();
            }
            if (array instanceof int[]) {
                int[] intArray = (int[]) array;
                Arrays.fill(intArray, val);
            } else {
                Object[] objArray = (Object[]) array;
                for (Object obj : objArray) {
                    deepFill(obj, val);
                }
            }
        }

    }

    static class FastInput {
        private final InputStream is;
        private StringBuilder defaultStringBuf = new StringBuilder(1 << 13);
        private byte[] buf = new byte[1 << 13];
        private int bufLen;
        private int bufOffset;
        private int next;

        public FastInput(InputStream is) {
            this.is = is;
        }

        private int read() {
            while (bufLen == bufOffset) {
                bufOffset = 0;
                try {
                    bufLen = is.read(buf);
                } catch (IOException e) {
                    bufLen = -1;
                }
                if (bufLen == -1) {
                    return -1;
                }
            }
            return buf[bufOffset++];
        }

        public void skipBlank() {
            while (next >= 0 && next <= 32) {
                next = read();
            }
        }

        public int readInt() {
            int sign = 1;

            skipBlank();
            if (next == '+' || next == '-') {
                sign = next == '+' ? 1 : -1;
                next = read();
            }

            int val = 0;
            if (sign == 1) {
                while (next >= '0' && next <= '9') {
                    val = val * 10 + next - '0';
                    next = read();
                }
            } else {
                while (next >= '0' && next <= '9') {
                    val = val * 10 - next + '0';
                    next = read();
                }
            }

            return val;
        }

        public String readString(StringBuilder builder) {
            skipBlank();

            while (next > 32) {
                builder.append((char) next);
                next = read();
            }

            return builder.toString();
        }

        public String readString() {
            defaultStringBuf.setLength(0);
            return readString(defaultStringBuf);
        }

    }

    static class FastOutput implements AutoCloseable, Closeable, Appendable {
        private StringBuilder cache = new StringBuilder(10 << 20);
        private final Writer os;

        public FastOutput append(CharSequence csq) {
            cache.append(csq);
            return this;
        }

        public FastOutput append(CharSequence csq, int start, int end) {
            cache.append(csq, start, end);
            return this;
        }

        public FastOutput(Writer os) {
            this.os = os;
        }

        public FastOutput(OutputStream os) {
            this(new OutputStreamWriter(os));
        }

        public FastOutput append(char c) {
            cache.append(c);
            return this;
        }

        public FastOutput append(int c) {
            cache.append(c);
            return this;
        }

        public FastOutput println(int c) {
            return append(c).println();
        }

        public FastOutput println() {
            cache.append(System.lineSeparator());
            return this;
        }

        public FastOutput flush() {
            try {
                os.append(cache);
                os.flush();
                cache.setLength(0);
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
            return this;
        }

        public void close() {
            flush();
            try {
                os.close();
            } catch (IOException e) {
                throw new UncheckedIOException(e);
            }
        }

        public String toString() {
            return cache.toString();
        }

    }
}


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

public class J implements Runnable {

    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;

    private BufferedReader in;
    private PrintWriter out;
    private StringTokenizer tok = new StringTokenizer("");

    private void init() throws FileNotFoundException {
        Locale.setDefault(Locale.US);
        String fileName = "";
        if (ONLINE_JUDGE && fileName.isEmpty()) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        } else {
            if (fileName.isEmpty()) {
                in = new BufferedReader(new FileReader("input.txt"));
                out = new PrintWriter("output.txt");
            } else {
                in = new BufferedReader(new FileReader(fileName + ".in"));
                out = new PrintWriter(fileName + ".out");
            }
        }
    }

    String readString() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());

        }
        return tok.nextToken();
    }

    int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    long readLong() throws IOException {
        return Long.parseLong(readString());
    }

    double readDouble() throws IOException {
        return Double.parseDouble(readString());
    }

    int[] readIntArray(int size) throws IOException {
        int[] a = new int[size];
        for (int i = 0; i < size; i++) {
            a[i] = readInt();
        }
        return a;
    }

    public static void main(String[] args) {
        //new Thread(null, new _Solution(), "", 128 * (1L << 20)).start();
        new J().run();
    }

    long timeBegin, timeEnd;

    void time() {
        timeEnd = System.currentTimeMillis();
        System.err.println("Time = " + (timeEnd - timeBegin));
    }

    @Override
    public void run() {
        try {
            timeBegin = System.currentTimeMillis();
            init();
            solve();
            out.close();
            time();
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(-1);
        }
    }

    int[][][][] dp;
    char[] s;
    int INF = 10000000;

    int solve(int v, int k, int x, int last) {
        if (v < 0) return INF;
        if (k < 0) return INF;
        if (x < 0) return INF;
        if (dp[v][k][x][last] != -1) {
            return dp[v][k][x][last];
        }
        int res = INF;
        if (last == 0 && v > 0) {
            //v
            for (int i = 0; i < 3; i++) {
                res = Math.min(res, solve(v - 1, k, x, i));
            }
            return res + count(s, 'V', v, k, x);
        }
        if (last == 1 && k > 0) {
            //K
            res = Math.min(solve(v, k - 1, x, 1), solve(v, k - 1, x, 2));
            return res + count(s, 'K', v, k, x);
        }
        if (last == 2 && x > 0) {
            for (int i = 0; i < 3; i++) {
                res = Math.min(res, solve(v, k, x - 1, i));
            }
            return res + + count(s, 'X', v, k, x);
        }
        return INF;
    }

    int count(char[] s, char target, int v, int k, int x) {
        int answer = 0;
        for (char c : s) {
            if (c == 'V') {
                v--;
                if (v == 0 && target == 'V') return answer;
                if (v < 0) answer++;
            }
            if (c == 'K') {
                k--;
                if (k == 0 && target == 'K') return answer;
                if (k < 0) answer++;
            }
            if (c == 'X') {
                x--;
                if (x == 0 && target == 'X') return answer;
                if (x < 0) answer++;
            }
        }
        throw new RuntimeException();
    }

    private void solve() throws IOException {
        int n = readInt();
        s = readString().toCharArray();
        int vcnt = 0, kcnt = 0, xcnt = 0;
        for (int i = 0; i < s.length; i++) {
            if (s[i] == 'V') {
                vcnt++;
                continue;
            }
            if (s[i] == 'K') {
                kcnt++;
                continue;
            }
            xcnt++;
            s[i] = 'X';
        }
        dp = new int[vcnt + 1][kcnt + 1][xcnt + 1][3];
        for (int[][][] x : dp) {
            for (int[][] xx : x) {
                for (int[] xxx : xx) {
                    Arrays.fill(xxx, -1);
                }
            }
        }
        dp[0][0][0][0] = dp[0][0][0][1] = dp[0][0][0][2] = 0;
        int res = INF;
        for (int i = 0; i < 3; i++) {
            res = Math.min(res, solve(vcnt, kcnt, xcnt, i));
        }
        out.println(res);

    }

}


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.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);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        static final int INF = (int) 1e9;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();
            int nk = 0;
            int nv = 0;
            int no = 0;
            int[] kpos = new int[n];
            int[] vpos = new int[n];
            int[] opos = new int[n];
            int[] snk = new int[n + 1];
            int[] snv = new int[n + 1];
            int[] sno = new int[n + 1];
            for (int i = 0; i < n; ++i) {
                char ch = s.charAt(i);
                if (ch == 'V') {
                    vpos[nv++] = i;
                } else if (ch == 'K') {
                    kpos[nk++] = i;
                } else {
                    opos[no++] = i;
                }
                snk[i + 1] = nk;
                snv[i + 1] = nv;
                sno[i + 1] = no;
            }
            int[][][][] best = new int[2][nk + 1][nv + 1][no + 1];
            for (int[][][] x : best) for (int[][] y : x) for (int[] z : y) Arrays.fill(z, INF);
            best[0][0][0][0] = 0;
            for (int k = 0; k <= nk; ++k) {
                for (int v = 0; v <= nv; ++v) {
                    for (int o = 0; o <= no; ++o) {
                        for (int hv = 0; hv < 2; ++hv) {
                            int cur = best[hv][k][v][o];
                            if (k < nk && hv == 0) {
                                best[0][k + 1][v][o] = Math.min(best[0][k + 1][v][o], cur + Math.max(snv[kpos[k]] - v,0) + Math.max(sno[kpos[k]] - o),0);
                            }
                            if (v < nv) {
                                best[1][k][v + 1][o] = Math.min(best[1][k][v + 1][o], cur + Math.max(snk[vpos[v]] - k,0) + Math.max(sno[vpos[v]] - o),0);
                            }
                            if (o < no) {
                                best[0][k][v][o + 1] = Math.min(best[0][k][v][o + 1], cur + Math.max(snv[opos[o]] - v,0) + Math.max(snk[opos[o]] - k),0);
                            }
                        }
                    }
                }
            }
            out.println(Math.min(best[0][nk][nv][no], best[1][nk][nv][no]) );
        }

    }

    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.*;

/**
 * Codeforces #68C "Synchrophasotron"
 * @link http://codeforces.ru/problemset/problem/68/C
 * @author Caesar
 */
public class Solution68C implements Runnable {

    private static final int EXIT_CODE = -1;
    private static final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null;
    private static final String INPUT = "input.txt";
    private static final String OUTPUT = "output.txt";

    private StringTokenizer tok;
    private BufferedReader in;
    private PrintWriter out;

    public static void main(String[] args) {
        new Thread(new Solution68C()).start();
    }

    public void run() {
        try {
            in = ONLINE_JUDGE ?
                new BufferedReader(new InputStreamReader(System.in)) :
                new BufferedReader(new FileReader(INPUT));
            out = ONLINE_JUDGE ? new PrintWriter(System.out) : new PrintWriter(OUTPUT);
            long start = System.currentTimeMillis();
            try {
                solve();
            } finally {
                if (ONLINE_JUDGE) {
                    out.flush();
                } else {
                    out.close();
                }
            }
            System.err.println("Time used: " + (System.currentTimeMillis() - start));
        } catch (Throwable ex) {
            ex.printStackTrace();
            System.exit(EXIT_CODE);
        }
    }

    private String readString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int n;
    private int[][] flow;
    private int[][] l;
    private int[][] h;
    private int[][] a;
    private int minFlow = Integer.MAX_VALUE;
    private int maxCost = Integer.MIN_VALUE;

    private void brute(int start, int finish) {
        if (start == finish) {
            if (!isValid()) {
                return;
            }
            int f = getFlow(n - 1);
            int c = getCost();
            if (f < minFlow) {
                minFlow = f;
                maxCost = c;
            } else if (f == minFlow) {
                if (c > maxCost) {
                    maxCost = c;
                }
            }
            return;
        }
        for (flow[start][finish] = l[start][finish]; flow[start][finish] <= Math.min(h[start][finish], getFlow(start)); ++flow[start][finish]) {
            if (start == n - 2 && finish == n - 1) {
                brute(n - 1, n - 1);
            } else if (finish == n - 1) {
                brute(start + 1, start + 2);
            } else {
                brute(start, finish + 1);
            }
        }
    }

    private boolean isValid() {
        for (int i = 1; i < n - 1; ++i) {
            int send = 0;
            int recv = 0;
            for (int j = 0; j < i; ++j) {
                recv += flow[j][i];
            }
            for (int j = i + 1; j < n; ++j) {
                send += flow[i][j];
            }
            if (send != recv) {
                return false;
            }
        }
        return true;
    }

    private int getFlow(int v) {
        if (v == 0) {
            return Integer.MAX_VALUE;
        }
        int ans = 0;
        for (int i = 0; i < v; ++i) {
            ans += flow[i][v];
        }
        return ans;
    }

    private int getCost() {
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                ans += flow[i][j] == 0 ? 0 : a[i][j] + flow[i][j] * flow[i][j];
            }
        }
        return ans;
    }

    public void solve() throws IOException {
        n = readInt();
        l = new int[n][n];
        h = new int[n][n];
        a = new int[n][n];
        flow = new int[n][n];
        int m = n * (n - 1) >> 1;
        for (int i = 0; i < m; ++i) {
            int s = readInt() - 1;
            int f = readInt() - 1;
            l[s][f] = readInt();
            h[s][f] = readInt();
            a[s][f] = readInt();
        }
        brute(0, 1);
        out.println(minFlow == Integer.MAX_VALUE ? "-1 -1" : (minFlow + " " + maxCost));
    }

}


import java.awt.Point;
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.io.*;
import java.math.BigInteger;
import static java.math.BigInteger.*;
import java.util.*;
public class C{
	int n;
	int[][]min;
	int[][]max;
	int[][]active;
	int[]pFlow;
	int inf=Integer.MAX_VALUE/100;
	void solve()throws Exception
	{

		n=nextInt();
		min=new int[n][n];
		max=new int[n][n];
		active=new int[n][n];
		int sum=0;
		for(int step=1;step<=n*(n-1)/2;step++)
		{
			int a=nextInt()-1;
			int b=nextInt()-1;
			min[a][b]=nextInt();
			max[a][b]=nextInt();
			active[a][b]=nextInt();
			sum+=max[a][b];
		}
		sum++;
		pFlow=new int[n];
		int[]res=rec(0,1);
		if(res==null)
			res=new int[]{-1,-1};
		System.out.println(res[0]+" "+res[1]);
	}

	private int[] rec(int a, int b) {
		if(a==n-1)
		{
			return new int[]{pFlow[0],0};
		}
		int[]res=null;
		if(b==n)
		{
			if(a!=0 && pFlow[a]!=0)
				return null;
			return rec(a+1,a+2);
		}
		else
		{
			for(int x=min[a][b];x<=max[a][b];x++)
			{
				int curCost=x*x+(x>0?active[a][b]:0);
				pFlow[a]+=x;
				pFlow[b]-=x;
				int[]next=rec(a,b+1);
				if(next!=null)
				{
					next[1]+=curCost;
					if(res==null || (res[0]>next[0] || (res[0]==next[0] && res[1]<next[1])))
						{
							res=next;
						}
				}
				pFlow[a]-=x;
				pFlow[b]+=x;
			}
			return res;

		}

	}

	BufferedReader reader;
	PrintWriter writer;
	StringTokenizer stk;
	void run()throws Exception
	{
		reader=new BufferedReader(new InputStreamReader(System.in));
		stk=null;
		writer=new PrintWriter(System.out);
		solve();
		reader.close();
		writer.close();
	}
	int nextInt()throws Exception
	{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception
	{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception
	{
		return Double.parseDouble(nextToken());
	}
	String nextString()throws Exception
	{
		return nextToken();
	}
	String nextLine()throws Exception
	{
		return reader.readLine();
	}
	String nextToken()throws Exception
	{
		if(stk==null || !stk.hasMoreTokens())
		{
			stk=new StringTokenizer(nextLine());
			return nextToken();
		}
		return stk.nextToken();
	}

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

	}

}


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

/**
 * Codeforces #68C "Synchrophasotron"
 * @link http://codeforces.ru/problemset/problem/68/C
 * @author Caesar
 */
public class Solution68C implements Runnable {

    private static final int EXIT_CODE = -1;

    private StringTokenizer tok;
    private BufferedReader in;
    private PrintWriter out;

    public static void main(String[] args) {
        new Thread(new Solution68C()).start();
    }

    public void run() {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        long start = System.currentTimeMillis();
        try {
            solve();
        } catch (Throwable ex) {
            ex.printStackTrace();
            System.exit(EXIT_CODE);
        } finally {
            out.flush();
        }
        System.err.println("Time used: " + (System.currentTimeMillis() - start));
    }

    private String readString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    private int readInt() throws IOException {
        return Integer.parseInt(readString());
    }

    int n;
    private int[][] flow;
    private int[][] l;
    private int[][] h;
    private int[][] a;
    private int minFlow = Integer.MAX_VALUE;
    private int maxCost = Integer.MIN_VALUE;
    private int border;

    private void brute(int start, int finish) {
        if (start == finish) {
            if (!isValid()) {
                return;
            }
            int f = getFlow();
            int c = getCost();
            if (f < minFlow && f > 0) {
                minFlow = f;
                maxCost = c;
            } else if (f == minFlow) {
                if (c > maxCost) {
                    maxCost = c;
                }
            }
            return;
        }
        for (flow[start][finish] = 0; flow[start][finish] <= border; ++flow[start][finish]) {
            if (start == n - 2 && finish == n - 1) {
                brute(n - 1, n - 1);
            } else if (finish == n - 1) {
                brute(start + 1, start + 2);
            } else {
                brute(start, finish + 1);
            }
        }
    }

    private boolean isValid() {
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                if (flow[i][j] < l[i][j] || flow[i][j] > h[i][j]) {
                    return false;
                }
            }
        }
        for (int i = 1; i < n - 1; ++i) {
            int send = 0;
            int recv = 0;
            for (int j = 0; j < i; ++j) {
                recv += flow[j][i];
            }
            for (int j = i + 1; j < n; ++j) {
                send += flow[i][j];
            }
            if (send != recv) {
                return false;
            }
        }
        return true;
    }

    private int getFlow() {
        int ans = 0;
        for (int i = 0; i < n - 1; ++i) {
            ans += flow[i][n - 1];
        }
        return ans;
    }

    private int getCost() {
        int ans = 0;
        for (int i = 0; i < n; ++i) {
            for (int j = i + 1; j < n; ++j) {
                ans += flow[i][j] == 0 ? 0 : a[i][j] + flow[i][j] * flow[i][j];
            }
        }
        return ans;
    }

    public void solve() throws IOException {
        n = readInt();
        l = new int[n][n];
        h = new int[n][n];
        a = new int[n][n];
        flow = new int[n][n];
        int m = n * (n - 1) >> 1;
        for (int i = 0; i < m; ++i) {
            int s = readInt() - 1;
            int f = readInt() - 1;
            l[s][f] = readInt();
            h[s][f] = readInt();
            a[s][f] = readInt();
        }
        border = 0;
        for (int i = 1; i < n; ++i) {
            border += h[0][i];
        }
        brute(0, 1);
        System.out.println(minFlow == Integer.MAX_VALUE ? "-1 -1" : (minFlow + " " + maxCost));
    }

}


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

public class BaiC {

    int n;
    int[][] a, low, high;
    boolean[][] b;
    int[][] c;
    int[][] edges;
    int[] e;

    int[] best = null;

    void duyet(int pos, int cost) {
        if(pos == edges.length) {
            for(int i=1;i+1<n;++i) if(e[i] != 0) return;

            if(best == null || best[0] > -e[0] || (best[0] == -e[0] && best[1] < cost)) {
                best = new int[]{-e[0], cost};
            }
            return;
        }

        int u = edges[pos][0];
        int v = edges[pos][1];

        if(best != null && best[0] < -e[0]) return;

        boolean tiep = true;
        for(int i=1;i+1<n;++i) if(e[i] < 0) tiep = false;
        for(int i=1;i<u;++i) if(e[i] != 0) tiep = false;
        if(!tiep) return;

        for(int x=low[u][v];x<=high[u][v];++x) {
            c[u][v] = x;
            e[u] -= x;
            e[v] += x;
            duyet(pos+1, cost + (x == 0 ? 0 : (a[u][v] + x * x)));
            e[u] += x;
            e[v] -= x;
        }
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n][n];
        low = new int[n][n];
        high = new int[n][n];
        b = new boolean[n][n];

        for(int i=0;i<n;++i)
            for(int j=i+1;j<n;++j) {
                int u, v, l, h, z;

                u = sc.nextInt();
                v = sc.nextInt();
                l = sc.nextInt();
                h = sc.nextInt();
                z = sc.nextInt();
                // u = i+1; v = j+1; l = 0; h = 5; z = 5;
                a[u-1][v-1] = z;
                low[u-1][v-1] = l;
                high[u-1][v-1] = h;
            }

        edges = new int[n*(n-1)/2][];
        int ne = 0 ;

        for(int i=0;i<n;++i)
            for(int j=i+1;j<n;++j) {
                edges[ne++] = new int[]{i,j};
            }
        e = new int[n];
        c = new int[n][n];
        duyet(0, 0);
        System.out.println(best[0] + " " + best[1]);
    }
    public static void main(String[] args) {
        // long tbegin = System.currentTimeMillis();
        new BaiC().run();
        // System.out.println(System.currentTimeMillis() - tbegin);
    }
}


import java.util.*;
public class Add{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int total=0,i,j=1,k=0;
		int l[],p[]=new int[1000];
		Arrays.fill(p,new Integer(0));
		int x=sc.nextInt();
		String s=sc.nextLine();
		for(i=0;i<s.length();i++){
				if(s.charAt(i)=='B'){
						l[j]=i+1;
						j++;
				}
		}
		for(i=1;i<j;i++){
				if(k[i+1]-k[i]!=1){

						total++;
						k++;
					}
			else
					p[k]++;

		}

		System.out.println(total);
		for(i=0;i<k;i++)
		System.out.println(p[i]);
	}
}


import java.util.*;
public class Add{
	public static void main(String arg[]){
		Scanner sc=new Scanner(System.in);
		int total=0,i,j=1,k=0;
		int l[],p[]=new int[1000];
		Arrays.fill(p,new Integer(0));
		int x=sc.nextInt();
		String s=sc.nextLine();
		for(i=0;i<s.length();i++){
				if(s.charAt(i)=='B'){
						l[j]=i+1;
						j++;
				}
		}
		for(i=1;i<j;i++){
				if(l[i+1]-l[i]!=1){

						total++;
						k++;
					}
			else
					p[k]++;

		}

		System.out.println(total);
		for(i=0;i<k;i++)
		System.out.println(p[i]);
	}
}


import java.util.Scanner;
import java.lang.Math;

public class Crossword{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);

        int rowLength = scan.nextInt();

        scan.nextLine();

        String[] blacks = scan.nextLine().replaceAll("W+","W").split("W");

        System.out.println(blacks.length);

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


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

public class te {

    static PrintStream p = System.out;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String t = sc.next();
        String[] ws = t.split("W");
        int [] a = new int[n];
        l = ws.length
        for (int i = 0; i <ws.length ; i++) {
            if (ws[i].length()>0)
                a[i] = ws[i].length
            else
                l--;
        }
        p.println(l);
        for(int i=0;i<l;i++)
            p.print(a[i] + " ");

    }
}


import java.util.*;

public class NumbersJoke {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        int a = scan.nextInt();
        if (x >= 30){
        	System.exit(1);
        } else if (a <= 1){
        	System.exit(1);
        }
		int y = 30 - a;

		System.out.print(y);

    }
}


import java.util.*;

public class AprilA {
	public static void main(String[] args) 	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		System.out.println(272727272727272727272727272727272727272727272727272727);

	}

}


public class Test{
public static void main(String[] args){
  Scanner input = new Scanner(System.in);
  int n = input.nextInt();
  System.out.println((40-1-n-n*n));

}
}


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

public class sample {
    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(in.readLine());
        StringTokenizer st = new StringTokenizer(in.readLine());
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = Integer.parseInt(st.nextToken());
        int max = -1;
        int smax = -1;
        for (int i = 0; i < n; i++)
            if (max < a[i])
                max = a[i];
        for (int i = 0; i < n; i++)
            if (smax < a[i] && a[i] != max)
                smax = a[i];
        if(max >=  2* smax)
            System.out.println("NO");
        else
            System.out.println("YES");
    }
}


import static java.lang.Math.*;
import static java.lang.System.currentTimeMillis;
import static java.lang.System.exit;
import static java.lang.System.arraycopy;
import static java.util.Arrays.sort;
import static java.util.Arrays.binarySearch;
import static java.util.Arrays.fill;
import java.util.*;
import java.io.*;

public class Main {

    public static void main(String[] args) throws IOException {
        try {
            if (new File("input.txt").exists())
                System.setIn(new FileInputStream("input.txt"));
        } catch (SecurityException e) {
        }
        new Main().run();

    }

    BufferedReader in;
    PrintWriter out;
    StringTokenizer st = new StringTokenizer("");

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

        int n = nextInt();
        long a[] = new long[n];

        for(int i = 0; i < n; i++) a[i] = nextInt();

        sort(a);

        long mx2 = a[n - 1];
        for(int i = n - 1; i >= 0; i--){
            if(a[i] < mx2){
                mx2 = a[i];
                break;
            }
        }

        if(mx2 * 2 <= a[n - 1]) out.println("NO");
        else out.println("YES");
        in.close();
        out.close();
    }

    void chk(boolean b) {
        if (b)
            return;
        System.out.println(new Error().getStackTrace()[1]);
        exit(999);
    }
    void deb(String fmt, Object... args) {
        System.out.printf(Locale.US, fmt + "%n", args);
    }
    String nextToken() throws IOException {
        while (!st.hasMoreTokens())
            st = new StringTokenizer(in.readLine());
        return st.nextToken();
    }
    int nextInt() throws IOException {
        return Integer.parseInt(nextToken());
    }
    long nextLong() throws IOException {
        return Long.parseLong(nextToken());
    }
    double nextDouble() throws IOException {
        return Double.parseDouble(nextToken());
    }
    String nextLine() throws IOException {
        st = new StringTokenizer("");
        return in.readLine();
    }
    boolean EOF() throws IOException {
        while (!st.hasMoreTokens()) {
            String s = in.readLine();
            if (s == null)
                return true;
            st = new StringTokenizer(s);
        }
        return false;
    }
}


public class Datatypes {
    public static void main(String[] args) throws NumberFormatException,
            IOException {
        BufferedReader buf = new BufferedReader(
                new InputStreamReader(System.in));
        int n = Integer.parseInt(buf.readLine());
        int[] array = new int[n];
        String[] line = buf.readLine().split(" ");
        for (int i = 0; i < n; i++)
            array[i] = Integer.parseInt(line[i]);

        boolean check = true;
        Arrays.sort(array);
        for (int i = 0; i < n-1 && check; i++) {
                if (array[i] != array[i+1]) {
                        check = find(array[i], array[i+1]);
                    }
        }
        if (check)
            System.out.println("NO");
        else
            System.out.println("YES");
    }

    public static boolean find(int a, int b) {
        if (a == 1)
            return true;
        else {
            if (2 * a > b)
                return false;
            else
                return true;
        }
    }

}


import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TaskB {

	final static int size = 200005;

	public static long[] getWithoutCopies(long[] mas) {
		HashSet<Long> withoutCopies = new HashSet<Long>();
		for (int i = 0; i < mas.length; ++i) {
			withoutCopies.add(mas[i]);
		}
		long[] result = new long[withoutCopies.size()];
		Iterator<Long> it = withoutCopies.iterator();
		int j = 0;
		while (it.hasNext()) {
			result[j++] = it.next();
		}
		return result;
	}

	public static void main(String[] args) throws IOException {
		PrintWriter jout = new PrintWriter(System.out);
		Scanner jin = new Scanner(new InputStreamReader(System.in));
		int n = jin.nextInt();
		//String a = jin.nextLine();
		//a = jin.nextLine();
		long mas[] = new long[n];
		StringTokenizer t = new StringTokenizer(a);
		for (int i = 0; i < n; ++i) {
			mas[i] = jin.nextLong();
		}

		mas = getWithoutCopies(mas);
		Arrays.sort(mas);
		for (int i = 1; i < mas.length; ++i) {
			if (mas[i] < 2 * mas[i - 1]) {
				System.out.println("YES");
				return;
			}
		}
		System.out.println("NO");
		jout.close();

	}
}


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

/**
 * Date 22.11.2011
 * Time 19:00:19
 * Author Woodey
 * $
 */

public class A73 {
	private void Solution() throws IOException {
		int x = nextInt(), y = nextInt(), z = nextInt(), k = nextInt();
		k = Math.min(k, x + y + z - 3);
		long a = 1, b = 1, c = 1;
		while (true) {
			if (a < x) {
				a ++;
				k --;
			}
			if (k == 0)
				break;
			if (b < y) {
				b ++;
				k --;
			}
			if (k == 0)
				break;
			if (c < z) {
				c ++;
				k --;
			}
			if (k == 0)
				break;
		}
		System.out.println(a * b * c);
	}

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

	BufferedReader in;
	StringTokenizer tokenizer;

	public void run() {
		try {
			in = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
			Solution();
			in.close();
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens())
			tokenizer = new StringTokenizer(in.readLine());
		return tokenizer.nextToken();
	}
}


/**
 * Created by IntelliJ IDEA.
 * User: shakhov
 * Date: 15.06.2011
 * Time: 15:22:46
 * To change this template use File | Settings | File Templates.
 */

//6
//86 402 133 524 405 610   6 4 1

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;

public class CodeForces {

	public void solve() throws IOException {
		int arr[] = new int[3];
		for (int i = 0; i < 3; i++) {
			arr[i] = nextInt() - 1;
		}
		int k = nextInt();
		int cur[] = { 0, 0, 0 };
		boolean[] cure = { 0==arr[0], 0==arr[1], 0==arr[2]};
		while (k > 0) {
			if ((cur[0] <= cur[1] || cure[1]) && (cur[0] <= cur[2] || cure[2]) && !cure[0]) {
				cur[0]++;
				if (cur[0] == arr[0])
					cure[0] = true;
			} else if ((cur[1] <= cur[0] || cure[0]) && (cur[1] <= cur[2] || cure[2]) && !cure[1]) {
				cur[1]++;
				if (cur[1] == arr[1])
					cure[1] = true;
			} else if ((cur[2] <= cur[1] || cure[1]) && (cur[2] <= cur[0] || cure[0]) && !cure[2]) {
				cur[2]++;
				if (cur[2] == arr[2])
					cure[2] = true;
			}
			k--;
		}
		out.println((cur[0] + 1) * (cur[1] + 1) * (cur[2] + 1));
	}

	private BufferedReader reader;
	private StringTokenizer tokenizer;
	private String separator;
	public PrintWriter out;

	public static void main(String[] args) {
		new CodeForces().run(new InputStreamReader(System.in), new OutputStreamWriter(System.out));
	}

	public void run(Reader reader, Writer writer) {
		try {
			this.reader = new BufferedReader(reader);
			out = new PrintWriter(writer);
			tokenizer = new StringTokenizer("");
			separator = System.getProperty("line.separator");
			separator = Character.toString(separator.charAt(separator.length() - 1));
			long t1 = System.currentTimeMillis();
			solve();
			out.flush();
			reader.close();
			writer.close();
			long t2 = System.currentTimeMillis();
			System.err.println("Time = " + (t2 - t1));
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		}
	}

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

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}

	String nextToken() throws IOException {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			tokenizer = new StringTokenizer(reader.readLine());
		}
		return tokenizer.nextToken();
	}
}


import java.util.*;
import java.math.*;

public class elder{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);

		int x = scan.nextInt();
		int y = scan.nextInt();
		int z = scan.nextInt();
		int k = scan.nextInt();

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

		if(k >= x + y + z - 3){
			System.out.println(bigIntegerFromInt(x).multiply(bigIntegerFromInt(y)).multiply(bigIntegerFromInt(z)));
			return;
		}

		BigInteger pieces = new BigInteger("1");

		BigInteger[] planePieces = {new BigInteger("1"), new BigInteger("1"), new BigInteger("1")};
		int[] dims = {x - 1, y - 1, z - 1};
		int[] cuts = {0, 0, 0};
		int j = 0;

		while(k > 0){
			if(dims[j] == 0){
				j = (j + 1) % 3;
				continue;
			}

			dims[j]--;
			cuts[j]++;

			pieces = pieces.add(planePieces[j]);

			planePieces[(j + 1) % 3] = planePieces[(j + 1) % 3].add(bigIntegerFromInt(cuts[(j + 2) % 3] + 1));
			planePieces[(j + 2) % 3] = planePieces[(j + 2) % 3].add(bigIntegerFromInt(cuts[(j + 4) % 3] + 1));
			k--;
			j = (j + 1) % 3;
		}

		System.out.println(pieces.toString());
	}

	public static int countDimsLeft(int[] dims){
		int dimsleft = 0;
		for(int i = 0; i < dims.length; i++){
			if(dims[i] > 0) dimsleft++;
		}
		return dimsleft;
	}

	public static BigInteger bigIntegerFromInt(int n){
		return new BigInteger(new Integer(n).toString());
	}

}