#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 120
const double eps = 1e-9;

inline int sig(double x){
    return (x>eps)-(x<-eps);
}

struct node{
    int x1, x2, y1, y2;
    double k, c;
    void in(){
        scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
    }
    void get_kc(){
        k = (y2-y1)*1.0/(x2-x1);
        c = y2*1.0 - k*x2;
    }
};
node p[N], que[N];
int w, n;

bool cmp(node a, node b)
{
    if(fabs(a.k-b.k) < eps) return a.c > b.c;
    else    return a.k > b.k;
}

void deal()
{
    int i, ct = 0, ps;
    sort(p, p+n, cmp);
    que[++ct] = p[0];
    for(i = 1; i < n; i++)
    {
        if(fabs(p[i].k-que[ct].k) < eps && fabs(p[i].c-que[ct].c) < eps)
            continue;
        else    que[++ct] = p[i];
    }
    //cout << "...ct " << ct << endl;
    int cnt, kps;
    if(fabs(que[ct].k-que[0].k) < eps)
    {
        if(ct+1 >= w) puts("0");
        else
        {
            cnt = 0, kps = ct;
            while(kps < w){
                cnt++;
                kps = ((ct+cnt)<<1);
            }
            printf("%d\n", cnt);
            return ;
        }
    }
    else
    {
        ps = (ct<<1);
        if(ps >= w) puts("0");
        else{
            cnt = 0, kps = ct;
            while(kps < w){
                cnt++;
                kps = ((ct+cnt)<<1);
            }
            printf("%d\n", cnt);
            return ;
        }
    }
    return ;
}

int main()
{
    freopen("in.txt", "r", stdin);
    while(~scanf("%d %d", &w, &n))
    {
        for(int i = 0; i < n; i++) {
            p[i].in();
            p[i].get_kc();
        }
        deal();
    }
    return 0;
}