//
// Written by Fyodor Menshikov 07.03.2010
// 05:58-06:04
//

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

class Assert {
   static void check(boolean e) {
      if (!e) {
         throw new Error();
      }
   }
}

class Main {

   Scanner in;
   PrintWriter out;

   void solve() {
      long n = in.nextInt();
      Assert.check(1 <= n && n <= Integer.MAX_VALUE);
      long pow2 = 1;
      while (pow2 * 2 <= n) {
         pow2 *= 2;
      }
      Assert.check(1 <= pow2 && pow2 <= n);
      Assert.check(pow2 * 2 > n);
      long ans;
      if (pow2 > 1) {
         Assert.check(pow2 % 2 == 0);
         if (pow2 / 2 * 3 <= n) {
            ans = pow2 / 2 * 3;
         } else {
            ans = pow2;
         }
      } else {
         Assert.check(pow2 == 1);
         Assert.check(n == 1);
         ans = 1;
      }
      Assert.check(1 <= ans && ans <= n);
      out.println(ans);
   }

   void run() {
      try {
         in = new Scanner(System.in);
         out = new PrintWriter(System.out);
      } catch (Exception e) {
         throw new Error(e);
      }
      try {
         solve();
      } finally {
         out.close();
      }
   }

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