Between 1503 and 1522 , for the sake of protection from Crimean Tatar attacks , the city was surrounded by defensive walls that had nine gates and three towers .
Between 1503 and 1522 the walls were built to protect the city , and at the time it had nine city gates and three towers .