#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, s = 0;
  scanf("%d:%d", &a, &b);
  int n = a % 10, m = a / 10;
  int c = n * 10 + m;
  if (c < 60 && c >= b) {
    s += c - b;
    cout << s << endl;
  } else {
    for (;;) {
      a++;
      s += 60 - b;
      b = 0;
      n = a % 10, m = a / 10;
      c = n * 10 + m;
      if (a >= 24) {
        break;
      }
      if (c < 60) {
        s += c;
        break;
      }
    }
    cout << s << endl;
  }
  return 0;
}
