#include <bits/stdc++.h>
using namespace std;
void firstButton(string &str) {
  for (int i = 0; i < int(str.length()); i++)
    if (str.at(i) == '9')
      str.replace(i, 1, 1, '0');
    else
      str.replace(i, 1, 1, str.at(i) + 1);
}
void secondButton(string &str) {
  str = str.at(str.length() - 1) + str.substr(0, str.length() - 1);
}
int main() {
  int n;
  char c;
  string number, pass;
  cin >> n;
  cin.get(c);
  getline(cin, number);
  pass = number;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < n; j++) {
      if (pass > number) pass = number;
      secondButton(number);
    }
    firstButton(number);
  }
  cout << pass;
  return 0;
}
