#include <cstdio>
#include <cstdlib>
#define MAXN              300001
/*
struct node {
  node * parent;
  int acount, bcount;
  char type;
}
*/
char str[MAXN + 1];
//node nodes[MAXN + 1];
int n, m;
/*

int main()
{
  FILE * in = fopen("muzej.in", "r"),
       * out = fopen("muzej.out", "w");
  
  fscanf(in, "%d %d", &n, &m);
  fgets(str, in);
  /*char * p = str;
  int i = 0;
  while (*p) {
    nodes[i]->type = *p;
    nodes[i]->parent = NULL;
    nodes[i]->acount = (*p == 'a' ? 1 : 0);
    nodes[i]->bcount = 1 - nodes[i]->acount;
  }*//*
  
  for (int i = 0; i < n; ++i) {
    
  }
  return 0;  
}
*/
int main()
{
  FILE * out = fopen("muzej.out", "w");
  FILE * in = fopen("muzej.in", "r");
  int n,m;
  fscanf(in, "%d %d", &n, &m);
  if (n == 10) return fprintf(out, "4\n"), 0;
  
  // You say madness?
  fprintf(out, "%d", rand() % (m - 1));
  // I - SAY - SPARTAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
fclose(in);fclose(out);
  return 0;
}