#include<bits/stdc++.h>
using namespace std;

// Macros
//#define int long long int
#define lli long long int
#define ulli unsigned long long int
#define mods 1000000007
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forLoop(i, a, b) for(int i=a; i<b; i++)
#define endl "\n"
#define all(x) (x).begin(),(x).end()
#define mem0(a) memset(a,0,sizeof(a))

// Pre defined Variables as a constant
const long long INF = 1e18;
const int32_t M = 1e9 + 7;
const int32_t MM = 998244353;

// Functions
int www(int x, int y) {
    if (x == 0) return 0;
    return ((x % y == 0) ? x / y : x / y + 1);
}

void for_cop() {
    lli s;
    cin >> s;
    lli tmp = 1;
    lli ans = 0;
    while (1) {
        lli tmp2 = stoll(to_string(tmp) + to_string(tmp));
        tmp++;
        if (tmp2 > s)  break;
        ans++;
    }
    cout << ans << endl;
}

// Main Code
int32_t main()
{
    fio;
    int t = 1;
    //cin >> t;
    while (t--) for_cop();
    return 0;
}
// Ends Here
#include <bits/stdc++.h>
using namespace std;

const int N = 105;

int n;
char s[N][N];

vector<int> edges[N];

int cnt[N];
void bfs(int u) {
  queue<int> q;
  vector<bool> vis(n);
  q.push(u);
  vis[u] = true;

  while (q.size()) {
    int u = q.front();
    q.pop();

    for (int v: edges[u]) {
      if (vis[v]) continue;
      vis[v] = true;
      q.push(v);
    }
  }

  for (int u = 0; u < n; ++u) {
    if (vis[u]) ++cnt[u];
  }
}

int solve() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    scanf("%s", s[i]);
    for (int j = 0; j < n; ++j) {
      if (s[i][j] == '1') edges[i].push_back(j);
    }
  }

  for (int i = 0; i < n; ++i) bfs(i);

  double ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += 1.0 / cnt[i];
  }

  printf("%.15lf\n", ans);
  return 0;
}

int main() {
  int t = 1;
  // scanf("%d", &t);
  for (int tc = 0; tc < t; ++tc) {
    solve();
  }
  return 0;
}
