#include <cstdio>
#include <vector>
#include <cmath>

struct Point {
    double x, y;
     
    Point (double x = 0, double y = 0) : x(x), y(y) { }
     
    static Point read() {
        double x, y;
        scanf("%lf %lf", &x, &y);
        return Point(x, y);
    }
     
    bool in_circle(const double r) const {
        return x*x+y*y < r*r;
    }
};
 
Point operator -(const Point & left, const Point & right) {
    return Point(left.x-right.x, left.y-right.y);
}
 
Point operator +(const Point & left, const Point & right) {
    return Point(left.x+right.x, left.y + right.y);
}
 
Point operator *(const Point & left, const double right) {
    return Point(left.x * right, left.y * right);
}
 
Point operator *(const double left, const Point & right) {
    return right * left;
}
 
double det(const Point & left, const Point & right) {
    return left.x * right.y - left.y * right.x;
}
 
struct Line {
    Point A, B;
     
    Line (const Point & A = Point(), const Point & B = Point()) : A(A), B(B) { }
     
    static Line read() {
        return Line(Point::read(), Point::read());
    }
     
    Point intersect(const Line & other) const {
        return other.A + (other.B-other.A) * (det(other.A - A, B-A) / det(B-A, other.B-other.A));
    }
};
 
int main() {
    //freopen("input.txt", "rt", stdin);
     
    double r;
    int k;
    scanf("%lf %d", &r, &k);
     
    int count = 1+k;
    std::vector<Line> v(k);
    for (int i = 0; i < (int) v.size(); ++i) {
        v[i] = Line::read();
        for (int j = 0; j < i; ++j) {
            count += v[i].intersect(v[j]).in_circle(r);
        }
    }
     
    printf("%d", count);
     
    return 0;   
}