#include <bits/stdc++.h>
const double PI = acos(-1.0);
using namespace std;
int setb(int n, int pos) { return n = n | (1 << pos); }
int resb(int n, int pos) { return n = n & ~(1 << pos); }
bool checkb(int n, int pos) { return (bool)(n & (1 << pos)); }
inline long long bigmod(long long b, long long p, long long m) {
  long long ret = 1, cur = b % m;
  while (p) {
    if (p & 1) ret = (ret * cur) % m;
    cur = (cur * cur) % m;
    p = p >> 1;
  }
  return ret;
}
int n, m, ara[505];
long long dp[502][502];
bool visit[502][502];
long long F(int l, int r) {
  if (l > r) return 1;
  if (visit[l][r]) return dp[l][r];
  int mn = 1e6, idx;
  for (int i = l; i <= r; i++) {
    if (ara[i] < mn) {
      mn = ara[i];
      idx = i;
    }
  }
  long long ret = 0;
  long long lft = 0;
  for (int i = l; i <= idx; i++)
    lft = (lft + F(l, i - 1) * F(i, idx - 1)) % 998244353;
  long long rgt = 0;
  for (int j = idx; j <= r; j++)
    rgt = (rgt + F(j + 1, r) * F(idx + 1, j)) % 998244353;
  ret = (lft * rgt) % 998244353;
  visit[l][r] = 1;
  return dp[l][r] = ret;
}
int main() {
  int i;
  scanf("%d %d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &ara[i]);
  long long ret = F(1, n);
  printf("%lld", ret);
  printf("\n");
  return 0;
}
