#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <vector>
#include <string>
#include <math.h>
#include <map>
#include <set>
using namespace std;

int n;
int test=5, maxnum=11;
int a[50];
int b[50];
long long p,s;
int sol[1000];


void check(){
  p=s=1;
  for (int i=1; i<=test; i++) {p*=a[i]; s*=(a[i]+1);}

  if (s%p==0 && s/p<1000) {
    if (sol[s/p]>test) sol[s/p]=test;
  }
}

void gen(int i, int p){
  if (i>test){
    check();
    return;
  }
  for (a[i]=p; a[i]<maxnum; a[i]++) gen(i+1,a[i]);
}




int main(){
  int n;
  scanf("%d", &n);

  for (int i=0; i<1000; i++) sol[i]=9999999;

  for (test=1; test<14; test++) gen(1,1);

  int k=0;
  for (int i=1; i<1000; i++) if (sol[i]<999) k++;
  //printf("%d\n", k);

  printf("%d\n", sol[n]);
  return 0;
}
