#include <iostream>
#include <cmath>

using namespace std;
/*
void calculate(float X) {
  float deg = X;
  float T = 3.14159265/180;
  int t = 0;
  float x = 0, y = 0;
  float e = 0.001;
  while (true) {
    t++;
    x -= sin(deg*T);
    y -= cos(deg*T);
    deg += X;
    //cout << X << endl;
    //cout << x << " " << y << endl;
    if (-1*e <= x && x <= e && -1*e <= y && y <= e) {
      break;
    }
  }
  cout << t << endl;
}
*/

int main() {
  int ans[179] = {
               360,
               180,
               120,
               90,
               72,
               60,
               360,
               45,
               40,
               36,
               360,
               30,
               360,
               180,
               24,
               45,
               360,
               20,
               360,
               18,
               120,
               180,
               360,
               15,
               72,
               180,
               40,
               90,
               360,
               12,
               360,
               45,
               120,
               180,
               72,
               10,
               360,
               180,
               120,
               9,
               360,
               60,
               360,
               90,
               8,
               180,
               360,
               15,
               360,
               36,
               120,
               90,
               360,
               20,
               72,
               45,
               120,
               180,
               360,
               6,
               360,
               180,
               40,
               45,
               72,
               60,
               360,
               90,
               120,
               36,
               360,
               5,
               360,
               180,
               24,
               90,
               360,
               60,
               360,
               9,
               40,
               180,
               360,
               30,
               72,
               180,
               120,
               45,
               360,
               4,
               360,
               90,
               120,
               180,
               72,
               15,
               360,
               180,
               40,
               18,
               360,
               60,
               360,
               45,
               24,
               180,
               360,
               10,
               360,
               36,
               120,
               45,
               360,
               60,
               72,
               90,
               40,
               180,
               360,
               3,
               360,
               180,
               120,
               90,
               72,
               20,
               360,
               45,
               120,
               36,
               360,
               30,
               360,
               180,
               8,
               45,
               360,
               60,
               360,
               18,
               120,
               180,
               360,
               5,
               72,
               180,
               120,
               90,
               360,
               12,
               360,
               45,
               40,
               180,
               72,
               30,
               360,
               180,
               120,
               9,
               360,
               20,
               360,
               90,
               24,
               180,
               360,
               15,
               360,
               36,
               40,
               90,
               360,
               60,
               72,
               45,
               120,
               180,
               360,
  };
  int X;
  cin >> X;
  cout << ans[X - 1] << endl;
}


Measured memory_bytes: 3544