#include <bits/stdc++.h>
int N;
int b0, b1, b2, b3;
int main() {
  scanf("%d", &N);
  b0 = N >> 0 & 1;
  b1 = N >> 1 & 1;
  b2 = N >> 2 & 1;
  b3 = N >> 3 & 1;
  if (1) b3 ^= 1;
  if (b3) b2 ^= 1;
  if (b3 && b2) b1 ^= 1;
  if (b3 && b2 && b1) b0 ^= 1;
  printf("%d\n", b3 << 3 | b2 << 2 | b1 << 1 | b0 << 0);
  return 0;
}
