int countSkippedCells(int cellId) {
        int segment = mesh.getSegmentNumber(cellId);
        int row = mesh.getRow(cellId);
        int offset = 0;
        if (mesh.isOffsetRow(row)) {
            offset = 1;
        }
        int n = mesh.getDistanceInCellsBetweenPoles() / 5;
        if (row < 0) {
            return 0;
        }
        if (row < n)  {
            int skippedBeforeMap = (2*n - row) / 2;
            int smallGap = n - row;
            int bonusGap = n;
            int numBonusGaps = segment / 2;
            return skippedBeforeMap + segment * smallGap + numBonusGaps * bonusGap;
        }
        if (row < 2*n) {
            int skippedBeforeMap = (2*n - row) / 2;
            int gap = 2*n - row;
            return skippedBeforeMap + segment * gap;
        }
        if (row <= 3*n) {
            return 0;
        }
        if (row <= 4*n) {
            int skippedBeforeMap = 0;
            int gap = row - 3*n;
            return skippedBeforeMap + segment * gap;
        }
        if (row <= 5*n) {
            int skippedBeforeMap = (row - 4*n) / 2;
            int smallGap = row - 4*n;
            int bonusGap = n;
            int numBonusGaps = (segment + 1) / 2;
            return skippedBeforeMap + segment * smallGap + numBonusGaps * bonusGap;
        }
        return 0;
    }