#include <bits/stdc++.h>
using namespace std;
template <typename T>
void printvi(vector<T> v, string sep = " ", string bookend = "") {
  cout << bookend << ((bookend == "") ? "" : " ");
  for (T n : v) cout << n << sep;
  cout << bookend << endl;
}
void printvii(vector<pair<int, int>> v, string sep = " ", string bookend = "") {
  cout << bookend << ((bookend == "") ? "" : " ");
  for (pair<int, int> p : v)
    cout << "(" << p.first << "," << p.second << ")" << sep;
  cout << bookend << endl;
}
double DEG_to_RAD(double d) { return d * acos(-1.0) / 180.0; }
double RAD_to_DEG(double r) { return r * 180.0 / acos(-1.0); }
struct point_i {
  int x, y;
  point_i() { x = y = 0; }
  point_i(int _x, int _y) : x(_x), y(_y) {}
};
struct point {
  double x, y;
  point() { x = y = 0.0; }
  point(double _x, double _y) : x(_x), y(_y) {}
  bool operator<(point other) const {
    if (fabs(x - other.x) > 1e-9) return x < other.x;
    return y < other.y;
  }
  bool operator==(point other) const {
    return (fabs(x - other.x) < 1e-9 && (fabs(y - other.y) < 1e-9));
  }
};
double dist(point p1, point p2) { return hypot(p1.x - p2.x, p1.y - p2.y); }
point rotate(point p, double theta) {
  double rad = DEG_to_RAD(theta);
  return point(p.x * cos(rad) - p.y * sin(rad),
               p.x * sin(rad) + p.y * cos(rad));
}
struct line {
  double a, b, c;
  point pta, ptb;
};
void pointsToLine(point p1, point p2, line &l) {
  if (fabs(p1.x - p2.x) < 1e-9) {
    l.a = 1.0;
    l.b = 0.0;
    l.c = -p1.x;
  } else {
    l.a = -(double)(p1.y - p2.y) / (p1.x - p2.x);
    l.b = 1.0;
    l.c = -(double)(l.a * p1.x) - p1.y;
  }
  l.pta = p1;
  l.ptb = p2;
}
struct line2 {
  double m, c;
};
int pointsToLine2(point p1, point p2, line2 &l) {
  if (abs(p1.x - p2.x) < 1e-9) {
    l.m = 1000000000;
    l.c = p1.x;
    return 0;
  } else {
    l.m = (double)(p1.y - p2.y) / (p1.x - p2.x);
    l.c = p1.y - l.m * p1.x;
    return 1;
  }
}
bool areParallel(line l1, line l2) {
  return (fabs(l1.a - l2.a) < 1e-9) && (fabs(l1.b - l2.b) < 1e-9);
}
bool areSame(line l1, line l2) {
  return areParallel(l1, l2) && (fabs(l1.c - l2.c) < 1e-9);
}
bool areIntersect(line l1, line l2, point &p) {
  if (areParallel(l1, l2)) return false;
  p.x = (l2.b * l1.c - l1.b * l2.c) / (l2.a * l1.b - l1.a * l2.b);
  if (fabs(l1.b) > 1e-9)
    p.y = -(l1.a * p.x + l1.c);
  else
    p.y = -(l2.a * p.x + l2.c);
  return true;
}
struct vec {
  double x, y;
  vec(double _x, double _y) : x(_x), y(_y) {}
};
vec toVec(point a, point b) { return vec(b.x - a.x, b.y - a.y); }
vec scale(vec v, double s) { return vec(v.x * s, v.y * s); }
point translate(point p, vec v) { return point(p.x + v.x, p.y + v.y); }
void pointSlopeToLine(point p, double m, line &l) {
  l.a = -m;
  l.b = 1;
  l.c = -((l.a * p.x) + (l.b * p.y));
}
void closestPoint(line l, point p, point &ans) {
  line perpendicular;
  if (fabs(l.b) < 1e-9) {
    ans.x = -(l.c);
    ans.y = p.y;
    return;
  }
  if (fabs(l.a) < 1e-9) {
    ans.x = p.x;
    ans.y = -(l.c);
    return;
  }
  pointSlopeToLine(p, 1 / l.a, perpendicular);
  areIntersect(l, perpendicular, ans);
}
void reflectionPoint(line l, point p, point &ans) {
  point b;
  closestPoint(l, p, b);
  vec v = toVec(p, b);
  ans = translate(translate(p, v), v);
}
double dot(vec a, vec b) { return (a.x * b.x + a.y * b.y); }
double norm_sq(vec v) { return v.x * v.x + v.y * v.y; }
double distToLine(point p, point a, point b, point &c) {
  vec ap = toVec(a, p), ab = toVec(a, b);
  double u = dot(ap, ab) / norm_sq(ab);
  c = translate(a, scale(ab, u));
  return dist(p, c);
}
double distToLineSegment(point p, point a, point b, point &c) {
  vec ap = toVec(a, p), ab = toVec(a, b);
  double u = dot(ap, ab) / norm_sq(ab);
  if (u < 0.0) {
    c = point(a.x, a.y);
    return dist(p, a);
  }
  if (u > 1.0) {
    c = point(b.x, b.y);
    return dist(p, b);
  }
  return distToLine(p, a, b, c);
}
double angle(point a, point o, point b) {
  vec oa = toVec(o, a), ob = toVec(o, b);
  return acos(dot(oa, ob) / sqrt(norm_sq(oa) * norm_sq(ob)));
}
double cross(vec a, vec b) { return a.x * b.y - a.y * b.x; }
bool ccw(point p, point q, point r) {
  return cross(toVec(p, q), toVec(p, r)) > 0;
}
bool collinear(point p, point q, point r) {
  return fabs(cross(toVec(p, q), toVec(p, r))) < 1e-9;
}
int main() {
  ios_base::sync_with_stdio(false);
  int left, right;
  cin >> left >> right;
  map<int, int> leftShips, rightShips;
  for (int i = 0; i < left; ++i) {
    int y;
    cin >> y;
    if (leftShips.count(y) == 0)
      leftShips[y] = 1;
    else
      ++leftShips[y];
  }
  for (int i = 0; i < right; ++i) {
    int y;
    cin >> y;
    if (rightShips.count(y) == 0)
      rightShips[y] = 1;
    else
      ++rightShips[y];
  }
  vector<line> lines;
  for (auto lit = leftShips.begin(); lit != leftShips.end(); ++lit) {
    for (auto rit = rightShips.begin(); rit != rightShips.end(); ++rit) {
      point a(-100, lit->first), b(100, rit->first);
      line add;
      pointsToLine(a, b, add);
      lines.push_back(add);
    }
  }
  map<point, set<point>> intersections;
  for (int i = 0; i < (int)lines.size(); ++i) {
    for (int j = i + 1; j < (int)lines.size(); ++j) {
      if (i == j) continue;
      line a = lines[i], b = lines[j];
      point intersect;
      if (areIntersect(a, b, intersect) && fabs(intersect.x - 0.0) < 1e-9) {
        intersections[intersect].insert(a.pta);
        intersections[intersect].insert(a.ptb);
        intersections[intersect].insert(b.pta);
        intersections[intersect].insert(b.ptb);
      }
    }
  }
  if ((int)intersections.size() <= 1) {
    line axis;
    pointsToLine(point(0, 0), point(0, 1), axis);
    for (int i = 0; i < (int)lines.size(); ++i) {
      point intersect;
      if (areIntersect(lines[i], axis, intersect) &&
          fabs(intersect.x - 0.0) < 1e-9) {
        intersections[intersect].insert(lines[i].pta);
        intersections[intersect].insert(lines[i].ptb);
      }
    }
  }
  int best = 0;
  if ((int)intersections.size() == 3600)
    best = 4;
  else {
    for (auto it = intersections.begin()->second.begin();
         it != intersections.begin()->second.end(); ++it)
      best +=
          ((int)it->x == -100) ? leftShips[(int)it->y] : rightShips[(int)it->y];
    for (auto ita = intersections.begin(); ita != intersections.end(); ++ita) {
      for (auto itb = intersections.begin(); itb != intersections.end();
           ++itb) {
        if (ita == itb) continue;
        set<point> merged(ita->second);
        merged.insert(itb->second.begin(), itb->second.end());
        int sum = 0;
        for (auto mit = merged.begin(); mit != merged.end(); ++mit)
          sum += ((int)mit->x == -100) ? leftShips[(int)mit->y]
                                       : rightShips[(int)mit->y];
        best = max(best, sum);
      }
    }
  }
  cout << best << endl;
  return 0;
}
